Set xticklabels when x axis is datetime

25 Views Asked by At

I am new to python. My data is stored in cdf format. In my data each second has approx 20,000 points i.e. in millisec. While plotting the x label prints all the second values like, 15, 15, repeatedly for 20,000 points even when I am using matplolib dateformatter. I want the label to be printed only once at the intervals of 15, 20, 25. I am unable to understand how to use set_xticks and set_xtick labels in this scenario.

efw_epoch = cdf['thb_efw_time'][...]  # epoch time for efw
time_ms = efw_time.strftime("%H:%M:%S.%f").str[:-4]
efw = cdf['thb_efw'][...]
plt.plot(time_ms, efw)
hm = mdates.DateFormatter('%S')
ax.xaxis.set_major_formatter(hm)
plt.show()

enter image description here

I want the x ais to show only 15 sec, 20 sec and 25 sec once only

0

There are 0 best solutions below