Re: bar chart legends

From: Adam Phillips (asphilli AT cgd.ucar.edu)
Date: Tue Jun 28 2005 - 11:43:43 MDT


ncl users: Dave and I have communicated offline about this, here is the
code that I ended up sending him:

lbres = True ; legend only resources
lbres@vpWidthF = 0.15 ; legend width
lbres@vpHeightF = 0.05 ; legend height
lbres@lbBoxMajorExtentF = 0.18 ; puts space between color boxes
lbres@lbFillColors = (/"green","blue"/)
lbres@lbMonoFillPattern = True ; Solid fill pattern
lbres@lbLabelFontHeightF = 0.036 ; font height. default is small
lbres@lbLabelJust = "CenterLeft" ; left justify labels
lbres@lbPerimOn = False
lbres@lgPerimColor = "white"
labels = (/"CCSM3 (T85)","CCSM3 (T42)"/)
gsn_labelbar_ndc(wks,2,labels,0.51,0.51,lbres)
frame(wks)

This will produce a legend with two colorbars and labels:
CB1 CCSM3 (T85) CB2 CCSM3 (T42)

The number of colorbars/labels, the spacing between them, and the colors
used are easily adjusted.

Adam

David B. Reusch wrote:
> Greetings ncl users,
>
> I am trying to figure out how/if I can get a horizontal
> legend underneath my panel of XYBarCharts. The tricky
> part is that I want something like:
> CB1 str1 CB2 str2 CB3 str3 ... CBn strn
> where CBx is the color box and str1 is the label string
> that goes with it. that is, a line of pairs of color
> boxes and their labels.
>
> right now, thanks to the bar_7.ncl example (using
> gsn_label_bar_ndc), I have:
> CBn strn
> ...
> CB2 str2
> CB1 str1
>
> this is sort of ok (although it *is* bottom-to-top) but
> takes more space than I'd really like to use. switching
> the label bar to horizontal tries to put the labels under
> the boxes, which is not what I'm after.
>
> I suspect this is going to take some special manual effort
> to place the label bar elements. if so, I could use some
> help on getting at the nitty gritty. if not, I'd love to
> hear the "easier way".
>
> thanks,
> dave
>
> ----------
> Department of Geosciences
> 517 Deike Building
> Penn State University
> University Park, PA 16802
> _______________________________________________
> ncl-talk mailing list
> ncl-talk@ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD                                   fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Tue Jun 28 2005 - 15:35:33 MDT