[ncl-talk] legend font size
David Brown
dbrown at ucar.edu
Wed Sep 16 11:32:16 MDT 2015
I will look into this question.
-dave
On Tue, Sep 15, 2015 at 5:20 PM, Mary Haley <haley at ucar.edu> wrote:
> Hi Gerard,
>
> I'm hoping Dave Brown will step in and correct me if I'm wrong, but I think
> the resizing of the legend labels is going to happen no matter what, because
> it's trying to fit everything inside the legend box.
>
> You can work around this by using gsn_create_legend (instead of
> gsn_legend_ndc) to create the legend with the same resources as before, and
> then use setvalues to reset the lgLabelFontHeightF resource to be what you
> originally wanted it to be. Setvalues will simply change the resource value
> of an existing object, and the legend manager doesn't enter the picture and
> try to shrink your labels.
>
> It's a kludge, but I think it should work. here's what the old code looks
> like:
>
> gsn_legend_ndc(wks_png, num_curves, legend_labels, 0.20, 0.35, lgres)
> frame(wks_png)
>
> And here's what the new code should look like:
>
> ;---gsn_create_legend creates the legend, but doesn't draw it
> legend_id = gsn_create_legend(wks_png, num_curves, legend_labels, lgres)
>
> ;---Reset lgLabelFontHeightF to the desired value
> setvalues legend_id
> "lgLabelFontHeightF" : lgres at lgLabelFontHeightF
> end setvalues
>
> ;--Now draw the legend
> draw(legend_id)
> frame(wks_png)
>
> You may need to place with lgres at vpXF and legres at vpYF to position the legend
> as desired.
>
> --Mary
>
>
> On Mon, Sep 14, 2015 at 11:19 PM, Gerard Ketefian - NOAA Affiliate
> <gerard.ketefian at noaa.gov> wrote:
>>
>> Hi,
>>
>> I'd like to generate a legend in which the font size of the item labels is
>> the same regardless of the length (i.e. the number of characters) of the
>> item labels. I'm using gsn_legend_ndc(...) to add the legend to my plot.
>>
>> The problem I'm having is that NCL is adjusting the font size (I suppose
>> to always fit the labels within the width of the legend box), and I'm not
>> getting the font size that I'd like.
>>
>> I've attached an NCL script (test_legend.ncl) that generates png files
>> showing what happens when:
>>
>> 1) No adjustments are made to any legend resources (case of manual_manage
>> set to False in the script). I tried a case of short legend labels
>> (test_legend_autoManage_short_labels.png) and another with long ones
>> (test_legend_autoManage_long_labels.png). You can see that NCL adjusts the
>> font size, I suppose to fit it within the legend box width.
>>
>> 2) Adjustments are made to several legend resources, including setting
>> lgAutoManage to False (case of manual_manage set to False in the script) and
>> setting a specific value for lgLabelFontHeightF. According to the online
>> documentation, in this case NCL should not adjust the font size, and I
>> should get whatever font size I specified via lgLabelFontHeightF. Again I
>> tried a case of both short (test_legend_manualManage_short_labels.png) and
>> long (test_legend_manualManage_long_labels.png) legend labels. You can see
>> that again, NCL adjusted the font size.
>>
>> Any idea how I can make NCL use the font size I specified, without any
>> automatic adjustments?
>>
>> Thanks,
>> Gerard
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
More information about the ncl-talk
mailing list