Python & Matplotlib - creating date ticks from a string

I have an array of strings that contain dates formatted as such: '01 / 01/09 '. I also have an array of floats with date values.

I want to take these dates and ultimately display them as x tick marks on my graph.

How to use floats or lines to indicate ticks on the x axis on my matplotlib chart? (using something like xticks)

+4
source share
1 answer

You set the set_xticks counter (and values) with set_xticks . You set set_xticklabels text with set_xticklabels

 from matplotlib import pyplot as plt plt.plot([1,2,3],[3,4,3]) ax = plt.gca() ax.set_xticks([1,2,3]) ax.set_xticklabels(['1/1','1/2','1/3']) 
+7
source

Source: https://habr.com/ru/post/1345303/


All Articles