[ncl-talk] Changing font height
Mary Haley
haley at ucar.edu
Fri Dec 9 09:23:19 MST 2016
Barry,
This is why I tell people to use the gsn_csm_xxxx functions for plotting.
The wrf_xxxx functions don't allow much customization of the graphics,
because they are really meant to be "black-box" style plots.
You could modify WRFUserARW.ncl yourself, to add whatever flexibility you
need for the font heights.
For example, this is the line that is retrieving whatever FontHeightF value
you are setting:
font_height = get_res_value_keep(opts,"FontHeightF",0.01)
If you then search beyond that line for "font_height" you will see it used
here:
txt0 = create "MainPlotTitle" textItemClass wks
"txString" : opts at MainTitle
"txFontHeightF" : font_height*1.5
end create
and here:
if( opts at InitTime ) then
InitTime = "Init: " + model_start_time
txt1 = create "InitTime" textItemClass wks
"txString" : InitTime
"txFontHeightF" : font_height
end create
and here:
txt2 = create "ValidTime" textItemClass wks
"txString" : ValidTime
"txFontHeightF" : font_height
end create
To change this code to behave the way you want, first make a copy of this
file and call is whatever you want:
cp $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl myWRFUserARW.ncl
Bring up the "myWRFUserARW.ncl" file in a UNIX editor.
In this file, create new resources (calling them whatever you like) and use
them to replace the singular "FontHeightF".
For example, replace this line:
font_height = get_res_value_keep(opts,"FontHeightF",0.01)
with these three lines:
main_font_height = get_res_value_keep(opts,"MainFontHeightF",0.015)
init_time_font_height =
get_res_value_keep(opts,"InitTimeFontHeightF",0.01)
valid_time_font_height =
get_res_value_keep(opts,"ValidTimeFontHeightF",0.01)
and then replace the "font_height" variable in the three sections of code
with the appropriate "main_font_height", "init_time_font_height" and
"valid_time_font_height" variables. You will then be able to set your own
font heights for each one:
res at MainFontHeightF = 0.02
res at ValidTimeFontHeightF = 0.01
res at InitTimeFontHeightF = 0.008
Now, to run your script, you will need to edit it and load your own copy of
"myWRFUserARW.ncl":
load "./myWRFUserARW.ncl"
--Mary
On Wed, Dec 7, 2016 at 10:34 PM, Barry Lynn <barry.h.lynn at gmail.com> wrote:
> Hi:
>
> I found it hard to find an exact point where FontheightF was being set in
> WRFUserARW.ncl.
>
> Instead, I did what "WRF-NCL" did for the Title. I modified it this way in
> both the InitTime and ValidTime locations.
>
> if( opts at InitTime ) then
> InitTime = "Init: " + model_start_time
> txt1 = create "InitTime" textItemClass wks
> "txString" : InitTime
> "*txFontHeightF" : font_height*1.5*
>
> This morning, I do see this line:
>
> font_height = get_res_value_keep(opts,"FontHeightF",0.01).
>
> Perhaps, I needed to modify this line, but then I would have enlarged the
> Title as well.
>
> Barry
>
> On Thu, Dec 8, 2016 at 2:26 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Barry,
>>
>> This is a good question. I had to dig around in WRFUserARW.ncl to look
>> for the answer.
>>
>> I think setting "FontHeightF" should do it. Try a value like 0.01, and
>> then increase or decrease it by small amounts as necessary. This apparently
>> is an unadvertised resource and I'm not positive it will work.
>>
>> If you find that you are wanting to customize your WRF plots quite a bit,
>> then you may want to consider using gsn_csm_xxx functions to do the
>> plotting instead of wrf_xxxx.
>>
>> The wrf_xxxx functions are really meant to be used "as-is" to quickly
>> produce plots that can fit on an 8-1/2" x 11" paper.
>>
>> To see some examples of plotting WRF data with gsn_csm_xxx functions, see:
>>
>> http://www.ncl.ucar.edu/Applications/wrfgsn.shtml
>>
>> --Mary
>>
>>
>> On Wed, Dec 7, 2016 at 5:29 AM, Barry Lynn <barry.h.lynn at gmail.com>
>> wrote:
>>
>>> Hi:
>>>
>>> I have tried figuring out how to do this by accessing the most obvious
>>> pages, but I can't see how to change the height of "FieldTitle," and
>>> "UnitLabel."
>>>
>>> I get a resources not found for the bolded lines.
>>>
>>> opts_ic_cg at FieldTitle = time_var
>>> *opts_ic_cg at gsnStringFontHeightF = 0.025*
>>> opts_ic_cg at UnitLabel = "10 minute ETLN Lightning Rate"
>>> *opts_ic_cg at UnitLabelHeightF = 0.015*
>>> opts_ic_cg at cnLevelSelectionMode = "ExplicitLevels"
>>> opts_ic_cg at cnFillOn = True
>>>
>>>
>>> --
>>> Barry H. Lynn, Ph.D
>>> Senior Lecturer,
>>> The Institute of the Earth Science,
>>> The Hebrew University of Jerusalem,
>>> Givat Ram, Jerusalem 91904, Israel
>>> Tel: 972 547 231 170
>>> Fax: (972)-25662581
>>>
>>> C.E.O, Weather It Is, LTD
>>> Weather and Climate Focus
>>> http://weather-it-is.com
>>> Jerusalem, Israel
>>> Local: 02 930 9525
>>> Cell: 054 7 231 170
>>> Int-IS: x972 2 930 9525
>>> US 914 432 3108
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161209/6fc06e87/attachment.html
More information about the ncl-talk
mailing list