user308827 user308827 - 1 year ago 65
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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download