CCATSL provides a large number of routines for plotting
three-dimensional data. The simplest is
XYZCurveCL which
plots a sequence of points
. It can either
plot the points individually, or it can join up the points with
straight lines.
Surfaces can be plotted using the routine
XYZSurfaceCL,
or as a contour plot using the function
XYZContourCL. If the function
is easy to define in terms of
and
, you can use the simpler
routine
ContourCL, which
samples
appropriately. PolarContourCL
performs a similar function to XYZContourCL
for functions which are more naturally expressed in polar coordinates:
the data is now a collection of points
where
lie in a (rectangular) lattice.
For histograms with two independent variables, CCATSL provides the
routine XYZHistogramCL.
For some of these
routines, you may find it helpful to use
XYZSortCL to re-order the arrays storing the
,
and
-values so that the
and
-values are in increasing
order.
XYZCurveCL
| void XYZCurveCL ( |
double *xp, |
| double *yp, |
|
| double *zp, |
|
| int npts, |
|
| int ncols, |
|
| DrawDataCT option, |
|
| ColourCT colour, |
|
| AxisModeCT axismode); |
|
| xp |
Array holding the sequence
|
|
| yp |
Array holding the sequence
|
|
| zp |
Array holding the sequence
|
|
| npts |
The number of points in the sequence. | |
| ncols |
Normally ncols=1. (ncols is the size
of the second dimension in the declaration of the arrays
xp, yp and zp.) |
|
| option |
Specifies how the points should appear. Popular choices are JOIN,
to have the points joined up with straight lines or PLUS to have each point
marked with a +. You can find the full list of plot symbols
here. |
|
| colour |
The colour of the graph, such as RedCC for example. |
|
| axismode |
Determines whether CCATSL should try to work out
scales for the axes automatically. See the example below for the most common
usage (AUTOAXES), and
here
for further information. |
|
/* /examples/chapter3/ddata3.c */
#include <catam.h>
int MainCL(void)
{
double x[50];
double y[50];
double z[50];
int i;
for (i=0; i<50; i++) {
x[i]=i;
y[i]=sin(i/5.0);
z[i]=cos(i/5.0);
}
XYZCurveCL(x,y,z,50,1,PLUS,RedCC,AUTOAXES);
return 0;
}
|
XYZSurfaceCLXYZSurfaceCL produces surface or wireframe plots from
a collection of points of the form XYZContourCL.
| void XYZSurfaceCL ( |
double *xp, |
| double *yp, |
|
| double *zp, |
|
| int nx, |
|
| int ny, |
|
| int ncols, |
|
| int ncolsZ, |
|
| DrawObjectCT option, |
|
| ColourCT upper_col, |
|
| ColourCT lower_col, |
|
| AxisModeCT axismode); |
|
| xp |
Array holding the sequence of |
|
| yp |
Array holding the sequence of |
|
| zp |
Array holding the double zp[nx][ny].) |
|
| nx |
The number of |
|
| ny |
The number of |
|
| ncols |
Normally ncols=1. (ncols is the size of the second dimension
in the declaration of the arrays xp and yp.) |
|
| ncolsZ |
Normally ncolsZ=ny. (ncolsZ is the size of the second dimension
in the declaration of the array zp.) |
|
| option |
Can be either WIREFRAME for a wireframe plot or
SURFACE for a hidden line surface plot. |
|
| upper_col |
The colour for the upper side of the surface. | |
| lower_col |
The colour for the lower side of the surface. | |
| axismode |
Determines whether CCATSL should try to work out
scales for the axes automatically. See the example below for the most
common usage (AUTOAXES), and
here
for further information. |
|
/* /examples/chapter3/surface.c */
#include <catam.h>
int MainCL(void)
{
double x[50];
double y[50];
double z[50][50];
int i;
int j;
for (i=0; i<50; i++) {
x[i]=i;
y[i]=i;
for (j=0; j<50; j++) {
z[i][j]=sin(i/20.0)*sin(i/20.0)*cos(j/5.0);
}
}
XYZSurfaceCL(x,y,z,50,50,1,50,SURFACE,
BlueCC,RedCC,AUTOAXES);
return 0;
}
|
XYZContourCLXYZContourCL produces contour plots from a collection of points of the
form
| void XYZContourCL ( |
double *xp, |
| double *yp, |
|
| double *zp, |
|
| int nx, |
|
| int ny, |
|
| int ncols, |
|
| int ncolsZ, |
|
| int ncontours, |
|
| double zlow, |
|
| double zhi, |
|
| DrawObjectCT option, |
|
| ColourCT colour, |
|
| AxisModeCT axismode); |
|
| xp |
Array holding the sequence of |
|
| yp |
Array holding the sequence of |
|
| zp |
Array holding the double zp[nx][ny].) |
|
| nx |
The number of |
|
| ny |
The number of |
|
| ncols |
Normally ncols=1. (ncols is the size of the second dimension
in the declaration of the arrays xp and yp.) |
|
| ncolsZ |
Normally ncolsZ=ny. (ncolsZ is the size of the second dimension
in the declaration of the array zp.) |
|
| ncontours |
Specifies the number of contours to be drawn. | |
| zlow, zhi |
Specify the range [zlow,zhi] of XYZContourCL will try to work out a suitable
range. |
|
| option |
Either CONTOURS2D or CONTOURS3D. The first case leads to a
flat `map' with contours, the other leads to three-dimensional contour plot. |
|
| colour |
The colour for the contours. | |
| axismode |
Determines whether CCATSL should try to work out
scales for the axes automatically. See the example below for the most
common usage (AUTOAXES), and
here
for more information. |
|
/* /examples/chapter3/contour.c */
#include <catam.h>
int MainCL(void)
{
double x[50];
double y[50];
double z[50][50];
int i;
int j;
for (i=0; i<50; i++) {
x[i]=i;
y[i]=i;
for (j=0; j<50; j++) {
z[i][j]=sin(i/10.0)*cos(j/6.0)+i*j/800.0;
}
}
XYZContourCL(x,y,z,50,50,1,50,25,0,0,CONTOURS2D,
RedCC,AUTOAXES);
return 0;
}
|
ContourCLXYZContourCL of producing contour plots of a
function
| void ContourCL ( |
double (*g)(double x, double y), |
| double xlow, |
|
| double xhi, |
|
| double ylow, |
|
| double yhi, |
|
| double zlow, |
|
| double zhi, |
|
| int ncontours, |
|
| int gtype, |
|
| ColourCT colour, |
|
| AxisModeCT axismode); |
|
| g |
A user-defined function taking two
double arguments and returning a double.
The function should interpret the arguments as |
|
| xlow, xhi |
The range [xlow, xhi] of |
|
| ylow, yhi |
The range [ylow, yhi] of |
|
| zlow, zhi |
The range [zlow, zhi] of |
|
| ncontours |
The number of contours to plot. | |
| gtype |
Specifies the type of contour plot: gtype=0 produces monochrome
contour lines of colour colour, gtype=1 produces contour lines
of different colours, gtype=2 shades the regions between contour lines,
and gtype=3 draws the contour lines in colour and shades
the region between contour lines. |
|
| colour |
The colour of the contours. | |
| axismode |
Determines whether CCATSL should try to work out
scales for the axes automatically. See the example below for the most
common usage (AUTOAXES), and
here
for further information. |
|
/* /examples/chapter3/fncont.c */
#include <catam.h>
double f(double x, double y)
{
return sin(2*M_PI*x)*cos(M_PI*y)+2*x*y;
}
int MainCL(void)
{
ContourCL(f,-2,2,-2,2,-3,5,50,3,RedCC,AUTOAXES);
return 0;
}
|
PolarContourCLPolarContourCL produces contour plots from a collection of points of the
form
| void PolarContourCL ( |
double *rp, |
| double *tp, |
|
| double *zp, |
|
| int ncolsZ, |
|
| int nr, |
|
| int ntheta, |
|
| double zlow, |
|
| double zhi, |
|
| int ncontours, |
|
| int gtype, |
|
| ColourCT colour, |
|
| AxisModeCT axismode); |
|
| rp |
Array holding the sequence of |
|
| tp |
Array holding the sequence of |
|
| zp |
Array holding the double zp[nx][ny].) |
|
| ncolsZ |
Normally ncolsZ=ntheta. (ncolsZ is the
size of the second dimension in the declaration of the array zp.) |
|
| nr |
The number of |
|
| ntheta |
The number of |
|
| zlow, zhi |
The range [zlow, zhi] of |
|
| ncontours |
Specifies the number of contours to draw. | |
| gtype |
Specifies the type of contour plot: gtype=0 produces monochrome
contour lines of colour colour, gtype=1 produces contour lines
of different colours, gtype=2 shades the regions between contour lines,
and gtype=3 draws the contour lines in colour and shades
the region between contour lines. |
|
| colour |
The colour for the contours. | |
| axismode |
Determines whether CCATSL should try to work out
scales for the axes automatically. See the example below for the most
common usage (AUTOAXES), and
here
for further information. |
|
/* /examples/chapter3/polcont.c */
#include <catam.h>
int MainCL(void)
{
double r[50];
double theta[50];
double z[50][50];
int i;
int j;
for (i=0; i<50; i++) {
r[i]=i/50.0;
for (j=0; j<50; j++) {
theta[j]=2*M_PI*j/50.0;
z[i][j]=r[i]*sin(3*theta[j]);
}
}
PolarContourCL(r,theta,z,50,50,50,0,0,15,0,
RedCC,AUTOAXES);
return 0;
}
|
XYZHistogramCL
| void XYZHistogramCL ( |
double *xp, |
| double *yp, |
|
| double *zp, |
|
| int nx, |
|
| int ny, |
|
| int nz, |
|
| int ncols, |
|
| int ncolsZ, |
|
| double xwidth, |
|
| double ywidth, |
|
| ColourCT colour, |
|
| AxisModeCT axismode); |
|
| xp |
Array holding the sequence of |
|
| yp |
Array holding the sequence of |
|
| zp |
Array holding double zp[nx][ny].) |
|
| nx |
The number of |
|
| ny |
The number of |
|
| ncols |
Normally ncols=1. (ncols is the size of the second dimension
in the declaration of the arrays xp and yp.) |
|
| ncolsZ |
Normally ncolsZ=ny. (ncolsZ is the size of the second dimension
in the declaration of the array zp.) |
|
| xwidth |
The |
|
| ywidth |
The |
|
| colour |
The colour for the bars. | |
| axismode |
Determines whether CCATSL should try to work out scales for the axes automatically. See the example below for the most common usage, and here for more information. |
|
/* /examples/chapter3/histo3d.c */
#include <catam.h>
int MainCL(void)
{
double x[10];
double y[10];
double z[10][10];
int i;
int j;
for (i=0; i<10; i++) {
x[i]=i;
y[i]=i;
for (j=0; j<10; j++) {
z[i][j]=exp(-(i+j)/3.0);
}
}
XYZHistogramCL(x,y,z,10,10,1,10,0.8,0.8,
YellowCC,AUTOAXES);
return 0;
}
|