Re: trick for hiding lines in legend

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 19 2012 - 14:17:36 MDT

On Jul 18, 2012, at 9:10 PM, mark collier wrote:

> Hi Mary/Rick,
> yes Mary's solution is the best as it offers the most flexibility. However, I was a little surprised that I couldn't get a white box to block out the unwanted legend items as for my case it will be adequate as the build in legend feature is generally quite adequate and only needs minor tweaking.

Hi Mark,

I think the issue with the white box is actually with the legend. :-) It wants to be drawn last, no mater what you do. Really, the only way you can get a white box over the legends is to first draw the plot with the legends, and then draw the box with gsn_polygon.

However, I think I have a better solution for you. Please see example 14 at:

http://www.ncl.ucar.edu/Applications/legend.shtml

The key is to create multiple XY plots, and then overlay them with the "overlay" procedure. This way, you can customize which curves get the legend, and which don't. The overlay procedure will take care of putting the two plots in the same data space, and not having two sets of tickmarks.

--Mary

>
> As I was also panelling, it was quite tricky to get the legend text of similar size between the panels and also the line lengths of similar size - in the end it was a compromise via the attributes:
>
> lgres@vpHeightF = 0.15 ; height of legend (NDC)
> lgres@vpWidthF = 0.17 ; width of legend (NDC)
> lgres@lgLabelFontHeightF = 0.15 ; Change the font size
>
> Many thanks,
> Mark.
>
> On 19/07/2012, at 2:25 AM, Mary Haley wrote:
>
>> Hi Mark and Rick,
>>
>> I thought changing a legend should be as easy as using the lgLineColors resource. But, when you use the built-in legend that comes with an XY plot, most of the legend resources are "turned off" and hence you can't change them. There's something called the "PlotManger" which is taking control of the legend here.
>>
>> If you want to customize the lines in your legend, especially in the sense of turning individual ones on or off, then you will need to *not* use this built-in legend, and instead create one yourself and attach it to the plot.
>>
>> Please see example 8, which shows you how to create the legend using gsn_create_legend, and then how to attach it using gsn_add_annotation.
>>
>> You can look at example 13, which is more complicated. It queries the XY plot for you, and attemps to construct the legend from scratch. It also allows you to pick how many legend items to display, but it starts with the first one and works from there. You would have to modify it to indicate that you want to keep the last two.
>>
>> --Mary
>>
>> On Jul 18, 2012, at 9:35 AM, Rick Brownrigg wrote:
>>
>>> Hi Mark,
>>>
>>> I don't know for certain without seeing your script and playing around with it, but one thing that comes to mind is to define the black line colors as completely transparent, such as (/ 0., 0., 0., 0. /) (assumes you are using 6.1.0b). Are you using the lgLineColors resource to specify line colors of the legend?
>>>
>>> Hope that helps…
>>> Rick
>>>
>>> On Jul 18, 2012, at 2:15 AM, mark collier wrote:
>>>
>>>> Hi,
>>>> wondering if there is a "cheap trick" for hiding the black-lines in the legend when using the built in legend feature? Setting the line to white wouldn't work as it would white out the time-series - and my attempt to put a white box over them failed although should work in principle but requires tweaking. One option might be to define a line type that has no "dashes" and use it?
>>>> Thanks for any advice,
>>>> Mark.
>>>>
>>>> <PastedGraphic-2.tiff>
>>>> _______________________________________________
>>>> 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
>>
>
> _______________________________________________
> 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 Thu Jul 19 14:17:45 2012

This archive was generated by hypermail 2.1.8 : Tue Jul 24 2012 - 09:48:26 MDT