I’ve written a simple program in Python using Matplotlib to draw lines in a coordinate system. I want X-Axis description to be “2006, 2007, 2008” but instead is shows as
“0, 0.5, 1, 1.5, 2.0 +2.006e3”
code is here:
import matplotlib.pyplot
import numpy as np
fig = matplotlib.pyplot.figure()
a=[2006,2007,2008]
b=[-1,3,5]
matplotlib.pyplot.plot(a, b, 'go-', label='line 1', linewidth=2)
matplotlib.pyplot.axis([2006, 2008, -1, 5])
matplotlib.pyplot.show()
Instead of
use plt.xticks:
PS: Its convenient to import
matplotlib.pyplotwithas this cuts down on the typing.