resources@lbPerimOn = False
There are times when you want to add other graphical objects to a plot, like a label bar, a legend, tick marks, or a title. In NCL, there's
something called a "PlotManager" that lets you do this. It's called this because it "manages" the look of these additional objects and tries to
make intelligent guesses about where the additional objects should be drawn with respect to the original plot. Also, if you resize the original
plot, then these extra objects get resized as well. Some of these objects are always drawn by default, like tick marks and a title (if you specify
one). A label bar is not drawn by default, so you need to tell the PlotManager to draw it by setting the PlotManager
resource pmLabelBarDisplayMode to the predefined string "Always" (the default is "Never"). PlotManager resources start with "pm, and label bar
resources start with "lb.
As noted in example 1, predefined strings are case-insensitive, so the
pmLabelBarDisplayMode
resource could have also been set
using "always" or "ALWAYS" or any another combination of uppercase and lowercase characters.
Setting the
lbPerimOn
resource to
False
indicates that you don't want a perimeter drawn around the label bar.
Lines 62-65:
resources@tiMainString = Z@long_name
resources@tiMainFont = 26
resources@tiXAxisFont = 26
resources@tiYAxisFont = 26
Set the main title using the long_name attribute of Z. Also change the fonts of the title and the X and Y axis labels. Please see the table of all
the available fonts with their index values. In this case, you are changing the font to "Times-bold."
Note: You could have also set this resource using the actual name of the font, "Times-bold", instead of the number 26.
Line 67:
plot = gsn_contour(xwks,Z,resources)
Draw the fourth contour plot with a new dataset. Note that there are some areas in the contour plot that aren't being drawn. This is due to
the presence of missing values in the data. By default, if the data being passed to any of the gsn_* plotting routines contains the attribute
"_FillValue," then the value of this attribute is assumed to represent a missing value, and the gsn_* routines do not plot any data equal to
this value. Missing values are covered in more detail in later examples, and you can also read about them in the "NCL variables overview"
section of the NCL Reference Manual.
Line 69:
;---------- Begin fifth plot ------------------------------------------
Draw a contour plot of the pres variable and fill the contour lines in solid colors using a grayscale color map that you define yourself.
Lines 71-75:
cmap = (/(/0.,0.,0./),(/1.,1.,1./),(/.1,.1,.1/),(/.15,.15,.15/),\
(/.2,.2,.2/),(/.25,.25,.25/),(/.3,.3,.3/),(/.35,.35,.35/),\
(/.4,.4,.4/),(/.45,.45,.45/),(/.5,.5,.5/),(/.55,.55,.55/),\
(/.6,.6,.6/),(/.65,.65,.65/),(/.7,.7,.7/),(/.75,.75,.75/),\
(/.8,.8,.8/),(/.85,.85,.85/)/)
For this plot, use grayscale values to fill the contour levels. To do this, you need to define your own color map. Color maps are represented
by arrays of red, green, and blue float values (referred to as RGB values) ranging from 0. to 1. (to indicate the intensity of that particular
color). The first entry in a color map is the background color, and the second entry is the foreground color. To get a color map of grayscale
values, use equal values for R, G, and B.
For more information on creating your own color map, see the section "Color maps" in the "Basics" chapter.
Line 77:
gsn_define_colormap(xwks,cmap)
To define a color map, use the NCL procedure gsn_define_colormap. The first argument is the workstation variable returned from a
previous call to gsn_open_wks. The second argument is the color map you just created inlines 71-75.
Lines 79-81:
resources@tiMainString = pres@long_name
plot = gsn_contour(xwks,pres,resources)