Re: xy plot secondary axis

Date: Wed, 30 May 2007 12:58:32 -0400

Thanks for the very helpful examples.

>
> Dennis was looking at this late last week and he he tossed it to me
> today.
>
> Take a look at tick mark example #6:
> http://www.ncl.ucar.edu/Applications/tickmarks.shtml#ex6
>
> It shows you how to label the right Y-axis differently than the left
> Y-axis. Specifically, you need to set tmYUseLeft = False to tell NCL
> to not use the left Y-axis labels ont he right.
>
> I (+Dennis) have come up with an example on how to 1) allow NCL to
> automatically draw Celsius labels on the right Y-axis at the same
> point as the Y-left labels were drawn in Fahrenheit. This will likely
> produce Celsius labels that aren't nice looking, but it will be done
> automatically. 2) Manually set up Celsius labels yourself, drawing
> nice round Celsius labels independent of where the left hand Y=axis
> major tick mark labels are. I would go with this method. I'm pretty
> sure I can come up with a way to do this automatically, but I think
> it's likely you will be happy with the manual method.
>
> Both examples are drawn with the code below.
> Good luck,
> ;================================================================
>
> begin
> ntim = 9
> time = ispan(1,9,1)
> T = (/0.,0.71,1.,0.7,0.002,-0.71,-1.,-0.71,-0.003/)*50
>
> time_at_long_name = "time"
> T_at_long_name = "Temperature"
> T_at_units = "F"
>
> wks = gsn_open_wks("ps","test") ; Open an X11 workstation.
>
> res = True
> res_at_gsnDraw = False
> res_at_gsnFrame = False
> res_at_trYMinF = -60 ; in degrees F
> res_at_trYMaxF = 40. ; in degrees F
> plot = gsn_csm_xy(wks,time,T,res) ; Draw an XY plot
>
> getvalues plot
> "tmYLValues" : tmYLValues ; values used by NCL at major
> tick marks
> "tmYRLabels" : tmYRLabels ; These are fahrenheit
> end getvalues
> degC = 0.55555555*(tmYLValues -32) ; convert F to C
>
> degC2 = round(degC*(10^2),0)/10^2
>
> setvalues plot
> "tmYUseLeft" : False
> "tmYRLabelsOn" : True
> "tmYRMode" : "Explicit"
> "tmYRValues" : tmYLValues
> "tmYRLabels" : degC2
> end setvalues
> draw(plot)
> frame(wks)
> ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> res_at_gsnDraw = True ; draw plot 2 with nice Celsius labels
> res_at_gsnFrame = True
> res_at_tmYUseLeft = False
> res_at_tmYROn = True
> res_at_tmYRLabelsOn = True
> yleftlabels = ispan(-50,0,10)
> degF = (yleftlabels/0.555555)+32.
> res_at_tmYRMode = "Explicit"
> res_at_tmYRValues = degF
> res_at_tmYRLabels = yleftlabels
>
> plot2 = gsn_csm_xy(wks,time,T,res) ; Draw an XY plot
> end
>
>
>
>
>
>
>
>
>
> ;========================================================================
>
> begin
> ntim = 9
> time = ispan(1,9,1)
> T = (/0.,0.71,1.,0.7,0.002,-0.71,-1.,-0.71,-0.003/)*50
>
> time_at_long_name = "time"
> T_at_long_name = "Temperature"
> T_at_units = "F"
>
> wks = gsn_open_wks("ps","test") ; Open an X11 workstation.
>
> res = True
> res_at_gsnFrame = False
> plot = gsn_csm_xy(wks,time,T,res) ; Draw an XY plot
>
> getvalues plot
> "tmYLValues" : tmYLValues ; values used by NCL at major
> tick marks
> "tmYRLabels" : tmYRLabels ; These are fahrenheit
> "vpXF" : xstart
> "vpYF" : ystart
> "vpHeightF" : pheight
> "vpWidthF" : pwidth
> end getvalues
> degC = 0.555*(tmYLValues -32) ; convert F to C
>
> plot2 = create "plot" logLinPlotClass wks
> "tmYLOn" : False
> "tmXBOn" : False
> "tmXTOn" : False
> "tmYROn" : True
> "trYMaxF" : max(degC)
> "trYMinF" : min(degC)
> "pmTickMarkDisplayMode" : "Always"
> "tmYLBorderOn" : False
> "tmXTBorderOn" : False
> "tmXBBorderOn" : False
> "tmYRBorderOn" : True
> "vpXF" : xstart+0.08
> "vpWidthF" : pwidth
> "vpYF" : ystart
> "vpHeightF" : pheight
> "tmYLMode" : "Explicit"
> "tmYRLabelsOn" : True
> "tmYLValues" : degC
> "tmYLLabels" : degC
> "tmYRMajorLengthF" : 0.021
> "tmYRMajorOutwardLengthF" : 0.021
> end create
> draw(plot2)
> frame(wks)
> end
>
>> I am currently plotting temperature vs time using gsn_csm_xy in
>> degrees F. I have been asked to make the secondary axis in degrees C
>> but I have not been able to find any examples on how this is done.
>> Can someone point me in the direction on how to accomplish this.
>>