Function graphics axis range - how to get it consistently? [message #87864] |
Fri, 28 February 2014 08:37  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Hello,
I'm plotting a simple time series (of program execution times) and, at
certain times, I want to indicate an occurrance (e.g. rebuild,
optimisation, etc).
I want to indicate this occurrance with a vertical dashed line that
spans the entire yrange of the completed plot.
Here is how I plot the actual data:
FOR i = 0L, n_times-1L DO BEGIN
tp[i] = PLOT( date_time, timing[*,i], $
TITLE='Host : ' + host + '!C' + $
'CRTM root : ' + crtm_root + '!C' + $
'Sensor Id : ' + sensor_id + '!C' + $
'CRTM version : ' + crtm_version + '!C' + $
'Current Date : ' + SYSTIME(), $
XTITLE='Date', $
YTITLE='Run time (sec.)', $
XTICKFORMAT='LABEL_DATE', $
MARGIN=[0.1,0.1,0.25,0.15], $
DIMENSIONS=[xsize,ysize], $
COLOR=color[i], $
THICK=2, $
FONT_SIZE=9, $
SYMBOL='diamond', $
OVERPLOT=i, $
NAME=legend_strings[i], $
BUFFER=buffer )
ENDFOR
l = LEGEND( TARGET=tp, $
ORIENTATION=0, $
FONT_SIZE=7, $
HORIZONTAL_ALIGNMENT='CENTER', $
VERTICAL_ALIGNMENT='CENTER', $
POSITION=[0.91,0.5] )
No worries. Works great. I then do the following to plot the vertical
line and an associated text string if there is a comment associated with
any of the dates/times:
idx = WHERE(STRLEN(comment) GT 0, n_comments)
print, tp[0].YRANGE
IF ( n_comments GT 0 ) THEN BEGIN
FOR i = 0, n_comments-1 DO BEGIN
c = PLOT( [date_time[idx[i]],date_time[idx[i]]], tp[0].YRANGE, $
XTICKFORMAT='LABEL_DATE', $
LINESTYLE='dashed', $
/OVERPLOT, $
BUFFER=buffer )
t = TEXT( date_time[idx[i]], (tp[0].YRANGE)[1], $
comment[idx[i]], $
FONT_SIZE=7, $
/DATA, $
TARGET=tp[0], $
ALIGNMENT=0.5, $
VERTICAL_ALIGNMENT=1.0 )
ENDFOR
ENDIF
Note that in the PLOT() command I'm using tp[0].YRANGE to specify the,
well, yrange of the vertical line, and in the TEXT() command I'm using
(tp[0].YRANGE)[1] to position the text at the top of the line.
When I run the above code I get the following output from the
"print, tp[0].YRANGE" command:
0.0000000 350.00000
(also note that tp[0].AXIS_RANGE is [0,0])
BUT, my plot looks like this:
ftp://ftp.emc.ncep.noaa.gov/jcsda/CRTM/timing/emc-lw-pvandel .trunk.amsua_metop-a.v2_2_0-alpha.timing.png
As you can see (I hope) the ACTUAL y-axis range is [0,400], not [0,350].
Additionally, while the vertical line plot only goes up to 350 the
TEXT() output, which should also be positioned at 350 since it uses the
same yrange data, is actually positioned at 400 - the "true" maximum
yrange value.
WTF?
So I have two questions:
1) How does one get the ACTUAL yrange values used in a plot?
2) Why does the TEXT() function position the text differently than the
PLOT() function plots when the same YRANGE property is being used?
Am I doing something wrong here or, as I'm beginning to suspect, is the
random number generator at the heart of Function Graphics funnin' with me?
cheers,
paulv
|
|
|
|
|
|
Re: Function graphics axis range - how to get it consistently? [message #87868 is a reply to message #87867] |
Fri, 28 February 2014 10:18   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Paul van Delst writes:
> To paraphrase Inigo Montoya, regarding the property YRANGE:
> "You keep using that word. I do not think it means what you think it means."
It has been one of those days. (Well, honestly, it has been one of those
weeks.) I finally got a chance to take a shower a few minutes ago and I
was thinking as the hot water splashed over me, that as long as I was
asking philosophical questions that remain unanswered, here is another.
When you say:
"For the record, I use FG pretty much exclusively.
I think they're great."
Do you mean great from an "idea" perspective? Or do you mean great from
a "practical" perspective? Because I find them to be a long, long way
from "great". Sometimes I don't understand what reality I live in. Blame
the ganja wafting over me from all quarters now, I guess. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Function graphics axis range - how to get it consistently? [message #87870 is a reply to message #87868] |
Fri, 28 February 2014 10:34   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Oh my God, check this out:
I added print statements before and after the various plot/text calls
like so:
print, tp[0].YRANGE
c = PLOT( [date_time[idx[i]],date_time[idx[i]]], tp[0].YRANGE, $
XTICKFORMAT='LABEL_DATE', $
LINESTYLE='dashed', $
/OVERPLOT, $
BUFFER=buffer )
print, tp[0].YRANGE
t = TEXT( date_time[idx[i]], (tp[0].YRANGE)[1], $
comment[idx[i]], $
FONT_SIZE=7, $
/DATA, $
TARGET=tp[0], $
ALIGNMENT=0.5, $
VERTICAL_ALIGNMENT=1.0 )
print, tp[0].YRANGE
This is the output:
0.0000000 350.00000
0.0000000 400.00000
0.0000000 400.00000
So the PLOT() command uses the "busted" YRANGE property value, but doing
so "fixes" it.
WTF?
I give up.
On 02/28/14 13:18, David Fanning wrote:
> Paul van Delst writes:
>
>> To paraphrase Inigo Montoya, regarding the property YRANGE:
>> "You keep using that word. I do not think it means what you think it means."
>
> It has been one of those days. (Well, honestly, it has been one of those
> weeks.) I finally got a chance to take a shower a few minutes ago and I
> was thinking as the hot water splashed over me, that as long as I was
> asking philosophical questions that remain unanswered, here is another.
> When you say:
>
> "For the record, I use FG pretty much exclusively.
> I think they're great."
>
> Do you mean great from an "idea" perspective? Or do you mean great from
> a "practical" perspective? Because I find them to be a long, long way
> from "great". Sometimes I don't understand what reality I live in. Blame
> the ganja wafting over me from all quarters now, I guess. :-)
Albert Einstein — 'In theory, theory and practice are the same. In
practice, they are not.'
Grr argghh!
|
|
|
Re: Function graphics axis range - how to get it consistently? [message #87872 is a reply to message #87870] |
Fri, 28 February 2014 11:00  |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Friday, February 28, 2014 11:34:05 AM UTC-7, Paul van Delst wrote:
> Oh my God, check this out:
>
>
>
> I added print statements before and after the various plot/text calls
>
> like so:
>
>
>
> print, tp[0].YRANGE
>
> c = PLOT( [date_time[idx[i]],date_time[idx[i]]], tp[0].YRANGE, $
>
> XTICKFORMAT='LABEL_DATE', $
>
> LINESTYLE='dashed', $
>
> /OVERPLOT, $
>
> BUFFER=buffer )
>
> print, tp[0].YRANGE
>
> t = TEXT( date_time[idx[i]], (tp[0].YRANGE)[1], $
>
> comment[idx[i]], $
>
> FONT_SIZE=7, $
>
> /DATA, $
>
> TARGET=tp[0], $
>
> ALIGNMENT=0.5, $
>
> VERTICAL_ALIGNMENT=1.0 )
>
> print, tp[0].YRANGE
>
>
>
>
>
> This is the output:
>
>
>
> 0.0000000 350.00000
>
> 0.0000000 400.00000
>
> 0.0000000 400.00000
>
>
>
> So the PLOT() command uses the "busted" YRANGE property value, but doing
>
> so "fixes" it.
>
>
>
> WTF?
>
>
>
> I give up.
>
>
>
> On 02/28/14 13:18, David Fanning wrote:
>
>> Paul van Delst writes:
>
>>
>
>>> To paraphrase Inigo Montoya, regarding the property YRANGE:
>
>>> "You keep using that word. I do not think it means what you think it means."
>
>>
>
>> It has been one of those days. (Well, honestly, it has been one of those
>
>> weeks.) I finally got a chance to take a shower a few minutes ago and I
>
>> was thinking as the hot water splashed over me, that as long as I was
>
>> asking philosophical questions that remain unanswered, here is another.
>
>> When you say:
>
>>
>
>> "For the record, I use FG pretty much exclusively.
>
>> I think they're great."
>
>>
>
>> Do you mean great from an "idea" perspective? Or do you mean great from
>
>> a "practical" perspective? Because I find them to be a long, long way
>
>> from "great". Sometimes I don't understand what reality I live in. Blame
>
>> the ganja wafting over me from all quarters now, I guess. :-)
>
>
>
> Albert Einstein -- 'In theory, theory and practice are the same. In
>
> practice, they are not.'
>
>
>
> Grr argghh!
Hi Paul,
I don't think you need to use a PLOT to do your dashed line. When you do an overplot, it's going to try to update the range to fit your new plot line. Instead, you could just use a polyline:
IDL> p = plot(/test, xrange=[0,250], yrange=[-1,2])
IDL> p1 = polyline([200,200],p.yrange, /data, linestyle='dashed')
Hope this helps.
Cheers,
Chris
|
|
|