CONtour

CONtour [gnum] ?|COlor list|LEvel list|LStyle list|LWidth list|OFf

This command causes PLT contour a two dimensional array of data. The first number denotes the plot group to be contoured. If you have not defined any two dimensional plot groups, then PLT will automatically create a group for you that consists of the largest possible chunk of the main data array. If you omit the first number then PLT uses the group number from the last time you used the CONtour, IMAge, DGroup (to define a 2D array). If none of these commands were used, the PLT will use group 1.

A contour plot does not automatically turn off the normal plotting of the remaining plot groups, and typical arrays to be contoured may contains lots (hundreds!) of columns the possiblity that some of those groups will normally overwrite the contour is high. Thus you are advised to issue a

COlor OFf 1..999

to suppress the normal ploting, unless, of course you are a PLT wizard and want to mix the two types of plot.

If order for a contour to appear you must define a set of levels via the LEvel subcommand.

example

Although this example is intended to be standalone, it will work with the fig06.qdp file. In other words, if you use qdp to plot fig06.qdp you can enter the following commands to get two contour plots in two windows. You will also note that group 1 is plotted in window 2 and group 2 in window 1. This was done purely to illustrate that it is possible. In general you will get a lot less confused if you stick to a simpler convention (e.g., group 1 in window 1, etc.)
Yplot OFf 1..99         ! Turn off all previous plots
DGroup 2 1 1 10 20      ! Define group 2 to be a 2D group
WIN 1                   ! Define the window to use
LOC 0 0 0.5 0.5         ! Locate window in bottom left corner
YPL 2                   ! Plot group 2 in window 1
CON 2 LEvels -0.5 0 0.5 ! Create contours at three levels
CON 2 LStyle 4 4        ! Use dotted lines for negative levels
CON 2 LWidth,,3         ! Make the level=0 line fatter
GAP 0.0 Nerr            ! Best for contour plots
R                       ! Reset the scale in this window
DGroup 1 11 1 20 20     ! Define group 1
WIN 2                   ! Define a second window
YPL 1                   ! Plot group 1 in window 2
LOC 0.5 0.5 1.0 1.0     ! :ocate window in upper right corner
CON 1 LEvels -1.5 -0.5 0 0.5 1.5
CON 1 LWidth,,,3        ! Fatten up level=0 in this plot
CON 1 LStyle 4 4        ! Use dotted lines for negative levels
R                       ! Reset the scale in this window

hints

PGPLOT draws the line segments that make up the contour such that one coordinate of an (x,y) pair is always at a integer pixel position, i.e., a pixel center. This makes sense if you assume the z value is correct at the center of the pixel and thus one is computing where the contour level intersects the line between two pixel centers. To correctly set the default scale for contour plot you should use:

GAp 0.0 Noerrors R ! reset the default scale.

The GAp 0.0 ensures that there is no extra gap around the data, and the Noerrors causes the error bars to be ignored when min/max values are computed. This causes the default scale to be set by the pixel centers.

It is possible to plot both a contour and an image in the same window. If the contour and image are both from the same group the PLT automatically plots the image first and then the contour "on top" of the image. If the contour and image correspond to different groups, then you should make sure the image is assigned a lower group number. This is because PLT plots the groups in order from the lowest to the highest.

Color

By default PLT plots the first contour with color index 1, the second with color index 2, etc. (Use the PLT COlor ? command to see the default mapping of color index into colors). The CONtour Color sub-command can be used to override this default. Thus to plot the first 10 levels with color index 1, you would use

CON Color 1 1 1 1 1 1 1 1 1 1

and to change just the third level to color index 3 use

CON Color,,,3

Note, you must use the CONtour LEv subcommand to define the levels before any contours will be plotted.

LEvel

This subcommand is required must be used before a contour plot will appear. The CONtour LEvel subcommand is followed by a list of numbers that correspond to the levels to be contoured. You can define up to 32 (set by MXLEV in PLT code) contour levels. Thus

CON LEV -20 -10 0 10 20

would define 5 levels. PLT remembers the previous levels so you change the value for level 3 only by

CON LEV ,,,3.14159

To use fewer levels than what had been previously defined you must use the NO data value. Thus

CON LEV,,,,no

would leave the first 3 levels unchanged and stop plotting levels above 4.

LStyle

By default all contours are plotted with a line style of one. (Use the PLT "LStyle ?" command to get a list of the possible styles.) You can use the CONtour LStyle sub-command to change this. Suppose you wanted to use dotted lines (line style of 4) to plot negative contours. You would do this with

CON LEV -10 -20 0 10 20 CON LS 4 4

Thus the first two contour levels would now be plotted with line style of 2 and the remainder would use the default line style.

Note, you must use the CONtour LEv subcommand to define the levels before any contours will be plotted.

LWidth

By default all contours are plotted with a line width of 1. You can override this default using the CONtour LWidth subcommand. Thus

CON LWidth,,,3

would plot the third level with a line width of 3.

Note, you must use the CONtour LEv subcommand to define the levels before any contours will be plotted.

OFf

This subcommand is use to switch off the plotting of a contour with a plot group. This you no longer wish to see plot group 2 plotted with a contour, then you would use

CON 2 OFF

Of course, if you now want to see plot group 2 plotted as a regular Y vs X manner, make sure you use the COlor ON command, i.e., COL ON 2. Since group 2 is now a two dimensional array, you will now see the entire array was was being contoured projected onto the X coordinate. If you wish to restore group 2 to its original one dimensional form you should use "DGrroup 2 2", i.e., define group 2 to be the second vector in the main data array.


Return to plt main page.