Polygons, Polymarkers, and Polylines
gsn_polygon_ndc will add polygons in ndc(page) coordinates while gsn_polygon will add them in plot coordinates.
The "climdiv_polygons.nc" netCDF file used in this script is available here (767440 bytes).
mpGridAndLimbOn = False, turns off the lat/lon grid.
mpAreaMaskingOn = True, enables area masking. This then allows the map to be divided into different areas by setting the resource mpFillAreaSpecifiers, e.g. (/"Water","Land"/). These designated areas can then be filled by setting the resource mpSpecifiedFillColors to various colors. In this case, they were set to zero to mask them entirely.
gsn_add_polymarker is the plot interface that will add polymarkers to a plot so that they can be paneled. There is also gsn_polymarker and gsn_polymarker_ndc which adds the polymarkers in page coordinates.
IMPORTANT: note the syntax on the use of this function:
dum1 = gsn_add_polymarker(wks,plot,glon(inds),glat(inds),polyres) . With this function, you need to set it equal to some sort of dummy variable. Do not set it equal to plot like we do in all other cases. Also, if you do panel this type of plot, do not delete that dummy variable or over write it.
gsn_add_polyline is the plot interface that adds polylines to a plot, and gsn_add_polygon is the plot interface that adds polygons to a plot. This version allows for panelling. There is also gsn_polyline and gsn_polyline_ndc which adds polylines in page coordinates.
gsLineColor = "red", changes the line color to red.
gsLineThicknessF = 2.0, changes the thickness of the line.
gsFillIndex > 0 changes the fill pattern to a pattern (rather than a solid).
gsFillScale changes the density of the fill pattern.
gsLineLabelString = "test", is one method of labeling a box of this type.
The trick with this plot is to create an array of dummy graphic variables. When you use gsn_add_polyline, the result must be a graphic variable. In a loop, you must not over write the dummy variable, which is why we need an array.
As of NCL version 4.2.0.a030, you can make your own marker using NhlNewMarker. You give the function the character and font table you want the marker taken from, and provide sizing and placement values. The function returns a marker index that can be used with xyMarkerColor.
This approach can be used for any boundary one wishes to draw as long as the coordinates are provided. (One should first check that the desired boundary cannot be drawn using the mpOutlineBoundarySets / mpAreaNames / mpOutlineSpecifiers suite of resources.)
The data files can be downloaded via the estados_brasil.tar tar file. You need to type "tar -xvf estados_brasil.tar" to extract the files.
As the extratropical polygons (red/blue) require the ocean to overlay the polygons, and the tropical polygons (green/yellow) require the land to overlay the polygons, the only way to get the desired effect is to draw two plots, and to set tfPolyDrawOrder equal to Draw.
A third blank plot is drawn over the previous two to draw the border correctly.
This is a reproduction of figure 1b from Kutzbach et al. 2008, Climate Dynamics, 30:567-579.
The point of this example is to show how various boxes look when they overlaid in a different order. The middle column was drawn starting with the red box starting first. The right column was drawn with the yellow box starting first.