pouria.vzr
pouria.vzr

Reputation: 65

Customizing the height in bar chart matplotlib

How can I force one of the bars to touch the roof of the plot in the matplotlib bar chart? there always a gap between them

Upvotes: 2

Views: 9329

Answers (1)

pakpe
pakpe

Reputation: 5479

By using plt.ylim(top = max(...)) as below:

import matplotlib.pyplot as plt

months = ["March", "April", "May", "June", "July", "August"]
cases = [1000, 2000, 5000, 8000, 15000, 6000]

plt.bar(months, cases, width=0.5, color="orange", label="All cases")
plt.ylim(top = max(cases))
plt.show()

enter image description here

Upvotes: 3

Related Questions