'How do I solve this too crowded x-axis when x-ticks does not work?

Context: The Data is on the millisecond and is in the following format:

'08:04:18.795'

'08:13:15.496'

Now what I want is to create specific time brackets (e.g. 08-11, 11-14, 14-17, etc.). If I plot this I get a too crowded x-axis where nothing is visible (black line as shown in the plot) and the x-ticks function does not work. Can someone help me fix this?

# Visualization of the price movement of the Security on 4/12/2020
plt.plot(df_trade_day1['time'],df_trade_day1['price'])
plt.show()

Price movement



Solution 1:[1]

This was answered here

This is the code I used

for ind, label in enumerate(plot_.get_xticklabels()):
    if ind % 10 == 0:  # every 10th label is kept
        label.set_visible(True)
    else:
        label.set_visible(False)

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 IsmailHabib97