- contour(data, x, y, annot=None, c_levels=None, colorbar=1, continents=0, ctindex=13, plottype='both', position=None, title=None, xrange=None, yrange=None, xtitle=None, ytitle=None)
- Interactively make 2-D contour plots.
Plots a contour plot onto the active VCS canvas. If there is a
pre-existing plot on the active canvas, that plot is overwritten.
Syntax of method call is based on IDL conventions. However,
defaults for input parameters are set to my personal preferences,
not IDL defaults; a call of contour(data,x,y) should give a
generic contour plot of that type I would (subjectively) find
generally suitable for publication.
Default plot is a generic contour plot with no axis titles or
overall title, and with a colorbar legend plotted at the bottom.
The plot is rainbow filled with contour lines overlain.
* data: 2-D array of data to contour. Location of rows are
described by y, and location of columns by x. Typically
for plots on the earth, x is longitude and y is latitude
so rows in data are bands of constant latitude. Numeric, MA,
MV array. If data is Numeric only, there should be no missing
values in data.
* x: Vector of x-axis variable values, which corresponds to
iterating through the columns of data. Numeric, MA, or MV
vector. There should be no missing values in x.
* y: Vector of y-axis variable values, which corresponds to
iterating through the rows of data. Numeric, MA, or MV
vector. There should be no missing values in y.
NB: If an input argument is MV, only the MA portion of the
variable is used; this procedure does not read the additional
attributes of the MV class.
* annot: Extra text to annotate the graph with, placed in the
very upper-left corner in small-sized text (1/2 the height of
the overall title). String scalar. Different lines of text
are separated by the os.linesep string.
* c_levels: Vector of contour levels. Can be list or Numeric
array. Default is None.
* colorbar: If set true (i.e. not equal to 0), a color bar
legend of the filled contour colors is plotted. Default is
true, except when plottype is 'line' the colorbar keyword's
value is ignored and no color bar is plotted.
* continents: If set true (i.e. not equal to 0), fine modern
continent outlines are plotted. Default is false.
* ctindex: Index of color table to use, keyed into the values
used by procedure loadct. The command loadct() will list all
available values. Default is 13 (rainbow, violet to red,
* plottype: If set to 'fill', smooth filled contours only are
plotted; if set to 'line', contour lines only are plotted; if
set to 'both', smooth filled contours plus an overlay of contour
lines are plotted. String scalar. Default is 'both'.
* position: 4-element list of [bbllx, bblly, bburx, bbury] of
the bounding box (x,y) coordinates in normalized values. The
data origin is the lower-left corner, and the upper-right cor-
ner of the data box is the upper-right corner of position.
If keyword not defined, IaGraph.Sysvar.__class__.p_position is
used. If that system variable is not defined, this procedure
uses the following values:
position value | colorbar? | annot?
[0.2, 0.30, 0.9, 0.80] | Y | Y
[0.2, 0.15, 0.9, 0.65] | N | Y
[0.2, 0.35, 0.9, 0.85] | Y | N
[0.2, 0.25, 0.9, 0.75] | N | N
* title: The overall plot title. String scalar. Only a single
line of input is accepted.
* [xy]range: The range of the [xy]-axis used to calculate "neat"
tickmarks, from which the actual axis range is set. Two-element
list, where the first element is the minimum in the axis range
and the second element is the maximum in the axis range. If
keyword not defined, IaGraph.Sysvar.__class__.[xy]_range is used.
If that system variable is not defined, this procedure uses the
the minimum and maximum of each input axis vector.
* [xy]title: The x-axis and y-axis title. String scalar. Only
a single line of input is accepted.
* Contour plot of data on screen.
* The active_canvas system variable in IaGraph.Sysvar is set to
the canvas (overwritten if a previous canvas exists) that is
drawn by this procedure. This allows other procedures in
IaGraph to operate on the canvas outside of the IaGraph.contour
* The font for the colorbar and the annot keyword text are set to
be the overall title font.
* Font heights for the axes labels are set to be the same as the
* Color of overall title, colorbar text, and axes tick labels and
titles are forced to always be black.
* The colorbar and annot font heights are set to 1/2 the overall
* The colorbar height is set to 0.03 (normalized units).
* If contour lines are plotted, negative values are long dashed
and positive values are solid.
Example to plot a simple contour plot with an overall title:
import Numeric as N
from contour import contour
x = N.arange(25) * 15.0 - 180.0
y = N.arange(13) * 15.0 - 90.0
data = N.outerproduct(N.sin(y*N.pi/360.), N.cos(x*N.pi/360.))
contour(data, x, y, title='Example')
Example to make a contour plot with manually set contour levels:
levs = [-0.3, -0.15, 0, 0.4, 0.6, 0.78]
contour(data, x, y, c_levels=levs)