Python Forum
Only show every nth tick in chart - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Only show every nth tick in chart (/thread-32279.html)



Only show every nth tick in chart - tgottsc1 - Feb-01-2021

Hi guys,

I've plotted a chart using the following basic setup:

df.plot()
However, I only want to have a difference of 300 ticks between the entries on the x-axis, ie.

 df.plot(xticks=(0,300,600,900,...)) 
The problem is that I don't know how to set the tick interval automatically (I have to enter it manually to receive the desired result).

I'd be happy if someone could please help me.

Many thanks in advance!

Best,

Tim


RE: Only show every nth tick in chart - j.crater - Feb-01-2021

Hello, Programmer named Tim!

I do not use Pandas, but as xticks is a series of numbers, could you try Python's range()?
E.g.:
df.plot(xticks=range(0, 1200, 300))