'Matplotlib plot label truncates
I'm working on a Horizontal Bar and added bar label. The first bar's label should show 1,857,045 which is 7 digits but as you can see here it weirdly truncates and displays 1,85704e+06. I want the label to display the whole number but couldn't find which parameters of bar_label I should change.
Below is my code:
fig, ax = plt.subplots(figsize=(15, 10))
plt.title(f"Refugees Fleeing Ukraine by Country as of {last_date}", fontsize=20)
ax.bar_label(container=ax.barh(list(countries_refugees.keys()), list(countries_refugees.values())), label_type="edge", padding=2, fontsize=15)
ax.tick_params(axis="both", labelsize=20)
ax.get_xaxis().get_major_formatter().set_scientific(False)
plt.xlim([0, 2100000])
plt.xlabel("Number of Refugees", fontsize=20)
plt.tight_layout()
plt.show()
Question is how can I make the actual number to be displayed as the bar's label rather than this weird truncation?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
