[ncl-talk] legends and different y-axis plots

Cathy Smith cathy.smith at noaa.gov
Mon May 13 08:54:59 MDT 2019


Hi

I wasn't getting the correct legend when plotting 2 timeseries using 
*gsn_csm_xy2* as I just get one title. If I plot using the same y axis 
using *gsn_csm_xy**,* I get both titles. Is it possible to use legend 
when using gsn_csm_xy2 or so I need to creat the legend more explicitly? 
Sample code is below that replicates issue.

Cathy


; NCL test code

; set ixy2 to 0 to get other plot

ixy2=1

key_title1="AAAAA"
key_title2="BBBBB"
wks = gsn_open_wks("png","outfile")          ; open a ncgm file
res2                      = True
res                        = True
res at xyExplicitLegendLabels = (/key_title1,key_title2/)         ; 
explicit labels
ndata      = new((/2,100/),float)

xinteger = ispan (1,100,1)
y1 = fspan(100,199,100)
y2 = fspan(150,249,100)
ndata(0,:)=y1
ndata(1,:)=y2
res at pmLegendDisplayMode    = "Always"            ; turn on legend
res at pmLegendHeightF            = 0.04                ; height of legend.

if(ixy2.eq.1)then
   plot = gsn_csm_xy2(wks,xinteger,y1,y2,res,res2)
else
   plot = gsn_csm_xy(wks,xinteger,ndata(:,:),res)
end if

-- 
----------------------------------------------
NOAA/ESRL PSD and CU CIRES
303-497-6263
https://www.esrl.noaa.gov/psd/people/cathy.smith/

Emails about data/webpages may get quicker responses from emailing
esrl.psd.data at noaa.gov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190513/9292e708/attachment.html>


More information about the ncl-talk mailing list