[ncl-talk] legend with gsn_add_polymaker

Guido Cioni guidocioni at gmail.com
Thu Feb 25 10:04:30 MST 2016


Hey Laura,
maybe I have a clue.

The problem is that you can not use the same legend for two different objects, or at least not in a simple manner. You are trying to plot dots with polymarkers while you should try to put all the data in the same array (data) and then plot everything with gsn_csm_xy. If you want to use markers instead of lines for only 1 variable you can use the resource (note the final s!):

 res at xyMarkLineModes   = (/“Lines”,"Lines”,"Lines","Markers"/) 

Then, without any other change,the legend should know whether to put lines or markers..Remember that you have to specify all the marker and line resources as array. 
The only problem may arise if the dataset that you are using to plot either lines or markers have different dimensions but you can still fill the missing part with Fill Values. I think this would be the best approach ;) 


Guido Cioni
http://guidocioni.altervista.org <http://guidocioni.altervista.org/> 

> On 25 Feb 2016, at 17:49, Laura Fowler <laura at ucar.edu> wrote:
> 
> Hi:
> Can somebody help me figure out how to add markers in a legend along
> with the legends with the 3 solid lines. I am attaching the plot so
> that you can understand what I am trying to do.
> 
> Here is how I create the legend for each plot:
> 
> res at pmLegendDisplayMode    = "Always"
> res at pmLegendSide           = "Top"
> res at pmLegendParallelPosF   =  0.15
> res at pmLegendOrthogonalPosF = -0.32
> res at pmLegendWidthF         = 0.15
> res at pmLegendHeightF        = 0.09
> res at lgPerimOn              = False
> res at lgLabelFontHeightF     = .015
> res at lgItemOrder            = (/2,1,0/)
> res at xyExplicitLegendLabels = (/" GF70"," GFNS"," NOGF"/)
> 
> Here is the way I added the markers to the bottom plot:
> 
> plot(2) = gsn_csm_xy(wks,ispan(1,24,1),data,res)
> 
> pmres2 = True
> pmres2 at gsMarkerIndex = 16
> pmres2 at gsMarkerSizeF = 0.008
> 
> obs = new((/9/),typeof(trmm))
> obs(8)   = trmm(0)
> obs(0:7) = trmm(0:7)
> 
> obs_x = (/0,3,6,9,12,15,18,21,24/)
> dum = gsn_add_polymarker(wks,plot(2),obs_x,obs,pmres2)
> 
> resP = True
> resP at gsnPaperWidth  =  8.5
> resP at gsnPaperHeight = 11.0
> resP at gsnPanelBottom = 0.05
> resP at gsnMaximize    = True
> gsn_panel(wks,plot,(/3,1/),resP)
> 
> For the bottom plot, I would like to have something that add a legend
> to the black dots below the legend for NOGF. Is it possible? The
> sourcecode can also be found on yellowstone (
> /glade/p/work/laura/GFconvection.revised/plots/plots.diurnalcycle.ncl).
> 
> Thanks,
> Laura
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> !-------------------------------------------------------------------------------------------------------------
> Laura D. Fowler
> Mesoscale and Microscale Meteorology Division (MMM)
> National Center for Atmospheric Research
> P.O. Box 3000, Boulder CO 80307-3000
> 
> e-mail: laura at ucar.edu
> phone: 303-497-1628
> 
> !-------------------------------------------------------------------------------------------------------------
> <FIGURE_10.revised.pdf>_______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160225/6cbad4b9/attachment.html 


More information about the ncl-talk mailing list