tickinterval erratic behavior in axes with time data

54 views
Skip to first unread message

steppenwolf

unread,
May 17, 2021, 3:57:02 PM5/17/21
to idl-pvwave

It's not clear to me how the tickinterval keyword works on axes with time data. In the two axes plots attached, I have set
    date_label = label_date(date_format=['%N-%D-%Y'])

In the first axis (1.png), I set xtickinterval = 10, intending for the major ticks to be ten days apart. No success.

1.png


In the second axis (2.png), I set xtickinterval = 5, intending the major ticks to be five days apart. This seems to work.

2.png


Any help with what's going on would be appreciated.

steppenwolf

unread,
May 17, 2021, 4:05:17 PM5/17/21
to idl-pvwave
To clarify, if I don't specify xtickinterval in the first case, then I get the following axis -


3.png

Ben C

unread,
May 18, 2021, 6:49:33 PM5/18/21
to idl-pvwave
Are you including the XTICKUNITS keyword? Set that to "Days". Otherwise IDL will try to choose what it thinks is the most appropriate time unit for your specified interval, which may or may not be correct.

;IDL EXAMPLE CODE: 

x =  TIMEGEN(100, UNITS = 'Days', START = JULDAY(1, 1, 2021, 0, 0, 1))
y = sin(x)
date_label = label_date(date_format=['%N-%D-%Y'])
p = plot(x,y,xtickinterval=20,xtickformat='LABEL_DATE',xtickunits='Days')

steppenwolf

unread,
May 18, 2021, 8:25:18 PM5/18/21
to idl-pvwave
I had been setting XTICKUNITS='TIME'. Changing to 'DAYS' definitely seems to make XTICKINTERVAL work as desired :)

Another solution seems to be to set up an automated definition of tick values to pass to the XTICKVALUES keyword.

Ben C

unread,
May 19, 2021, 9:12:04 AM5/19/21
to idl-pvwave
I think "Time" is the generic value and ends up with the same behavior as not setting XTICKUNITS at all. Your desired XTICKINTERVAL and XTICKUNITS should always match up, whether it's Year/Months/Day/Hours, otherwise you could get mixed results depending on your XRANGE. 

You can set up the manual tick marks with XTICKVALUES, but IDL should be able to handle all that for you :)

Good luck! 

Reply all
Reply to author
Forward
0 new messages