Re: Legends

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon, 10 Nov 2008 17:48:26 -0700

Hi Rosemarie,

It would be helpful to know what you ultimately want your legend to
look like. Do you really want it to be as wide as your script suggests?
Why are you not using the regular legend labels to label your lines?
Because you couldn't figure out how to set the size? Or was it
something else, like wanting the label color to match the line color?

Some resources that you may not know about are:

lgAutoManage: when set True, the Legend label font size is set
automatically. Setting this False allows you to control the label
font sizes.
It does not affect the line label font size (these are actually part
of the line pattern).

lgBoxMinorExtentF : this basically controls the fraction of the
legend as a whole that the boxes occupy in the direction orthogonal
to the sequence of legend lines.
By default it is .5, to leave plenty of room for the legend labels.
However, if you have turned the labels off, setting this resource to
a larger value will cause
the boxes to be wider (assuming the legend lines oriented in a
vertical sequence). If you set it to 1.0, then the boxes will occupy
the full width of the space allotted by
vpWidthF if you also set lgLeftMarginF and lgRightMarginF to 0.0.

lgBoxMajorExtentF: this controls the spacing between each box (in the
vertical direction, given the orientation you have set up for your
legend).

I hope this helps. As I stated above, it would be helpful to have a
better sense of what you want your ultimate result to look like.
  -dave

P.S. I am noticing an anomaly in your legend that could be a bug in
the code. When I run your code, the second two lines appear not to
restore all the line properties
after the line label text is drawn. I will look into this.

On Nov 10, 2008, at 2:24 PM, Rosemarie Drummond wrote:

> Hi,
> I am trying to add a legend to a plot. Below is the ncl script
> just for this legend part. I am attaching a ps file created by it.
> I have put lgBoxLinesOn = True so that it shows how much white
> space it puts each side of the actual legends.
> I would like this white space to be very small and the text to be
> bigger. The actual line segments could be shorter but that does not
> seem to be settable.
> Any advice would be gladly received
> Rosemarie
>
>
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> begin
> ncolors = 9
> cmap = new((/ncolors,3/), float)
> cmap = (/ (/1.0,1.0,1.0/), \
> (/0.0,0.0,0.0/), \
> (/1.0,0.0,0.0/), \
> (/0.0,1.0,0.0/), \
> (/0.0,0.0,1.0/), \
> (/0.0,1.0,1.0/), \
> (/1.0,0.0,0.80/), \
> (/1.0,0.50,0.0/), \
> (/0.90,0.90,0.90/)/)
>
> xworkid = gsn_open_wks("ps","Vtst")
>
> setvalues xworkid
> "wkColorMap" : cmap
> end setvalues
> getvalues xworkid
> "wkDefGraphicStyleId": gsid
> end getvalues
>
>
> Lg_id = create "Legend" legendClass xworkid
> "vpXF" : 0.3
> "vpYF" : 0.5
> "vpWidthF" : 0.70
> "vpHeightF" : 0.18
> "lgItemCount" : 3
> ; "lgPerimOn" : False
> "lgBoxLinesOn" : True
> "lgLeftMarginF" : 0.01
> "lgRightMarginF" : 0.01
>
> "lgLabelsOn" : False
> "lgLabelFont" : 30
> "lgLabelFontHeightF" : .07
> "lgLabelStrings" : (/" D:F35:)):F30: Models"," VM5a"," VM2"/)
>
> "lgDashIndexes" : (/16,0,0/)
> "lgMonoLineThickness" : False
> "lgLineThicknesses" : (/3.,6.,6./)
> "lgLineColors" : (/4,3,2/)
>
> ; "lgMonoLabelFontColor" : False invalid
> ; "lgLabelFontColors" : (/4,3,2/) invalid
>
> "lgMonoLineLabelFontHeight" : False
> "lgLineLabelFontHeights" : (/0.02,0.02,0.02/)
> "lgLineLabelFontThicknessF" : 3
> "lgLineLabelFontColors" : (/4,3,2/)
> "lgLineLabelStrings" : (/"VM5b-#","VM5a ","VM2 "/)
> "lgLineLabelFont" : 30
>
> end create
> draw(Lg_id)
>
> end
>
> --
> Dr Rosemarie Drummond
> rmarie_at_atmosp.physics.utoronto.ca
>
> <Vtst.ps>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov 10 2008 - 17:48:26 MST

This archive was generated by hypermail 2.2.0 : Fri Nov 14 2008 - 16:42:12 MST