Reputation: 1053
simple, probably dummy question, but I can't find the answer:
How to adjust the X axis for a bar plot in Matplotlib?
my code so far:
_ = matplotlib.pyplot.bar(names, value, color="blue")
_.axis([-11,11,0,1])
returns
--> AttributeError: 'BarContainer' object has no attribute 'axis'
Upvotes: 0
Views: 2291
Reputation: 116
First of all a good practise to make things easier is to import this:
import matplotlib.pyplot as plt
and then you can simply
plt.bar(names, value, color="blue")
plt.xlim([-11,11])
plt.show()
Upvotes: 1
Reputation: 420
You can use xlim for this!
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.xlim.html
Example:
import matplotlib.pyplot as plt
plt.xlim(-11, 11)
Upvotes: 1