NCL Home>
Application examples>
Plot techniques ||
Data files for some examples
Example pages containing:
tips |
resources |
functions/procedures
Contours overlaid on contours
To overlay contours on top of other contours (and possibly those on
top of maps), you can either use the
overlay
procedure (which can also be used to overlay other things like vectors
and streamlines), or the special plotting function
gsn_csm_contour_map_overlay.
This page also shows how you can create different types of contours
for more meaningful plots, like dashed line contours, shaded contours,
and stippled contours.
If you plan to overlay multiple types of plots on a map
plot, the prefered method is to use the overlay
procedure.
conOncon_1.ncl: A typical contour
on contour plot.
Note that this data is already on pressure
levels. If this were model data, it would be necessary to interpolate
from hybrid coordinates to pressure levels.
Use gsn_csm_pres_hgt and gsn_csm_contour. Then
overlay(plotu,plotv) will overlay the two plots.
At this point NCL only sees one plot, plotu since it was listed first,
so now if we draw plotu, we will get both plots.
gsnContourZeroLineThicknessF doubles the
thickness of the zero contour, and gsnContourNegLineDashPattern dashes the negative
contours.
conOncon_2.ncl: This example
shows how to overlay several contour objects over a map background.
gsn_csm_contour_map_overlay is the
plot interface that overlays contour objects onto a map
background. Note that this function sets the zero line thickness to
2.0 and sets all other contours line thickness to 1.0. This will
override whatever thicknesses you have set.
NhlNewColor allows the user to add one or more colors to
an existing color map. They can only be specified using RGB
triplets.
gsnContourZeroLineThicknessF doubles the
thickness of the zero contour, and gsnContourNegLineDashPattern dashes the negative
contours.
conOncon_6.ncl: Demonstrates the
addition of a legend for a contour-On-contour plot.
gsn_legend_ndc is the function that
will add a legend to a contour plot.
conOncon_7.ncl: Spaghetti plot
(data with 2D coordinates). Data with 2D coordinates require extra
steps to create an overlay spaghetti plot.
You must use gsn_contour for the
contour portion of this plot. See the sample script for all the
details.
This data just happens to be on a native
grid projection. This is just one type of data that usually has 2D
coordinates. The techniques in the loop will not change for data that
is not on a native grid.
conOncon_8.ncl: A color
significance plot. The difference between this example and example 2
is the order. The color fill must be drawn first and then the contour
lines added. This goes whether the significance is colored magenta or
gray. The issue is a solid fill versus a pattern fill (stippling).
For a "B&W" plot, replace magenta with gray and turn off the continent
fill by setting mpFillOn = False.
conOncon_9.ncl: This image
describes land use in different resolutions for each domain. This
script was originally written in
PyNGL by Ufuk Utku Turuncoglu of
the Istanbul Technical University in relation to a Turkey Climate
Change Scenarios project.
The overlay function is used to do the multiple
contour overlays, and the special lat2d/lon2d attributes are used to
indicate there are 2-dimensional latitude/longitude coordinate arrays.
Polylines are drawn on top of the map to show the three domains.
conOncon_10.ncl: This
example shows how to overlay precipitation contours on
a terrain map, using transparent contours for some of
the precipitation values.
This example also shows how to use two different colormaps
that are too large to merge into one colormap.
The overlay function is used to do the overlay of
precipitation. The special lat2d/lon2d attributes are used to indicate
the latitude, longitude positions of the data.
Thanks to Dr. Craig Mattocks at the Center for Environmental Modeling
for Policy Development, UNC-Chapel Hill, for providing the inspiration
for this example and helping fine-tune it. There's a
version of this script that uses wrf_xxx functions on the WRF precipitation page.