'Change tick frequency matlplotlib

I've a pandas series which contains several time. When i try to plot this date related to another measure, the graph i obtain is: enter image description here

I want to change the frequency of x label, for example showing every 2 labels. What I have already tried is ax2.set_xticks(x[::2]), plt.xticks(np.arange(min(x), max(x)+1, 1.0), rotation=45), but none of that works.

Here is the code i used to plot:

dfDay = pd.read_csv(f, encoding = "ISO-8859-1", sep = ';')
bpm = dfDay .tempo
h = dfDay .time
   
second = plt.figure(figsize=(10,5))
plt.scatter(h, bpm, c = bpm)
plt.xticks(rotation=45)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source