Reputation: 65
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
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()
Upvotes: 3