# Changing number of x ticks in plot

**URL:** https://discourse.obspy.org/t/changing-number-of-x-ticks-in-plot/1144
**Category:** Usage Questions
**Created:** [November 27, 2020, 4:44pm UTC](https://discourse.obspy.org/t/changing-number-of-x-ticks-in-plot/1144 "2020-11-27T16:44:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![amygilligan](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@amygilligan](https://discourse.obspy.org/u/amygilligan)
#### Post date: [November 27, 2020, 4:44pm UTC](https://discourse.obspy.org/t/changing-number-of-x-ticks-in-plot/1144/1 "2020-11-27T16:44:37Z")

</div>

Hello

I’m trying to plot some seismograms and would like to be able to change the number of ticks (labels) on the x axis. When I try to change this using the ‘number\_of\_ticks’ argument it doesn’t result in any change to the output figure

For example:

st[0].plot(starttime=UTCphase-50, endtime=UTCphase2+100, linewidth=0.5, tick\_rotation=0, number\_of\_ticks=3)

and

st[0].plot(starttime=UTCphase-50, endtime=UTCphase2+100, linewidth=0.5, tick\_rotation=0, number\_of\_ticks=10)

Both result in figures that look the same (sorry it doesn’t seem to want to attach) with 5 ticks on the x axis.

I’ve had a look in obspy.imaging.waveforms and it I note that it does say Unused variable for the function:

\_\_plot\_set\_x\_ticks(self, \*args, \*\*kwargs): # @UnusedVariable

Is there another way to change the number of ticks on the x axis or should I try matplotlib/gmt in this instance?

Thanks!

Amy

---

<div class="post-metadata">

### Author: ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)
#### Post date: [December 1, 2020, 9:42am UTC](https://discourse.obspy.org/t/changing-number-of-x-ticks-in-plot/1144/2 "2020-12-01T09:42:44Z")

</div>

I had a look in the code and that parameter is actually exclusively used in the `dayplot` option of plotting, but it is described in the general parameters section. So docs and code do not line up well.

For mid term I will move it in the docs. For the long term somebody could implement that parameter in the general waveform wiggle plot as well.

For the short term if you need to change ticks, you might have to do it yourself. Either set up the plot in matplotlib from scratch, or you could use `show=False` and `handle=True` and do final touches to your figure before showing it (see [matplotlib.ticker — Matplotlib 3.3.2 documentation](https://matplotlib.org/3.3.2/api/ticker_api.html)).
