Reputation: 1097
I have a dataset of a year and its numerical description. Example:
X Y
1890 6
1900 4
2000 1
2010 9
I plot a bar like plt.bar(X,Y)
and it looks like:
How can I make the step of the X scale more detailet, for example, 2 years? Can I border somehow every 5 years with another color, red, for instatnce?
Upvotes: 0
Views: 183
Reputation: 13465
There are some different ways to do this. This is a possible solution:
import matplotlib.pyplot as plt
x = [1890,1900,2000,2010]
y = [6,4,1,9]
stepsize = 10 # Chose your step here
fig, ax = plt.subplots()
ax.bar(x,y)
start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, stepsize))
plt.show()
, the result is:
Upvotes: 1