Re: Looking for more elegant plot scaling... [message #76652 is a reply to message #76651] |
Sat, 18 June 2011 18:57   |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
Hi,
On 6/18/11 1:16 AM, Balt wrote:
> Hi all,
>
> I'm OPLOTting 3 curves on a fourth one. Is there a more elegant way to
> scale a plot to YRANGE=[maxy,miny] than this:
>
> ; get the y max for the plots
> maxy = MAX(temp_obsdata)
> IF MAX(splined_wvrdata) GT maxy THEN maxy = MAX(splined_wvrdata)
> IF MAX(residuals) GT maxy THEN maxy = MAX(residuals)
> IF MAX(interp_obsdata) GT maxy THEN maxy = MAX(interp_obsdata)
>
> miny = MIN(temp_obsdata)
> IF MIN(splined_wvrdata) LT miny THEN miny = MIN(splined_wvrdata)
> IF MIN(residuals) LT miny THEN miny = MIN(residuals)
> IF MIN(interp_obsdata) LT miny THEN miny = MIN(interp_obsdata)
>
> Maybe something a bit more C macro-ish... ?
I don't know about C stuff, but IDL's compare-and-assign operators could
be handy here...
IDL> a = randomn(s,10)
IDL> b = randomn(s,10)
IDL> c = randomn(s,10)
IDL> print, a,b,c
0.774450 0.0338028 -2.49289 -0.430953 2.15833
0.868524 -0.145793 1.13590 0.726517 1.28041
-1.14027 -0.520221 -0.283700 -0.849713 0.00405929
-0.525046 -0.335924 -0.548919 1.01423 0.0764202
2.04586 0.00412738 1.72472 0.707579 0.997633
1.72583 0.913348 0.699497 1.20014 0.907764
IDL> maxy = max(a) > max(b) > max(c)
IDL> print, maxy
2.15833
IDL> maxy = max(a, min = mina) > max(b, min = minb) > max(c, min=minc)
IDL> print, mina,minb,minc
-2.49289 -1.14027 0.00412738
IDL> miny = mina < minb < minc
IDL> print, miny
-2.49289
You could also simply concatenate all of the arrays together, but that
seems like a lot of overhead.
Cheers,
Ben
|
|
|