1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% GLE - Graphics Layout Engine <http://glx.sourceforge.io/> %
% %
% Modified BSD License %
% %
% Copyright (C) 2009 GLE. %
% %
% Redistribution and use in source and binary forms, with or without %
% modification, are permitted provided that the following conditions %
% are met: %
% %
% 1. Redistributions of source code must retain the above copyright %
% notice, this list of conditions and the following disclaimer. %
% %
% 2. Redistributions in binary form must reproduce the above %
% copyright notice, this list of conditions and the following %
% disclaimer in the documentation and/or other materials provided with %
% the distribution. %
% %
% 3. The name of the author may not be used to endorse or promote %
% products derived from this software without specific prior written %
% permission. %
% %
% THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR %
% IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED %
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE %
% ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY %
% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL %
% DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE %
% GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS %
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER %
% IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR %
% OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN %
% IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Contour}
\index{contour}
\index{.z file}
The contour block produces contour lines of a function $z = f(x,y)$.
The function $f(x,y)$ is given by a .z file. The .z file format is discussed on page~\pageref{zfile:pg}. Recall that a .z file can be created from sample data points, that is $(x,y,z)$ tuples, with the {\sf fitz} block (Section~\ref{fitz:sec}), or from an implicit definition of $f(x,y)$ with a {\sf letz} block (Section~\ref{letz:sec}).
\begin{minipage}[c]{8cm}
\begin{Verbatim}
include "contour.gle"
begin contour
data "saddle.z"
values 0.5 1 1.5 2 3
end contour
begin graph
title "Saddle Plot Contour Lines"
data "saddle-cdata.dat"
d1 line color blue
end graph
contour_labels "saddle-clabels.dat" "fix 1"
\end{Verbatim}
\end{minipage}
\hfill
\begin{minipage}[c]{7cm}
\ifdefined\APPLE
% surface countours cause seg fault on macOS
\else
\mbox{\input{utilities/fig/saddle-contour.inc}}
\fi
\end{minipage}
The contour block can contain the following commands:
\begin{commanddescription}
\item[{\sf data {\it file\$}}]\index{data} Specifies the name of the .z file.
\item[{\sf values $v_1,\ldots, v_n$}]\index{values} Specifies the z-values to contour at.
\item[{\sf values from $v_1$ to $v_n$ step $s$}] Specifies the z-values to contour at by means of from/to/step.
\item[{\sf smooth {\it integer}}]\index{smooth} Specifies the smoothing parameter.
\end{commanddescription}
The contour block creates the files ``data-clabels.dat'' and ``data-cdata.dat'' with the prefix ``data'' the name of the .z file. The file ``data-clabels.dat'' contains information for drawing labels on the contour plot. This is done by the subroutine {\sf contour\_labels} defined in the library ``contour.gle'' in the example above. The file ``data-cdata.dat'' contains the $(x,y)$ values of the contour lines. This file can be used as input to a graph block and plotted with the ``d1 line'' command as shown in the example above.
\section{Color Maps}
\label{colormap}
\index{colormap}
Color maps plot a function $z = f(x,y)$ by mapping $z$ to a color range. The following example combines a color map with a contour plot.
\begin{minipage}[c]{8cm}
\begin{Verbatim}
begin contour
data "volcano.z"
values from 130 to 190 step 10
end contour
begin graph
title "Auckland's Maunga Whau Volcano"
data "volcano-cdata.dat"
xaxis min 0 max 20
yaxis min 0 max 20
d1 line color black
colormap "volcano.z" 100 100
end graph
\end{Verbatim}
\end{minipage}
\hfill
\begin{minipage}[c]{7cm}
\ifdefined\APPLE
% surface countours cause seg fault on macOS
\else
\mbox{\input{utilities/fig/volcano.inc}}
\fi
\end{minipage}
The options to the colormap command are as follows:
\begin{commanddescription}
\item[{\sf colormap {\it fct} {\it pixels-x} {\it pixels-y} [color] [invert] [zmin $z_1$] [zmax $z_2$] [palette {\it pal}]}]
\mbox{}\\
\begin{itemize}
\item {\it fct} specifies the function to map. This can either be the name of a .z file, or it can be a function definition $f(x,y)$.
\item {\it pixels-x}, {\it pixels-x} specify the dimension of the color map. A color map is a stored as a bitmap image and ({\it pixels-x}, {\it pixels-x}) are the resolution of this bitmap. A larger resolution yields more detail, but at the cost of longer computation time and a larger file size.
\item {\it color} is an optional argument and indicates that the color map should be drawn in color (as opposed to grayscale).
\item {\it invert} is an optional argument that inverts the color map. That is, large function values will be drawn in black and small function values in white.
\item {\it zmin}, {\it zmax} are optional arguments that specify the range of the function.
\item {\it palette} is an optional argument that specifies the palette to use. A palette is a subroutine that maps $z$ values to colors. A number of example palette subroutines are included in the library ``color.gle''.
\end{itemize}
\end{commanddescription}
The following example is a color map of a two dimensional Gaussian.
\preglegraph{}
\begin{minipage}[c]{8cm}
\begin{Verbatim}
include "color.gle"
sub gauss x y
s = 0.75
return exp(-(x^2+y^2)/(2*s^2))
end sub
begin graph
title "2D Gaussian"
xaxis min -2 max 2
yaxis min -2 max 2
colormap gauss(x,y) 200 200 zmin 0 zmax 1 color
end graph
amove xg(xgmax)+0.3 yg(ygmin)
color_range_vertical zmin 0 zmax 1 zstep 0.1 format "fix 1"
\end{Verbatim}
\end{minipage}
\hfill
\begin{minipage}[c]{7cm}
\ifdefined\APPLE
% surface countours cause seg fault on macOS
\else
\mbox{\input{utilities/fig/gaussian.inc}}
\fi
\end{minipage}
\postglegraph{}
|