Closed gdementen closed 1 year ago
This problem comes from Pandas, which inherits it from matplotlib:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.bar([2010, 2011, 2012], [1, 3, 2])
plt.show()
The problem is only present when there are less than 5 ticks/values:
fig, ax = plt.subplots()
ax.bar([2010, 2011, 2012, 2013, 2014], [1, 3, 2, 4, 2])
plt.show()
For example,
produces a plot from 2010.0 to 2012.0 in steps of 0.25, which looks really silly. Remarkably, the plot produced via the editor GUI (via Ctrl-P) does not suffer from that problem, so its code could probably be used for inspiration.