[Matplotlib-users] how to specify time locator's start-ticking timestamp?

eliu eliu at hydro.mb.ca
Fri May 13 18:06:59 EDT 2016


*All I want is quite straight forward, I just want the locator ticks to start
at a specified timestamp:
peudo code: locator.set_start_ticking_at( datetime_dummy )
I have no luck finding anything so far.*

Here is the portion of the code for this question:

    axes[0].set_xlim(datetime_dummy) # datetime_dummy = '2015-12-25
05:34:00'
    import matplotlib.dates as matdates
    seclocator = matdates.SecondLocator(interval=20) 
    minlocator = matdates.MinuteLocator(interval=1) 
    hourlocator = matdates.HourLocator(interval=12)

    seclocator.MAXTICKS  = 40000
    minlocator.MAXTICKS  = 40000
    hourlocator.MAXTICKS  = 40000

    majorFmt = matdates.DateFormatter('%Y-%m-%d, %H:%M:%S')  
    minorFmt = matdates.DateFormatter('%H:%M:%S')  

    axes[0].xaxis.set_major_locator(minlocator)
    axes[0].xaxis.set_major_formatter(majorFmt)
    plt.setp(axes[0].xaxis.get_majorticklabels(), rotation=90 )

    axes[0].xaxis.set_minor_locator(seclocator)
    axes[0].xaxis.set_minor_formatter(minorFmt)
    plt.setp(axes[0].xaxis.get_minorticklabels(), rotation=90 )

    # other codes
    # save fig as a picture


*The x axis ticks of above code will get me:
*
<http://matplotlib.1069221.n5.nabble.com/file/n47066/2016-05-12_19-08-54.jpg> 

*How do I tell the minor locator to align with the major locator?
How do I tell the locators which timestamp to start ticking at?

what I have tried:
set_xlim doesn't do the trick
seclocator.tick_values(datetime_dummy, datetime_dummy1) doesn't do anything*



--
View this message in context: http://matplotlib.1069221.n5.nabble.com/how-to-specify-time-locator-s-start-ticking-timestamp-tp47066.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


More information about the Matplotlib-users mailing list