To access the additional fonts, use font number 10 and above. There is also a way to assign the new fonts to font numbers 0 to 6, if desired. The name of a font will depend on what fonts are installed on your system. A utility called "fontconfig" must be installed on your system for the Cairo fonts to work. You can use the fontconfig command "fc-list" to discover the fonts that fontconfig has made available.
The command to assign a font to a GrADS font number is a new form of the "set font" command:
set font nn bb ii font-name
The font number nn should be 10 to 99.
"bb" should be set to "normal" or "bold".
"ii" should be set to "normal" or "italic".
The font-name can be the name of any font on your system. Cairo will also try to match up the generic terms of "serif", "sans-serif", or "monospace" with some appropriate available font. These generic terms can be used as the font name. Font names may include blanks.
This command also sets the current font to be the font number indicated.
To access font numbers 10 and above within strings using the GrADS string escape characters, use the `f escape. The format of this is the backquote, followed by the character "f", followed by a two digit integer number. For example:
draw string `f10Temperature `3.`f10F
In the above example, the characters are drawin in font 10, except for the degree symbol, which is drawn using the traditional symbol font 3.
All other GrADS string drawing commands will work the same as before.
Examples
set font 10 bold normal times new roman
set strsiz 0.8 1.1
set string 1 c 1 45
draw string 4 5 Hello World
set strsiz 1.1 0.5
draw string 6 5 Hello Again
set font 10 normal normal arial
set lev 500
set clab masked
d t
set font 11 bold normal arial
draw title 500mb Temperature `3.`f11K
set rgb nn red green blue alpha
An alpha value of zero is fully transparent; a value of 255 is fully opaque. The default is 255.
Transparent colors will not work with the legacy shaded contouring algorithm ("set gxout shade1").
Example
... set up a grey scale rbcols ...
set gxout shaded
set lev 500
d z
set mpdraw off
set rgb 20 255 0 0 50
set clevs 5
set ccols -1 20
d v
set rgb 21 0 0 255 50
set clevs -5
set ccols 21 -1
d v
GrADS supports the automatic generation of tiles for drawing certain simple patterns. More complex patterns can be acheived by providing a custom image file.
Tiles are generated or described by the new "set tile" command:
set tile nn type width height lwidth fcolor bcolor
or
set tile nn 0 file-name
where:
nn is the tile number, 0 to 2000
type is the tile type, where 0 indicates the tile image is provided as the indicated file-name, and:
1 - solid
2 - dots
3 - diagonal up/down lines
4 - diagonal back/forth lines
5 - diagonal cross hatching
6 - vertical up/down lines
7 - horizontal back/forth lines
8 - up/down/back/forth cross hatching
width is the width of the generated tile in pixels. The default is 9.
height is the height of the generated tile in pixels. The default is 9.
lwidth is the line thickness used to draw the specified line in the image.
fcolor is the color used to draw the line
bcolor is the background color to be used to fill the background of the image.
For generated tiles, a small image is created using the specific width and height, and then is either filled with a solid color, or is filled with the background color and then one or two lines are drawn on the image using the foreground color and the specified line thickness. Note that the lines are either drawn from corner to corner (for diagonal lines) or through the middle of the image (for up/down or back/forth lines). Thus the size of the image, as controlled by the width and height settings, will control the spacing of the lines for the final pattern, and the aspect ratio of the image will control the angle of the lines. A smaller image will result in more closely spaced lines in the final pattern, and a larger image will result in a more widely spaced pattern.
Note that the default thickness is 3, the default foreground color is color number 1, and the default background color is a fully transparent black (red=0 green=0 blue=0 alpha=0).
The fully described tile will be a combination of the "set tile" command and "set rgb" commands to define the foreground and background colors. These may be set in any order, but should be set before any drawing is done on the current page. Setting rgb or tile values mid-stream in a plot may result in inconsistent behavior.
To use a tile pattern, assign the tile pattern to a color. The command is:
set rgb nn tile tt
where:
nn is the color number
tt is the tile number
A color that has a tile assigned to it may not be used as a color for another tile pattern.
Examples
set tile 20 8 5 5 2 0
set rgb 50 tile 20
set font 10 normal normal arial
set lev 500
set gxout shaded
set cint 60
d z
set ccols -1 50
set clevs 5
d v
draw title 500mb Heights
set rgb 30 0 0 0 70
set rgb 31 0 0 0 30
set tile 20 8 5 5 2 30 31
set rgb 50 tile 20
set font 10 normal normal arial
set lev 500
set gxout shaded
set cint 60
d z
set ccols -1 50
set clevs 5
d v
draw title 500mb Heights
The following example shows a number of different patterns. The tile command that was used to create the pattern is shown under each square (without the color values). The color definitions are not shown. The commands used to draw the last square are shown below. The commands used for the other squares are similar.
set rgb 36 255 255 0
set rgb 40 255 0 255
set tile 21 2 9 9 3 40 36
set rgb 31 tile 21
set line 31
draw recf 7 1 9 3
draw string 8 0.8 set tile 21 2 9 9 3
The following plot was done using the above patterns. The color numbers used in the above plot were 20 through 31. Once the tiles and colors are set up using the technique shown above, then:
set rbcols 20 21 22 23 24 25 26 27 28 29 30 31
set lev 500
set cint 30
set gxout shaded
d z
draw title 500mb Heights
To avoid this, you can plot a color value using a mask. How this operates "under the hood" is somewhat complex. When the color number is encountered, a mask is set up, the same size of the screen image. While that color number is being plotted, the plotting is done to the mask image. The mask image can be thought of as simply zeros and ones -- 0 indicating that the color has not been drawn there, 1 that it has. When this action is terminated, either by a major "event" or by another color number being used, then the "masked" color is drawn to the main plot using a masked paint operation, where the color is painted to the plot everywhere where the mask image was 1.
There are some drawbacks to using masked colors. The masked region is an image operation, so the boundaries will be jagged -- pixelated -- if the plot is magnified. There is a performance penalty for using masked colors. It is a good idea to avoid using masked colors unless needed. It is not normally necessary to use masked colors for "set gxout shade2" as the new shaded contouring algorithm is very well behaved.
To set a color to be masked, simply specify its alpha channel value as negative. The positive of that value will be used to draw the actual color, when rendered via the mask.
Examples
Note in the following example how for many of the polygons used to fill
the land area, the edges can be seen.
set rgb 20 0 0 0 100
set mpdraw off
set grid off
set font 10 normal normal arial
set lev 200
set gxout shaded
set clevs 0
set ccols 3 3
d z
set mpdraw on
run basemap.gs L 20 20 L
By using the masking option (a negative alpha value) for the color number 20 used for the map fill, the visible polygon edges are eliminated.
set rgb 20 0 0 0 -100
set mpdraw off
set grid off
set font 10 normal normal arial
set lev 200
set gxout shaded
set clevs 0
set ccols 3 3
d z
set mpdraw on
run basemap.gs L 20 20 L
This is how it might look for a more typical plot: