0

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

Mr. T
  • 11,960
  • 10
  • 32
  • 54
PeterPost
  • 1
  • 1
  • [This](https://stackoverflow.com/q/54783160/8881141) is linked as a related question. Have you tried it? Have you had a look at the questions that were suggested when you wrote this? And what does it mean that "x-ticks does not work"? – Mr. T Jan 10 '21 at 13:59
  • Yes sir, I have tried that. With 'x-ticks doesn't work' I should be more clear. What I mean is that when I perform x-ticks before the plt.show(). The output does not change. I still have crowded x-axis unfortunately. – PeterPost Jan 10 '21 at 14:10
  • I still don't know what the code is for "perform x-ticks", and I cannot imagine why any of the linked methods would not work. I suggest you provide a [minimal, complete and verifiable example](https://stackoverflow.com/help/minimal-reproducible-example). – Mr. T Jan 10 '21 at 14:14

1 Answers1

0

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)
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on [how to write good answers](https://stackoverflow.com/help/how-to-answer) in the [help center](https://stackoverflow/help). – user11717481 Apr 24 '22 at 15:17