I have written a very simple piece of code using matplotlib where I want to plot integers on both x and y axis. (I am using Python3 on Raspberry pi)
I searched web and found this thread
how to force matplotlib to display only whole numbers on the Y axis
Based on the suggestion, I wrote this code
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
fig, ax = plt.subplots()
for axis in [ax.xaxis, ax.yaxis]:
axis.set_major_locator(ticker.MaxNLocator(integer=True))
plt.plot([2013, 2014, 2015, 2016], [20, 30, 40, 50])
plt.ylabel("Hot Dog Sales")
plt.xlabel("year")
plt.show()
But it still produces X axis like this