[ncl-talk] trouble making plot legend with a loop

Adam Herrington adam.herrington at stonybrook.edu
Wed Aug 16 14:42:07 MDT 2017


Hi all,

I'm trying to come up with a routine thats produces a plot legend using a
loop. However, my attempts to do so corrupts the text labels. See attached
plot as an example. The code for this loop is:

  plabel = (/"  ne30_old", \
             "  ne30_new", \
             "  ne60_old", \
             "  ne60_new", \
             "  ne120_old",\
             "  ne120_new",\
             "  ne240_old",\
             "  ne240_new"/)

  xx = (/1.,2.5/)
  yy = (/985.,978.,971.,964.,957.,950.,943.,936./)
  do n = 0,nfiles-1
    res_lines at gsLineColor       = colors(n)
    lstr = unique_string("rum")
    tstr = unique_string("hum")
    plot@$lstr$ =
gsn_add_polyline(wks,plot(1),xx,(/yy(n),yy(n)/),res_lines)
    plot@$tstr$ = gsn_add_text(wks,plot(1),plabel(n),xx(1),yy,res_text)
  end do

Can anyone figure out why my legend labels are, what appears to be,
'doubly' printed?

Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170816/9ef04efd/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2017-08-16 at 2.31.25 PM.png
Type: image/png
Size: 58937 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170816/9ef04efd/attachment.png 


More information about the ncl-talk mailing list