Plotting time [message #46515] |
Fri, 25 November 2005 08:37  |
clivecook59
Messages: 26 Registered: November 2005
|
Junior Member |
|
|
I'm trying to plot in IDL with time on the x-axis. Now i can do this in
direct graphics mode by converting my x values into julian time and
then using the tickunits='time' and tick_format='LABEL_DATE' comands.
However i am trying to do this in an object plot and i just cannot get
it to work. Whats the best way to plot time correctly in object
graphics?
many thanks
Clive Cook
|
|
|
Re: Plotting time [message #46548 is a reply to message #46515] |
Tue, 29 November 2005 16:57   |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
David Fanning wrote:
> Hang on a minute and I'll make it easy for you. :-)
David sent me some code in which a date axis as described by the OP was
grafted into his XPLOT plotting window application thingy. The axis
appeared in the wrong place, off the left-hand edge of the plot window,
as reported. I traced the problem. XPLOT gets the axes in the right
place by adjusting the scaling, something like this
xAxis->GetProperty, CRange=xrange
xs = Normalize(xrange, Position=[xn0,xn1])
xAxis->SetProperty, XCoord_Conv=xs
where xn0 & xn1 are the desired end points of the axis in normalised
coordinates.
NORMALIZE was doing its calculations in single-precision floating point
and returning a single-precision result. Once I changed everything to
double-precision, the axis appears in the right place.
>> Incidentally, LABEL_DATE is evil; the C() formats are much better, and
>> not *that* hard to construct.
>
> It is screwy with or without LABEL_DATE.
Sure. That was just me riding one of my hobby horses.
--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|
|
|
Re: Plotting time [message #46553 is a reply to message #46515] |
Tue, 29 November 2005 14:18   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield writes:
> Yes, but the problem is not with the axis object, which keeps its data
> in double precision, but with the view object. Set the view object's
> DOUBLE property and these problems should disappear.
Well, that changed things. The axis moved further to the LEFT,
and I wanted it over here on the RIGHT. Sigh...
I checked all the inputs, etc. everything appears to be in
double precision.
It is a mystery.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
|
|
Re: Plotting time [message #46560 is a reply to message #46515] |
Tue, 29 November 2005 10:37   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
clivecook59@gmail.com writes:
> Here's the code for the x-axis,
>
> dummy = LABEL_DATE(DATE_FORMAT=['%H:%I'])
> xrange1 = [julday(10,1,2005,5,0,0),julday(10,1,2005,10,0,0)]
>
> xAxis1a = Obj_New("IDLgrAxis",0,Color=[0,0,0],Ticklen=0.025,$
> Range=xrange1,title=xtitle1,Location=[position2(0),position2 (1)],$
> /Exact,tickunits='time',TICKFORMAT ='LABEL_DATE')
>
> xAxis1a->GetProperty, Ticktext=xAxisText
> xAxisText->SetProperty, Font=helvetica10pt
>
> I would assue that this should give me an axis from 5:00 to 10:00
> however i get nothing
Humm. Well, I get *something*, but it is clearly not right.
In my example, using your axis range, tickunits, and tickformat,
I can see just a portion of the axis. The rest is off to the
left of my view somewhere. So, it appears that it cannot be
positioned and scaled like other axes. I would guess bug
at this point. Maybe we could get someone at RSI to respond.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Plotting time [message #46561 is a reply to message #46515] |
Tue, 29 November 2005 10:08   |
clivecook59
Messages: 26 Registered: November 2005
|
Junior Member |
|
|
Here's the code for the x-axis,
dummy = LABEL_DATE(DATE_FORMAT=['%H:%I'])
xrange1 = [julday(10,1,2005,5,0,0),julday(10,1,2005,10,0,0)]
xAxis1a = Obj_New("IDLgrAxis",0,Color=[0,0,0],Ticklen=0.025,$
Range=xrange1,title=xtitle1,Location=[position2(0),position2 (1)],$
/Exact,tickunits='time',TICKFORMAT ='LABEL_DATE')
xAxis1a->GetProperty, Ticktext=xAxisText
xAxisText->SetProperty, Font=helvetica10pt
I would assue that this should give me an axis from 5:00 to 10:00
however i get nothing
many thanks
Clive
|
|
|
|
|
Re: Plotting time [message #46646 is a reply to message #46548] |
Tue, 29 November 2005 17:31  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark Hadfield writes:
> David sent me some code in which a date axis as described by the OP was
> grafted into his XPLOT plotting window application thingy. The axis
> appeared in the wrong place, off the left-hand edge of the plot window,
> as reported. I traced the problem. XPLOT gets the axes in the right
> place by adjusting the scaling, something like this
>
> xAxis->GetProperty, CRange=xrange
> xs = Normalize(xrange, Position=[xn0,xn1])
> xAxis->SetProperty, XCoord_Conv=xs
>
> where xn0 & xn1 are the desired end points of the axis in normalised
> coordinates.
>
> NORMALIZE was doing its calculations in single-precision floating point
> and returning a single-precision result. Once I changed everything to
> double-precision, the axis appears in the right place.
Ah, *my* NORMALIZE does it's calculations in double precision. But I
just noticed that my XPLOT has an *old* copy that does it in single
precision. Just another reminder to all you aspiring IDL programmers
out there that you should really, REALLY check your assumptions. :-)
Thanks, Mark.
Cheers,
David
P.S. The *new* version of XPLOT will not include NORMALIZE. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|