1.13 Contour maps

Contour maps are similar to color maps, but instead of coloring the whole $$(x,y)$ plane, lines are drawn to indicate paths of constant $c(x,y)$. The number of contours drawn, and the values $c_1$ that they correspond to, is set using the {\tt set contour} command\index{set contour command@{\tt set contour} command}, which has the following syntax: 

\begin{verbatim} 
set contours [ ( <number> |
               \( { <value> } \) ) ]
             [ (label | nolabel) ]
\end{verbatim}

If {\tt <number>} is specified, as in the example 

\begin{verbatim} 
set contours 8
\end{verbatim}

 then the specified number of contours are drawn at evenly spaced intervals. Whether the contours are linearly or logarithmically spaced can be changed using the commands 

\begin{verbatim} 
set logscale c1
set linearscale c1
\end{verbatim}

 By default, the range of values spanned by the contours is automatically scales to the range of the data provided. However, it may also be set manually using the {\tt set c1range} command\index{set c1range command@{\tt set c1range} command} as in the example 

\begin{verbatim} 
set c1range [0:10]
\end{verbatim}

 The default autoscaling behaviour can be restored using the command 

\begin{verbatim} 
set c1range [*:*]
\end{verbatim}

Alternatively, an explicit list of the values of 

$c$ for which contours should be drawn may be specified to the {\tt set contour} command\index{set contour command@{\tt set contour} command} as a ()-bracketed comma-separated list. For example: 

\begin{verbatim} 
set contours (0,5,10,20,40)
\end{verbatim}

If the option {\tt label} is specified to the {\tt set contour} command\index{set contour command@{\tt set contour} command}, then each contour is labelled with the value of 

$c$ that it corresponds to. If the option {\tt nolabel} is specified, then the contours are left unlabelled. 

In the following example, a contour map is overlaid on top of a color map of the function 

$x^3/20+y^2$: 

\vspace{2mm} \input{examples/tex/ex_ contourmap_1.tex} \vspace{2mm} 

\centerline{\includegraphics[width=10cm]{examples/eps/ex_ contourmap}} \vspace{2mm} 

The {\tt contourmap} plot style differs from other plot styles in that it is not permitted to take expressions such as {\tt \$ 2+1} for style modifiers such as {\tt linetype} (see Section~ \ref{sec:with_ modifier}) which use additional columns of input data to plot different points in different styles. However, the variable {\tt c1} may be used in such expressions to define different styles for different contours: 

{\vspace{3mm}\noindent \begin{tabular}{p{1cm}p{\dontdowidth }}\noindent {\includegraphics{cross}}

& \noindent \begin{minipage}{\dontdowidth }\tt  plot ’datafile’ with contourmap linetype \$ 5 \end{minipage}

\end{tabular}\vspace{3mm}} 

{\vspace{3mm}\noindent \begin{tabular}{p{1cm}p{\dontdowidth }}\noindent {\includegraphics{tick}}

& \noindent \begin{minipage}{\dontdowidth }\tt  plot ’datafile’ with contourmap linetype c1/10 \end{minipage}

\end{tabular}\vspace{3mm}} 

$