Y-axis on RHS
Ethan M Greene
emgreene at FS.FED.US
Wed Mar 2 11:40:14 EST 2005
Dear Lynette,
Below is a function I use to draw a secondary y axis for some plots of heat
flux. It is not as generic as I would like, but it should work of you with
a few modifications. The basic idea is that you plot the primary variable
using the normal method (i.e. 'd whatever'). Then turn ylab off, set the
vertical scale to whatever you want, plot the variable for the second y
axis. Since you know the vertical length (height) of the plot and the range
of your variable you can draw the secondary axis. In the code below I am
plotting % from 0 to 150 in increments of 10. The function needs the max
value of your secondary variable and the increment you want on the plot.
Please write if this doesn't make sense.
Good luck,
Ethan
'd first_var' <- display first var
'set ylab off' <- turn off y axis label
'set vrange 0 150' <- reset y scale
rc=yscale(150,10) <- call function with secondary y varilable
maximum and the scale increment
**********************************************
function yscale (ymax,inc)
'q gxinfo'
rec1=sublin(result,3)
rec2=sublin(result,4)
xlo=subwrd(rec1,4)
xhi=subwrd(rec1,6)
ylo=subwrd(rec2,4)
yhi=subwrd(rec2,6)
scale =(yhi-ylo)/ymax
xl = xhi+0.1
yht = yhi-ylo
'set line 1 1 1 c'
i=inc
while(i <= ymax)
'draw line 'xhi' 'ylo+i*scale' 'xl' 'ylo+i*scale
i = i + inc
endwhile
'set string 1 l 1'
'set strsiz 0.1'
i=inc
while(i <= ymax)
'draw string 'xl' 'ylo+i*scale' 'i
i = i + inc
endwhile
'set string 1 c 1 90'
'set strsiz 0.2'
'draw string 'xhi+0.6' 'yht/2+ylo' % Retained' <- you will need
to change the y lable at least :-)
'set string 1 c 1 0'
return
Ethan Greene
(970)498-1273 office
(970)498-1212 fax
Lynette Bettio
<L.Bettio at BOM.GOV
.AU> To
Sent by: GRADSUSR at LIST.CINECA.IT
GRADSUSR at LIST.CIN cc
ECA.IT
Subject
Y-axis on RHS
02/28/2005 04:38
PM
Please respond to
GRADSUSR at LIST.CIN
ECA.IT
Hello,
I was wanting to do an x-y plot with two different y-axis scalings. I would
prefer to have the second y-axis scale on the right hand side (rather than
both scales on the LHS as it currently plots). Does anyone have any
suggestions? Any help would be appreciated. Thanks in advance.
Regards,
lyn bettio
More information about the gradsusr
mailing list