Re: the legend order

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 01 2012 - 10:36:39 MST

Hello,
I think you are setting the wrong resource. Instead of setting
lgMarkerColors (which control the marker colors of the legend), try
setting lgLineColors. See example #8 here:
http://www.ncl.ucar.edu/Applications/legend.shtml#ex8
Adam

On 02/29/2012 11:34 PM, Guo Zhang wrote:
> Hi,
> When I set up the legend, I have a strange problem. The lables of
> legend are supposed to match with the colors, ie LE_OBS: red, LE_CTL:
> green,LE_BT: black. But I got a disordered legend. Please see the
> attached file.
> And the script is as below.
> How can I fix the problem? Thanks.
> wks = gsn_open_wks ("pdf","200907_LE") ; open
> workstation
> res = True ; plot mods desired
> ; res@xyMarkLineModes <mailto:res@xyMarkLineModes> = "MarkLines"
> res@xyMarkLineModes <mailto:res@xyMarkLineModes> = "Lines"
> res@xyDashPattern <mailto:res@xyDashPattern> = 0 ; Make
> curves all solid
> ; res@xyMarkers <mailto:res@xyMarkers> = 6
> ; res@xyMarkerSizeF <mailto:res@xyMarkerSizeF> = 0.005
> ; res@xyMarkerColors <mailto:res@xyMarkerColors> =(/"blue"/)
> res@trYMinF <mailto:res@trYMinF> = 0
> res@trYMaxF <mailto:res@trYMaxF> = 300
>
> res@xyLineColors <mailto:res@xyLineColors> = (/"red"/)
> res@tiMainString <mailto:res@tiMainString> = "Monthly Mean Flux
> Daily Variation" ; add title
> res@tiXAxisString <mailto:res@tiXAxisString> = "Time"
> res@tiYAxisString <mailto:res@tiYAxisString> = "Latent Heat
> Flux(W/m~S~2~N~)"
> res@gsnDraw <mailto:res@gsnDraw> = False
> res@gsnFrame <mailto:res@gsnFrame> = False
> plot0 = gsn_csm_xy(wks,t0,LE_OBS,res) ; create plot
> res@xyLineColors <mailto:res@xyLineColors> = (/"green"/)
> plot1 = gsn_csm_xy(wks,t,m,res)
> res@xyLineColors <mailto:res@xyLineColors> = (/"black"/)
> plot2 = gsn_csm_xy(wks,t,n,res)
> overlay(plot0,plot1)
> overlay(plot0,plot2)
>
> lgres = True
> colors = (/"red","green","black"/)
> lgres@lgMarkerColors <mailto:lgres@lgMarkerColors> = colors
> lgres@lgItemType <mailto:lgres@lgItemType> = "lines"
> ; lgres@lgMonoMarkerIndex <mailto:lgres@lgMonoMarkerIndex> = True
> ; lgres@lgMarkerIndex <mailto:lgres@lgMarkerIndex> = 4
> ; lgres@lgMarkerSizeF <mailto:lgres@lgMarkerSizeF> =0.005
> lgres@vpWidthF <mailto:lgres@vpWidthF> = 0.13
> lgres@lgLabelFontHeightF <mailto:lgres@lgLabelFontHeightF> =.08
> lgres@vpHeightF <mailto:lgres@vpHeightF> = 0.10
> lgres@lgPerimOn <mailto:lgres@lgPerimOn> = False
> ; lgres@lgPerimThicknessF <mailto:lgres@lgPerimThicknessF> = 2.
> lgres@lgMonoDashIndex <mailto:lgres@lgMonoDashIndex> = True
> lgres@lgDashIndex <mailto:lgres@lgDashIndex> = 0
> ; labels = (/"LE_BT","LE_OBS","LE_CTL"/)
> labels = (/"LE_OBS","LE_CTL","LE_BT"/)
>
> legend = gsn_create_legend(wks,3,labels,lgres)
> amres = True
> amres@amJust <mailto:amres@amJust> = "ToPLeft"
> amres@amParallelPosF <mailto:amres@amParallelPosF> = -0.5
> amres@amOrthogonalPosF <mailto:amres@amOrthogonalPosF> = -0.5
> ; amres@amPerimOn <mailto:amres@amPerimOn> =
> False ; turn off box around
> annoid = gsn_add_annotation(plot0,legend,amres)
> draw(plot0)
> frame(wks)
> end
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 1 10:36:47 2012

This archive was generated by hypermail 2.1.8 : Mon Mar 05 2012 - 14:12:07 MST