comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » line graph problems
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
line graph problems [message #24286] Sun, 25 March 2001 13:27 Go to next message
Brian is currently offline  Brian
Messages: 27
Registered: March 2001
Junior Member
Hello,

I have a couple of problems I was hoping that someone might be able to
help me with...

First of all I am trying to automate the process of creating a series
of line graphs for a project (approximately 50). I could do this in
Excel, but it is very time consuming. I was hoping to use IDL to make
the process easier, but it seems to be causing me just as many
headaches.

There will be two plots per page and they have identical y-axis and
variable x-axis ranges. The x-axis values are fairly large, which
leads me to my first problem. Is it possible to change the text
orientation for an axis using PLOT? I've searched the IDL help and
David's book and can't seem to find any reference to this. I'd like
to have the text display at a 45 degree angel so the values don't
overlap when displayed. My second problem relates to the y-axis. In
several of my plots I have a few y values that are large while the
rest are many times smaller. Is it possible to create a broken y-axis
so I can bring out the smaller values while still displaying the
larger ones?

Any help that can be provided will be greatly appreciated!

Brian
please remove the _ns if replying directly by email...
Re: line graph problems [message #24359 is a reply to message #24286] Mon, 26 March 2001 12:09 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Martin Schultz wrote:
>
> Paul van Delst wrote:
>>
>> Paul van Delst wrote:
>>>
>>> maxval = ABS( MIN( xdata ) ) > MAX( xdata )
>> ^
>> oops. Missing ")" above in previous post
>>
>
> This line (the ">" to be exact) gave me another idea:
>
> Since you can/should explicitely specify your axis labels with the
> beforementioned ESRG routine anyway,

I disagree about that. Mostly because I'm lazy (I *really* dislike having to use
tremendously verbose code - full of stuff like determining the width of characters and
then lining stuff up by applying fractions of said width etc. - simply to label plot axes
and/or tick marks)

> you could do something like:
>
> labels = [ string(findgen(6),format='(f6.1)'),
> string(max(data),format='(f20.1)') ]
> labels = StrTrim(labels,2)
> axgap,..., ; use the labels here
> oplot, x, data < 8. ; where the value of 8. is just a guess and
> would have to be determined.
>
> This wouldn't do exactly what you want, but it would "line up" all
> points above the threshold in the upper plot area. So, better, would
> be to scale only the data above the gap. E.g.:
>
> tmpdata = data
> wbig = Where(data gt 6., cnt) ; assume your threshold is 6
> IF cnt GT 0 THEN tmpdata[wbig] = (tmpdata[wbig]/10.)+6.
>
> ... or something similar. Hope you get the idea.

Yeah, but recently I have come to the conclusion that IDL is not mature enough to allow me
absolute control in a simple, intuitive way of plot properties (note that the qualifier
"simple" eliminates OG :o) as opposed to some other proprietary plotting package (like,
for e.g., Grapher or Surfer).

However, IDL has always allowed me dictatorial control over my data (totally unlike, for
e.g., Grapher or Surfer) and this is, after all, one of the two reasons I use IDL - data
"malleability" :o) the other being visualisation. This leads to my (personal) path of
least resistance of data scaling. All the axis/tick mark/interval/label stuff I leave to
IDL cause I don't care about that stuff (i.e. it shouldn't take more than about a minute
or two to get my plot looking the way I want it.)

Thanks for the tips though. As always, they're useful and illuminating.

paulv

--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
paul.vandelst@noaa.gov Alexander Pope.
Re: line graph problems [message #24366 is a reply to message #24286] Mon, 26 March 2001 10:23 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Paul van Delst wrote:
>
> Paul van Delst wrote:
>>
>> maxval = ABS( MIN( xdata ) ) > MAX( xdata )
> ^
> oops. Missing ")" above in previous post
>

This line (the ">" to be exact) gave me another idea:

Since you can/should explicitely specify your axis labels with the
beforementioned ESRG routine anyway, you could do something like:

labels = [ string(findgen(6),format='(f6.1)'),
string(max(data),format='(f20.1)') ]
labels = StrTrim(labels,2)
axgap,..., ; use the labels here
oplot, x, data < 8. ; where the value of 8. is just a guess and
would have to be determined.

This wouldn't do exactly what you want, but it would "line up" all
points above the threshold in the upper plot area. So, better, would
be to scale only the data above the gap. E.g.:

tmpdata = data
wbig = Where(data gt 6., cnt) ; assume your threshold is 6
IF cnt GT 0 THEN tmpdata[wbig] = (tmpdata[wbig]/10.)+6.

... or something similar. Hope you get the idea.

Cheers,
Martin


--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
Re: line graph problems [message #24369 is a reply to message #24286] Mon, 26 March 2001 08:25 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Paul van Delst wrote:
>
> maxval = ABS( MIN( xdata ) ) > MAX( xdata )
^
oops. Missing ")" above in previous post


--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
paul.vandelst@noaa.gov Alexander Pope.
Re: line graph problems [message #24370 is a reply to message #24286] Mon, 26 March 2001 08:22 Go to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Brian wrote:
>
> Hello,
>
> I have a couple of problems I was hoping that someone might be able to
> help me with...
>
> First of all I am trying to automate the process of creating a series
> of line graphs for a project (approximately 50). I could do this in
> Excel, but it is very time consuming. I was hoping to use IDL to make
> the process easier, but it seems to be causing me just as many
> headaches.
>
> There will be two plots per page and they have identical y-axis and
> variable x-axis ranges. The x-axis values are fairly large, which
> leads me to my first problem. Is it possible to change the text
> orientation for an axis using PLOT? I've searched the IDL help and
> David's book and can't seem to find any reference to this. I'd like
> to have the text display at a 45 degree angel so the values don't
> overlap when displayed.

My solution to exactly this problem (but for 7x4 plots per page) is avoid like the plague
anything that requires shifting plot/tick titles. IDL makes this an unbelievable difficult
process - particularly if you're going to automate it so it has to work in a fairly robust
manner (as opposed to a one off mucking about about with POSITION and XYOUTS and god-knows
what). I prefer to scale the data as follows:

max_exponent = 0
scale_check = ( ( MACHAR( /DOUBLE ) ).EPS )^2

maxval = ABS( MIN( xdata ) > MAX( xdata )

multiplier = 1.0d
xtitle = 'X Data'
IF ( maxval GT scale_check ) THEN BEGIN
exponent = FLOOR( ALOG10( maxval ) )
IF ( ABS(exponent) GT max_exponent ) THEN BEGIN
multiplier = 10.0d^(-exponent)
xtitle = 'X Data (x'+STRING(10.0d^(exponent),FORMAT='(e7.1)')+')'
ENDIF
ENDIF

PLOT, multiplier * xdata, ydata, $
XTITLE = xtitle, $
YTITLE = 'Y Data'

This "dynamically" scales the data and updates the x-axis title with the scale factor.
Depending on what you like, you can change the max_exponent. I prefer anything larger or
equal to 10 to be scaled. It has worked flawlessly for me so far (touch wood) with no
overlapping x-tick labels.


> My second problem relates to the y-axis. In
> several of my plots I have a few y values that are large while the
> rest are many times smaller. Is it possible to create a broken y-axis
> so I can bring out the smaller values while still displaying the
> larger ones?

This is a hairier problem but I would recommend steering away from doing what you suggest
(i.e. what other plotting/graphics packages do with ease - broken y-axis) at least with
IDL. Can you scale the data again in this case? E.g. plot the y-data on a logarithmic axis
(won't work if values < or = 0). If it can be done, then you can use the following as the
X|YTICKFORMAT keyword function name to avoid gobs of unneeded decimal places, e.g.
1000.00000 if the smallest tick label is 0.00001 (which I find _extremely_ annoying):


FUNCTION logticks, axis, index, value

exponent = LONG( ALOG10( value ) )

CASE 1 OF
; -- Exponent is less than zero ->
; -- fractional ticklabel
( exponent LT 0 ): format = '( f' + $
STRTRIM( ABS( exponent ) + 2, 2 ) + $
'.' + $
STRTRIM( ABS( exponent ), 2 ) + $
' )'
; -- Exponent is greater than or = to zero ->
; -- whole number ticklabel
( exponent GE 0 ): format = '( i' + $
STRTRIM( ABS( exponent ) + 1, 2 ) + $
' )'
ENDCASE

RETURN, STRING( value, FORMAT = format )

END


Hope some of this is useful.

paulv


--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
paul.vandelst@noaa.gov Alexander Pope.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Making SAV files
Next Topic: converting to array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:56:13 PDT 2025

Total time taken to generate the page: 0.00695 seconds