user308827 user308827 - 9 months ago 32
Python Question

Explicitly labeling end points in matplotlib graph

In the matplotlib graph above, the x-axis ranges from 850 - 2015. I would like them to be explicitly labeled. Is there a way to force matplotlib to do that?

I am doing this:

ax.set_xlim([min(xvar), max(xvar)])
, here xvar is the x-axis array ranging from 850 - 2015


try set_xticks and set_xticklabels to set the location and content of labels.

import matplotlib.pyplot as plt
a = plt.subplot(1,1,1)
a.set_xticks([0, 5, 10, 10.5])
a.set_xticklabels([0, 5, 10, 10.5])

enter image description here