Two different vertical scales!

Charles Seman Charles.Seman at NOAA.GOV
Wed Aug 16 12:54:54 EDT 2006


Matias,

Here is some code (untested; it was adapted from a script which has been
run here...) that hopefully you can adapt to find the max/min for the
three time series, and then use "vrange" to set the plot axis... (it
assumes there are 3 different GrADS files for the three precipitation
time series;  if not, the code would have to be changed...)
-------------------------------------------------------------------------------------------------------------------------------------------------------------
...
*
*  Set time series limits
*
ts = '...'
tf = '...'
say
say 'Time series is from "'ts'" to "'tf'"'
say
*
*  Plot page limits
*
_pvar_vpage = '0 11 0 8.5'
_pvar_parea = '1 10 1 7.5'
*
*  Legend captions, colors, and marks for the
*  precipitation time series
*
_legends = 'P1  P2 P3'
_colors  = ' 1    2     3'
_marks   = ' 0    0     0'
...
*
*  initialize...
*
pmin = 1e6 ; pmax = -1e6

'set dfile 1'
...
'define p1 = ...'
*
*  update min/max values for plot...
*
 'set time 'ts' 'tf
 'set gxout stat'
 'd p1'
 min_max_p1 = sublin(result,8)
 min = subwrd(min_max_p1,4)
 max = subwrd(min_max_p1,5)
 if( min < pmin )
   pmin = min
 endif
 if( max > pmax )
   pmax = max
 endif

'set dfile 2'
...
'define p2 = ...'
*
*  update min/max values for plot...
*
 'set time 'ts' 'tf
 'set gxout stat'
 'd p2'
 min_max_p2 = sublin(result,8)
 min = subwrd(min_max_p2,4)
 max = subwrd(min_max_p2,5)
 if( min < pmin )
   pmin = min
 endif
 if( max > pmax )
   pmax = max
 endif

'set dfile 3'
...
'define p3 = ...'
*
*  update min/max values for plot...
*
 'set time 'ts' 'tf
 'set gxout stat'
 'd p3'
 min_max_p3 = sublin(result,8)
 min = subwrd(min_max_p3,4)
 max = subwrd(min_max_p3,5)
 if( min < pmin )
   pmin = min
 endif
 if( max > pmax )
   pmax = max
 endif
...
*
* plot results...
*
diff = pmax - pmin
pmin = pmin - 0.05*diff ; pmax = pmax + 0.05*diff
say
say '------------------------------------------------'
say 'Plotting variable for "P1"'
say '------------------------------------------------'
say
p1file = 1 ; nv = 1
plot(ts,tf,p1file,nv,pmin,pmax,p1)
say
say '------------------------------------------------'
say 'Plotting variable for "P2"'
say '------------------------------------------------'
say
p2file = 2 ; nv = 2
plot(ts,tf,p2file,nv,pmin,pmax,p2)
say
say '------------------------------------------------'
say 'Plotting variable for "P3"'
say '------------------------------------------------'
say
p3file = 3 ; nv = 3
plot(ts,tf,p3file,nv,pmin,pmax,p3)
say
say 'Annotate plot...'
say
'draw title Station: 20027'
'draw xlab Time \\'
'draw ylab \\ Precipitation (mm d`a-1`n)'
cbar_line -x 3 -y 6 -c '_c.1' '_c.2' '_c.3' -l 1 1 1 -m "'_m.1'"
"'_m.2'" "'_m.3'" -t "'_l.1'" "'_l.2'" "'_l.3'" -p'
...
************************************************************************
*
function plot(ts,tf,nf,nv,pmin,pmax,var)
*
* Plots precip variable
*
'set dfile 'nf
'set x 1'
'set y 1'
'set z 1'
'set time 'ts' 'tf
'set vpage '_pvar_vpage
'set parea '_pvar_parea
'set gxout line'
'set grads off'
_c.nv = subwrd(_colors,nv)
_m.nv = subwrd(_marks,nv)
_l.nv = subwrd(_legends,nv)
'set ccolor '_c.nv
'set cmark  '_m.nv
'set vrange 'pmin' 'pmax
'd 'var
*
return
*
************************************************************************

I hope this helps,
Chuck

J. Matias Mendez Perez wrote:
> Hello GrADS users,
>
> I am trying to make a time series plot of precipitation, but when I
> display them, I get two different vertical scales as you can see in the
> attached figure.
> I've already tried using yaxis, but unfortunately labeled ticks don't
> have relation to data. How can I get same scale?.
>
> I hope someone can help me. Thank you very much.
>
> Best wishes,
> Matias
>
>
> ------------------------------------------------------------------------
>

--

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."



More information about the gradsusr mailing list