[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. MathGL core

The core of MathGL is mglGraph class defined in #include <mgl/mgl.h>. It contains a lot of plotting functions for 1D, 2D and 3D plots. It also encapsulates parameters for axes drawing. Moreover an arbitrary coordinate transformation may be used for each axis. All plotting functions use data encapsulated in mglData class (see section mglData class) that allows to check sizes of used arrays easily. Also it have many functions for data handling: modify it by formulas, find momentums and distribution (histogram), apply operator (differentiate, integrate, transpose, Fourier and so on), change data sizes (interpolate, squeeze, crop and so on). Additional information about colors, fonts, formula parsing can be found in Other classes.

Note that class mglGraph is abstract and contains only interface functions for plotting but does not make plot by itself. For plotting in specific device (screen, memory or file) one should use derived classes: mglGraphZB – for bitmap picture in file or in memory; mglGraphPS – for vector PostScript picture; mglGraphGL – for drawing using OpenGL, or for GLUT windows interface; and so on, see section Plotter classes. If you want not only to create a picture but to view it in a window/widget or to run animation and so on then look at Widget classes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Graphics setup

Functions and variables in this group influences on overall graphics appearance. So all of them should be placed before any actual plotting function calls.

Method on mglGraph: void DefaultPlotParam ()

Restore initial values for all of parameters except described in Zooming.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.1 Transparency

There are several functions and variables for setup transparency. The general function is Alpha() which switch on/off the transparency for overall plot. It influence only for graphics which created after Alpha() call (with one exception, mglGraphGL). Variable AlphaDef specify the default value of alpha-channel. You may switch off transparency of selected plot by variable Transparent. Finally, variable TranspType set the kind of transparency. See section Transparent surface sample, for sample code and picture.

Method on mglGraph: bool Alpha (bool enable)

Sets the transparency on/off. It is recommended to call this function before any plotting command. Function returns previous value of transparency. In any case it must be called before Finish() function if the last is used. Default value is transparency off. Unfortunately it switches the transparency on/off for all subplots. Use Transparent = false in particular plot to disable its transparency.

General option of mglGraph: float AlphaDef

Default value of alpha channel (transparency) for all plotting functions. Note, that OpenGL (mglGraphGL) has incorrect drawing for large values of alpha in case of several overlapping surfaces.

General option of mglGraph: bool Transparent

Flag which temporary switches transparency on/off for the plot.

General option of mglGraph: int TranspType

This variable set the transparency type. Normal transparency (‘0’) – below things is less visible than upper ones. It does not look well in OpenGL mode (mglGraphGL) for several surfaces. Glass-like transparency (‘1’) – below and upper things are commutable and just decrease intensity of light by RGB channel. Lamp-like transparency (‘2’) – below and upper things are commutable and are the source of some additional light. I recommend to set AlphaDef = 0.3 or less for lamp-like transparency.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.2 Lighting

There are several functions for setup lighting. The general function is Light(bool) which switch on/off the lighting for overall plot. It influence only for graphics which created after Light() call (with one exception, mglGraphGL). Generally MathGL support up to 10 independent light sources. But in OpenGL mode only 8 of light sources is used due to OpenGL limitations. The position, color, brightness of each light source can be set separately. By default only one light source is active. It is source number 0 with white color, located at top of the plot.

Method on mglGraph: bool Light (bool enable)

Sets the using of light on/off for overall plot. It is recommended to call this function before any plotting command. Function returns previous value of lighting. Default value is lightning off.

Method on mglGraph: void Light (int n, bool enable)

Switch on/off n-th light source separately.

Method on mglGraph: void Light (int n, mglPoint p, mglColor c, float bright=0.5, bool infty=true)
Method on mglGraph: void Light (int n, mglPoint p, char c='w', float bright=0.5, bool infty=true)

The function adds a light source with identification n at position p. The color of light is c (white by default). The brightness of light is bright which must be in range [0,1]. Flag infty=true puts the source to infinite distance (for the faster drawing). It is recommended to call this function before any plotting command.

Method on mglGraph: void Ambient (float bright=0.5)

Sets the brightness of ambient light. The value should be in range [0,1]. It is recommended to call this function before any plotting command.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.3 Fog

Method on mglGraph: void Fog (float d, float dz=0.25)

Function imitate a fog in the plot. Fog start from relative distance dz from view point and its density growths exponentially in depth. So that the fog influence is determined by law ~ 1-exp(-d*z). Here z is normalized to 1 depth of the plot. If value d=0 then the fog is absent. See section Surface in fog sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.4 Default sizes

These variables control the default (initial) values for most graphics parameters including sizes of markers, arrows, linewidth and so on. As any other settings these ones will influence only on plots created after the settings change.

Method on mglGraph: void SetTickLen (float val, float stt=1)

The relative length of axis ticks. Default value is 0.1. Parameter stt>0 set relative length of subticks which is in sqrt(1+stt) times smaller.

Method on mglGraph: void SetTickStl (const char *stl, const char *sub)

The line style of axis ticks (stl) and subticks (sub). If stl is empty then default style is used (‘k’ or ‘w’ depending on transparency type). If sub is empty then ticks style is used (i.e. stl).

General option of mglGraph: float BarWidth

Relative width of rectangles in Bars plot (see section Bars). Default value is 0.7.

General option of mglGraph: float MarkSize

The size of marks for 1D plotting. Default value is 0.02.

General option of mglGraph: float ArrowSize

The size of arrows for 1D plotting, lines and curves (see section Primitives drawing). Default value is 0.03.

General option of mglGraph: float BaseLineWidth

The variable define the base width for all lines. The value <1 is ignored. For values > 1 the real line width is result of multiplication of specified line width and the value of BaseLineWidth. Increase of this variables is actual for large bitmap pictures. Default value is 1.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.5 Zooming

These variables and functions control the overall zooming of the picture (see Zoom()) or the sub-picture (see PlotFactor). Normally you can use these variables and functions for removing “white” spaces around a plot.

General option of mglGraph: float PlotFactor

The factor of plot size. It is not recommended to set it lower then 1.6. This is some analogue of function Zoom() but applied not to overall image but for each InPlot (see section Transformation matrix).

General option of mglGraph: bool AutoPlotFactor

Switch on/off automatic change of PlotFactor variable during plot rotation.

Method on mglGraph: void Zoom (float x1, float y1, float x2, float y2)

The function changes the scale of graphics that correspond to zoom in/out of the picture. After function call the current plot will be cleared and further the picture will contain plotting from its part [x1,x2]*[y1,y2]. Here picture coordinates x1, x2, y1, y2 changes from 0 to 1. Attention! this settings can not be overwritten by any other functions. Use Zoom(0,0,1,1) to return default view.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.6 Cutting

These variables and functions set the condition when the points are excluded (cutted) from the drawing.

General option of mglGraph: bool Cut

Flag which determines how points outside bounding box are drawn. If it is true then points are excluded from plot (it is default) otherwise the points are projected to edges of bounding box.

png_static/cut

Left figure is drawn with parameter Cut=false. Right one is drawn with parameter Cut=true

General option of mglGraph: mglPoint CutMin, CutMax

Lower and upper edge of the box in which never points are drawn. If both edges are the same (the variables are equal) then the cutting box is empty. See section CutMinMax sample, for sample code and picture.

General option of mglGraph: mglFormula * fc

Formula for condition of point cutting. The point will be omitted (“cut”) if function return non-zero value for point coordinates. This variable is obsolete – use CutOff() function instead.

Method on mglGraph: void CutOff (const char *EqC)

Sets the cutting off condition by formula EqC. This condition determine will point be plotted or not. If value of formula is nonzero then point is omitted, otherwise it plotted. Set argument as NULL to disable cutting off condition. See section CutOff sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.7 Font settings

General option of mglGraph: float FontSize

The size of font for tick and axis labels. Default font size of axis labels is 1.4 times large than for tick labels.

General option of mglGraph: char FontDef[32]

Font specification (see section Text printing). Default is “rC” – Roman font centering.

General option of mglGraph: bool RotatedText

Set to use or not text rotation along axis.

Method on mglGraph: void SetFontSizePT (float cm, int dpi=72)

Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72).

Method on mglGraph: inline void SetFontSizeCM (float cm, int dpi=72)

Set FontSize by size in centimeters and picture DPI (default is 0.56 cm = 16 pt).

Method on mglGraph: inline void SetFontSizeIN (float cm, int dpi=72)

Set FontSize by size in inch and picture DPI (default is 0.22 in = 16 pt).

Method on mglGraph: void SetFont (mglFont *f)

Sets font typeface. Note that each mglFont instance can be used with ONLY ONE mglGraph instance at a moment of time! If f==NULL then default font is used.

Method on mglGraph: inline mglFont * GetFont ()

Gets current typeface. Note that this variable can be deleted at next SetFont() call!


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.8 Pallete and colors

Method on mglGraph: void SetPalette (const char *colors)

Sets the palette as selected colors. Default value is "Hbgrcmyhlnqeup" that corresponds to colors: dark gray ‘H’, blue ‘b’, green ‘g’, red ‘r’, cyan ‘c’, magenta ‘m’, yellow ‘y’, gray ‘h’, blue-green ‘l’, sky-blue ‘n’, orange ‘q’, yellow-green ‘e’, blue-violet ‘u’, purple ‘p’. The palette is used mostly in 1D plots (see section 1D plotting) for curves which styles are not specified.

General option of mglGraph: mglColor Pal[101]

Color palette for 1D plotting. This variable is obsolete – use SetPalette() function instead.

General option of mglGraph: int NumPal

Number of actual colors in palette. The value must be less then 100. This variable is obsolete – use SetPalette() function instead.

Method on mglGraph: void SetScheme (const char *sch)

Set the color scheme for following plots. Usually this function is used internally. See section Color scheme.

Method on mglGraph: void SelectPen (const char *sch)

Set the line and mark styles for following plots. Usually this function is used internally. See section Line styles.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.9 Error handling

There are 2 variables which indicate the warnings/errors presence during plot creation. Normally user should set it to zero by SetWarn(0); before plotting and check if WarnCode is not zero after plotting. Note that only last warning will be saved.

General option of mglGraph: char * Message

Pointer to buffer for writing messages about matters why some plot are not drawn. Set to NULL to disable messages. The buffer length must be at least 1024. If Message[0]==0 then there are no messages

General option of mglGraph: int WarnCode

Numerical ID of warning about the not drawn plot. Possible values are:

mglWarnNone=0

Everything OK

mglWarnDim

Data dimension(s) is incompatible

mglWarnLow

Data dimension(s) is too small

mglWarnNeg

Minimal data value is negative

mglWarnFile

No file or wrong data dimensions

mglWarnMem

Not enough memory

mglWarnZero

Data values are zero

mglWarnLegA

Too many legend entries

mglWarnLeg

No legend entries

mglWarnSlc

Slice value is out of range

mglWarnCnt

Number of contours is zero or negative

mglWarnOpen

Couldn’t open file

mglWarnLId

Light: ID is out of range

mglWarnSize

Setsize: size(s) is zero or negative

mglWarnFmt

Format is not supported for that build

mglWarnEnd

Maximal number of warnings (must be last)

Method on mglGraph: void SetWarn (int code, const char *who="")

Set warning code and corresponding message from function who. Normally you should call this function only for clearing the warning state, i.e. call SetWarn(0);.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.10 Other settings

General option of mglGraph: int MeshNum

Sets approximate number of lines in Mesh(), Fall(), Grid() and also the number of hachures in Vect(), VectC(), Dew() and the number of cells in Cloud*(). By default (=0) it draws all lines/hachures/cells.

General option of mglGraph: char AxialDir

Set direction around which curve rotated in Axial() and Torus(). Default value is ’z’.

General option of mglGraph: bool DrawFace

If set to true then it prevent faces drawing. It is useful for speeding up drawing (for example, during rotation and so on).

General option of mglGraph: int CirclePnts

Number of points used for a circle approximation (for example, in Primitives drawing, Tube, Pipe and so on). Default value is 40.

General option of mglGraph: const char * PlotId

Id of plot for saving filename (in GLUT window for example).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Axis settings

These large set of variables and functions control how the axis and ticks will be drawn. Note that there is 3-step transformation of data coordinates are performed. Firstly, coordinates are projected if Cut=true (see section Cutting), after it transformation formulas are applied, and finally the data was normalized in bounding box.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.1 Ranges (bounding box)

Method on mglGraph: void Axis (mglPoint min, mglPoint max, mglPoint org=mglPoint(NAN,NAN,NAN))

Safely sets the value for Min, Max and Org members (options) of the class. If minimal and maximal values of the coordinate are the same then they are ignored. This function also sets Cmin=Min.z and Cmax=Max.z. This is default color range for 2d plots.

Method on mglGraph: void SetRanges (float x1, float x2, float y1, float y2, float z1=0, float z2=0)

Sets maximal and minimal values for coordinate range (bounding box). If minimal and maximal values of the coordinate are the same then they are ignored. This function also sets Cmin=Min.z and Cmax=Max.z. This is default color range for 2d plots.

Method on mglGraph: void CAxis (float min, float max)

Safely sets the values of Cmin and Cmax. This values are used later for determining the color of the surface.

Method on mglGraph: void XRange (const mglData & dat, bool add=false, float fact=0)

Sets values of Min.x and Max.x as minimal and maximal values of data a. Parameter fact add additional range increase on value (Max-Min)*fact. See also Axis().

Method on mglGraph: void YRange (const mglData & dat, bool add=false, float fact=0)

Sets values of Min.y and Max.y as minimal and maximal values of data a. Parameter fact add additional range increase on value (Max-Min)*fact. See also Axis().

Method on mglGraph: void ZRange (const mglData & dat, bool add=false, float fact=0)

Sets values of Min.z and Max.z as minimal and maximal values of data a. Parameter fact add additional range increase on value (Max-Min)*fact. See also Axis().

Method on mglGraph: void CRange (const mglData & dat, bool add=false, float fact=0)

Sets values of Cmin and Cmax as minimal and maximal values of data a. Parameter fact add additional range increase on value (Cmax-Cmin)*fact. See also CAxis().

Method on mglGraph: void RecalcBorder ()

Recalculates internal parameter for correct apply of transformation rules. Must be called after any direct change of members Min, Max, fx, fy, fz if its changes should be seen on the plot.

Method on mglGraph: void SetAutoRanges (float x1, float x2, float y1=0, float y2=0, float z1=0, float z2=0)

Sets ranges for automatic variables of plots. It act as changing of Min, Max proprties without calling of RecalcBorder(). Function don’t change the direction if minimal and maximal values are the same. For example, if yy1=y2 then ranges along y-direction will not be changed (will be used previous one). Note that the automatic range become axis range after next call of [XYZ]Range() function(s).

General option of mglGraph: mglPoint Min, Max

Lower and upper edges of bounding box for graphics. These variables are used for determining the range of automatic (non-specified) arrays in most of plotting functions. So, you may change it before plot and return it back after it and the plot will have automatic x-(y-,z-)coordinate normalized in this range but not in bounding box. BUT if you want to change the bounding box then you must call RecalcBorder(); after it or use Axis() function.

General option of mglGraph: float Cmin, Cmax

Minimal and maximal value for data (used for coloring).

General option of mglGraph: mglPoint Org

Center of axis cross section. If one of values is NAN then MathGL library try to select optimal axis position.

General option of mglGraph: bool AutoOrg

Flag for automatic shifting of axes origin Org if it lies out of range Min ... Max.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.2 Transformation (curved coordinates)

Method on mglGraph: void Axis (const char *EqX, const char *EqY, const char *EqZ)

Safely sets transformation formulas for curvilinear coordinate. Each string should contain mathematical expression for real coordinate depending on internal coordinates x, y, z. For example, the cylindrical coordinates are introduced as Axis("x*cos(y)", "x*sin(y)", "z");. For removing of formulas the corresponding parameter should be NULL. Using transformation formulas will slightly slowing the program, i.e. Axis(NULL, NULL, NULL) is faster than Axis("x", "y", "z"). See section mglFormula class.

Method on mglGraph: void Axis (int how)

Sets one of the predefined transformation formulas for curvilinear coordinate. Paramater how define the coordinates: mglCartesian=0 – Cartesian coordinates (no transformation); mglPolar=1 – Polar coordiantes x_n=x*cos(y),y_n=x*sin(y), z_n=z; mglSpherical=2 – Sperical coordinates x_n=x*sin(y)*cos(z), y_n=x*sin(y)*sin(z), z_n=x*cos(y); mglParabolic=3 – Parabolic coordinates x_n=x*y, y_n=(x*x-y*y)/2, z_n=z; mglParaboloidal=4 – Paraboloidal coordinates x_n=(x*x-y*y)*cos(z)/2, y_n=(x*x-y*y)*sin(z)/2, z_n=x*y; mglOblate=5 – Oblate coordinates x_n=cosh(x)*cos(y)*cos(z), y_n=cosh(x)*cos(y)*sin(z), z_n=sinh(x)*sin(y); mglProlate=6 – Prolate coordinates x_n=sinh(x)*sin(y)*cos(z), y_n=sinh(x)*sin(y)*sin(z), z_n=cosh(x)*cos(y); mglElliptic=7 – Elliptic coordinates x_n=cosh(x)*cos(y), y_n=sinh(x)*sin(y), z_n=z; mglToroidal=8 – Toroidal coordinates x_n=sinh(x)*cos(z)/(cosh(x)-cos(y)), y_n=sinh(x)*sin(z)/(cosh(x)-cos(y)), z_n=sin(y)/(cosh(x)-cos(y)); mglBispherical=9 – Bispherical coordinates x_n=sin(y)*cos(z)/(cosh(x)-cos(y)), y_n=sin(y)*sin(z)/(cosh(x)-cos(y)), z_n=sinh(x)/(cosh(x)-cos(y)); mglBipolar=10 – Bipolar coordinates x_n=sinh(x)/(cosh(x)-cos(y)), y_n=sin(y)/(cosh(x)-cos(y)), z_n=z.

Method on mglGraph: void Ternary (bool tern)

The function sets to draws Ternary plot. This special plot is for 3 dependent coordinates (components) a, b, c so that a+b+c=1. MathGL uses only 2 independent coordinates a=x and b=y since it is enough to plot everything. At this third coordinate z act as another parameter to produce contour lines, surfaces and so on. See section Ternary plot sample, for sample code and picture.

General option of mglGraph: mglFormula *fx, *fy, *fz

Transformation formula for x, y and z directions. These variables are obsolete – use Axis() function instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2.3 Ticks

Method on mglGraph: void AdjustTicks (const char *dir)

Set the ticks step, number of sub-ticks and initial ticks position to be the most human readable for the axis along direction(s) dir. Also set TuneTicks=true.

Method on mglGraph: void SetTicks (char dir, float d=-5, int ns=0, float org=NAN)

Set the ticks step d, number of sub-ticks ns and initial ticks position org for the axis along direction dir. Variable d set step for axis ticks (if positive) or it’s number on the axis range (if negative). Zero value set logarithmic ticks. If org value is NAN then value from Org is used.

Method on mglGraph: void SetTicksVal (char dir, int n, float *val, const char **lbl)
Method on mglGraph: void SetTicksVal (char dir, int n, float *val, const wchar_t **lbl)
Method on mglGraph: void SetTicksVal (char dir, float val1, wchar_t *lbl1, ...)

Set the manual positions val and its labels lbl for n-th ticks along axis dir. The arrays val and lbl must contain n elements. Use SetTicks() to restore automatic ticks. Note, you have to be very careful to use floating-point (not integer!!!) values as ticks position due to limitations of stdarg library (argument transfer). See section Tick values sample, for sample code and picture.

General option of mglGraph: float dx, dy, dz

Step for axis ticks (if positive) or it’s number (if negative) in x-,y-,z- directions. Zero value set logarithmic ticks. These variables are obsolete – use SetTicks() function instead.

General option of mglGraph: int NSx, NSy, NSz

Number of axis sub-ticks in x-,y-,z- directions. These variables are obsolete – use SetTicks() function instead.

General option of mglGraph: mglPoint OrgT

Starting point for ticks. If corresponding value is NAN then value from Org is used (it is default).

General option of mglGraph: const wchar_t *xtt, *ytt, *ztt, *ctt

The template for x-,y-,z-axis ticks or colorbar ticks. It may contain TeX symbols also. If xtt, ytt, ztt, ctt=NULL then default template is used (in simplest case it is ‘%.2g’) with automatic detaching of common multiplier or common component (see TuneTicks).

General option of mglGraph: bool TuneTicks

Switch on/off ticks enhancing by factoring common multiplier (for small, like from 0.001 to 0.002, or large, like from 1000 to 2000, coordinate values) or common component (for narrow range, like from 0.999 to 1.000).

General option of mglGraph: float FactorPos

The position of common multiplier/component on the axis: =0 at minimal axis value, =1 at maximal axis value. Default value is 1.15.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Transformation matrix

These functions control how and where further plotting will be placed. There is a curtain order of calling of these functions for the better plot view. First one should be SubPlot() or InPlot() for specifying the place. After it a Rotate() and Aspect(). And finally any other plotting functions may be called. Alternatevely you can use ColumnPlot() for position plots in the column one by another without gap between plot axis (bounding boxes).

Method on mglGraph: void SubPlot (int nx, int ny, int m, float dx=0, float dy=0)

Puts further plotting in a m-th cell of nx*ny grid of the whole frame area. This function set off any aspects or rotations. So it should be used first for creating the subplot. From the aesthetical point of view it is not recommended to use this function with different matrices in the same frame. The position of the cell can be shifted from its default position by relative size dx, dy.

Method on mglGraph: void InPlot (float x1, float x2, float y1, float y2, bool rel=false)

Puts further plotting in some region of the whole frame surface. This function allows one to create a plot in arbitrary place of the screen. The position is defined by rectangular coordinates [x1, x2]*[y1, y2]. The coordinates x1, x2, y1, y2 are normalized to interval [0, 1]. If parameter rel=true then the relative position to current SubPlot() (or last InPlot() with rel=false) is used. This function set off any aspects or rotations. So it should be used first for creating subplot.

Method on mglGraph: void ColumnPlot (int num, int ind)

Puts further plotting in ind-th cell of column with num cells. The position is relative to previous SubPlot() call (or InPlot() with rel=false).

Method on mglGraph: void Rotate (float TetX, float TetZ, float TetY=0)

Rotates a further plotting relative to each axis (x, z, y) consecutively on angles TetX, TetZ, TetY.

Method on mglGraph: void RotateN (float Tet, float x, float y, float z)

Rotates a further plotting around vector {x,y,z}.

Method on mglGraph: void Aspect (float Ax, float Ay, float Az)

Defines aspect ratio for the plot. The viewable axes will be related one to another as the ratio Ax:Ay:Az. For the best effect it should be used after Rotate() function.

Method on mglGraph: void Perspective (float a)

Add (switch on) the perspective to plot. The parameter a ~ 1/z_eff \in [0,1). By default (a=0) the perspective is off.

Method on mglGraph: void Identity ()

Clears transformation matrix. This function clears all previous effects of Aspect(), SubPlot(), InPlot() or Rotate() functions. It is equivalent to the call of InPlot(0,1,0,1).

Method on mglGraph: void RestoreM ()

Restore transformation matrix after last InPlot(). This function clears all previous effects of Aspect(), SubPlot(), InPlot() or Rotate() functions. It is useful to restore back the transformation matrix after Identity() call.

Method on mglGraph: void View (float tetx, float tetz, float tety= 0)

Sets angle of view independently from Rotate() but usually don’t rotate actually.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4 Export to file

These functions export current view to a graphic file. The filename fname should have appropriate extension. Parameter descr gives the short description of the picture. Just now the transparency is supported in PNG and SVG files.

Method on mglGraph: void WriteFrame (const char *fname=NULL, const char *descr=NULL)

Exports current frame to a file fname which type is determined by the extension. Parameter descr adds description to file (can be NULL). If fname=NULL then the file ‘frame####.jpg’ is used, where ‘####’ is current frame id and name ‘frame’ is defined by PlotId class property.

Method on mglGraph: void WritePNG (const char *fname, const char *descr=NULL, int compr=NULL, bool alpha=true)

Exports current frame to PNG file. Parameter fname specifies the file name, descr adds description to file, alpha gives the transparency type. By default there are no description added and transparent image used. This function does nothing if NO_PNG is defined during compilation of MathGL library.

Method on mglGraph: void WriteJPEG (const char *fname, const char *descr=NULL)

Exports current frame to JPEG file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. This function does nothing if NO_JPEG is defined during compilation of MathGL library.

Method on mglGraph: void WriteGIF (const char *fname, const char *descr=NULL)

Exports current frame to GIF file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added.

Method on mglGraph: void WriteBMP (const char *fname, const char *descr=NULL)

Exports current frame to BMP file. Parameter fname specifies the file name, descr adds description to file. There is no compression used.

Method on mglGraph: void WriteEPS (const char *fname, const char *descr=NULL)

Exports current frame to EPS file. The vector representation is used if possible. So it is not recommended for the export of large data plot. It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added.

Method on mglGraph: void WriteSVG (const char *fname, const char *descr=NULL)

Exports current frame to SVG (Scalable Vector Graphics) file. The vector representation is used. In difference of EPS format, SVG format support transparency that allows to correctly draw half-transparent plot (like SurfA(), Surf3A(), CloudQ() or CloudP()). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).

Method on mglGraph: void WriteIDTF (const char *fname, const char *descr=NULL)

Exports current frame to IDTF file. Later this file can be converted to U3D format. The vector representation is used. So, the output file may be too large for graphic of large data array (especially for surfaces). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).

Method on mglGraph: void ShowImage (const char *viewer="kuickshow", bool nowait=false)

Displays the current picture using external program viewer for viewing. The function save the picture to temporary file and call viewer to display it. If nowait=true then the function return immediately (it will not wait while window will be closed).

Method on mglGraph: void SetSize (int width, int height)

Sets size of picture in pixels. This function must be called before any other plotting because it completely remove picture contents.

Method on mglGraph: void Finish ()

Finishes plotting and create a picture. Normally this function is called internally.

Method on mglGraph: void Flush ()

Flushes the plotting commands to frame. This function may be useful if one wants to remove array before the finishing of the plot (i.e. before calling Finish()). Also call of this function separate the objects in mglGraphIDTF. Most of plots call this function internally.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5 Primitives drawing

These functions draw some simple objects like line, point, sphere, drop, cone and so on.

Method on mglGraph: void Clf (mglColor Back=WC)

Clear the picture and will it by color Back.

Method on mglGraph: void Ball (float x, float y, float z, mglColor col=RC, float alpha=1)

Draws a point (ball) at position {x, y, z} with color col.

Method on mglGraph: void Ball (mglPoint p, char col='r')

Draws a point (ball) at position p with color col.

Method on mglGraph: void Error (mglPoint p, mglPoint e, char *pen=NULL)

Draws a 3d error box at position p with sizes e and style pen.

Method on mglGraph: void Line (mglPoint p1, mglPoint p2, char *stl="B", intnum=2)

Draws a geodesic line (straight line in Cartesian coordinates) from point p1 to p2 using line style stl. Parameter num define the “quality” of the line. If num=2 then the stright line will be drawn in all coordinate system (independently on transformation formulas (see section Transformation (curved coordinates)). Contrary, for large values (for example, =100) the geodesic line will be drawn in corresponding coordinate system (straight line in Cartesian coordinates, circle in polar coordinates and so on). Line will be drawn even if it lies out of bounding box.

Method on mglGraph: void Curve (mglPoint p1, mglPoint d1, mglPoint p2, mglPoint d2, const char *stl="B", int num=100)

Draws Bezier-like curve from point p1 to p2 using line style stl. At this tangent is codirected with d1, d2 and proportional to its amplitude. Parameter num define the “quality” of the curve. If num=2 then the straight line will be drawn in all coordinate system (independently on transformation formulas (see section Transformation (curved coordinates)). Contrary, for large values (for example, =100) the spline like Bezier curve will be drawn in corresponding coordinate system. Curve will be drawn even if it lies out of bounding box.

Method on mglGraph: void Face (mglPoint p1, mglPoint p2, mglPoint p3, mglPoint p4, const char *stl="w", int num=2)

Draws the solid quadrangle (face) with vertexes p1, p2, p3, p4 and with color(s) stl. At this colors can be the same for all vertexes or different if all 4 colors are specified for each vertex. Face will be drawn even if it lies out of bounding box.

Method on mglGraph: void FaceX (float x0, float y0, float z0, float wy, float wz, const char *stl="w", float dx=0, float dy=0)

Draws the solid rectangle (face) perpendicular to x-axis at position {x0, y0, z0} with widths wy, wz and with color stl. At this colors can be the same for all vertexes or different if all 4 colors are specified for each vertex. Parameters d1, d2 set additional shift of the last vertex (i.e. to draw quadrangle). Face will be drawn even if it lies out of bounding box.

Method on mglGraph: void FaceY (float x0, float y0, float z0, float wx, float wz, const char *stl="w", float dx=0, float dy=0)

Draws the solid rectangle (face) perpendicular to y-axis at position {x0, y0, z0} with widths wx, wz and with color stl. At this colors can be the same for all vertexes or different if all 4 colors are specified for each vertex. Parameters d1, d2 set additional shift of the last vertex (i.e. to draw quadrangle). Face will be drawn even if it lies out of bounding box.

Method on mglGraph: void FaceZ (float x0, float y0, float z0, float wx, float wy, const char *stl="w", float dx=0, float dy=0)

Draws the solid rectangle (face) perpendicular to z-axis at position {x0, y0, z0} with widths wx, wy and with color stl. At this colors can be the same for all vertexes or different if all 4 colors are specified for each vertex. Parameters d1, d2 set additional shift of the last vertex (i.e. to draw quadrangle). Face will be drawn even if it lies out of bounding box.

Method on mglGraph: void Sphere (mglPoint p, float r, const char *stl="r")

Draw the sphere with radius r and center at point p and color stl.

Method on mglGraph: void Drop (mglPoint p, mglPoint q, float r, mglColor col, float shift=1, float ap=1)
Method on mglGraph: void Drop (mglPoint p, mglPoint q, float r, const char *col="r", float shift=1, float ap=1)

Draw the drop with radius r at point p elongated in direction q and with color col. Parameter shift set the degree of drop oblongness: ‘0’ is sphere, ‘1’ is maximally oblongness drop. Parameter ap set relative width of the drop (this is analogue of “ellipticity” for the sphere). See section Drops sample, for sample code and picture.

Method on mglGraph: void Cone (mglPoint p1, mglPoint p2, float r1, float r2=-1, const char *stl="B", bool edge=false)

Draw tube (or truncated cone if edge=false) between points p1, p2 with radius at the edges r1, r2. If r2<0 then it is supposed that r2=r1. The cone color is defined by string stl.

Method on mglGraph: void Mark (mglPoint p, char mark='.')

Draws a marks of different type at position p.

Method on mglGraph: void Glyph (float x, float y, float f, int nt, const short *trig, int nl, const short *line)

Draw a set of triangles (or lines if trig=NULL) for glyph which is placed at point {x, y}. Values in the arrays are normalized by factor f. Normally this function is used internally.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6 Text printing

These functions draw the text. There are functions for drawing text in arbitrary place, in arbitrary direction and along arbitrary curve. The class mglFont (see section mglFont class) is used for low-level string parsing and printing. It can use arbitrary font-faces and parse many TeX commands. All these functions have 2 variant: for printing 8-bit text (char *) and for printing Unicode text (wchar_t *). In first case the conversion in current locale is used. So sometimes you need to specify it by setlocale() function. The size argument control the size of text: if positive it give the value, if negative it give the value relative to FontSize. The font type (STIX, arial, courier, times and so on) can be selected by function SetFont(), GetFont(). See section Font settings.

The font parameters are described by string. This string may contain several characters of font type (‘rbiwou’) and/or align (‘LRC’) specification. Also it may contain the text color ‘wkrgbcymhRGBCYMHW’ (see section mglColor class) after symbol ‘:’. The font types are: ‘r’ – roman font, ‘i’ – italic style, ‘b’ – bold style, ‘w’ – wired style, ‘o’ – over-lined text, ‘u’ – underlined text. By default roman font is used. The align types are: ‘L’ – align left (default), ‘C’ – align center, ‘R’ – align right. Also a parsing of the LaTeX-like syntax is provided (for detail see section mglFont class). For example, string ‘iC:b’ correspond to italic font style for centered text which printed by blue color.

Method on mglGraph: void Puts (mglPoint p, const char *text, const char *font=NULL, float size=-1, char dir=0, float shift=0)
Method on mglGraph: void Putsw (mglPoint p, const wchar_t *text, const char *font=NULL, float size=-1, char dir=0, float shift=0)

The function plots the string text at position p with fonts specifying by the criteria how. The size of font is set by size parameter (default is FontSize). Parameter dir specifies the additional string align. The aligns are: ‘x’ – align as x-label, ‘y’ – align as y-label, ‘z’ – align as z-label, ‘i’ – align as x-label but inverse writing direction, ‘t’ – no align (default), ‘n’ – align in x-y plane.

Method on mglGraph: float Puts (mglPoint p, mglPoint l, const char *text, charwhere='t', float size=-1)
Method on mglGraph: float Putsw (mglPoint p, mglPoint l, const wchar_t *text, charwhere='t', float size=-1)

The function plots the string text at position p along direction l with specified size. Parameter where set to print text above the line (‘T’) or under the line (‘t’). Function return the width of the string.

Method on mglGraph: void Text (mglPoint p, const char *text, const char *font=NULL, float size=-1, char dir=0)
Method on mglGraph: void Text (mglPoint p, const wchar_t *text, const char *font=NULL, float size=-1, char dir=0)

The function plots the string text at position p with fonts how. These functions are obsolete – use Puts(), Putsw() functions instead.

Method on mglGraph: void Printf (mglPoint p, const char *arg, ...)

Print formatted string at point p.

Method on mglGraph: void Title (const char *text, const char *font=0, float size=-2)
Method on mglGraph: void Title (const wchar_t *text, const char *font=0, float size=-2)

Print string text as title of the picture (at the top of the picture). Can be used at any place (even inside SubPlot()).

Method on mglGraph: void Text (const mglData &y, const char *text, const char *font=NULL, float size=-1, float zVal=NAN)
Method on mglGraph: void Text (const mglData &y, const wchar_t *text, const char *font=NULL, float size=-1, float zVal=NAN)
Method on mglGraph: void Text (const mglData &x, const mglData &y, const char *text, const char *font=NULL, float size=-1, float zVal=NAN)
Method on mglGraph: void Text (const mglData &x, const mglData &y, const wchar_t *text, const char *font=NULL, float size=-1, float zVal=NAN)
Method on mglGraph: void Text (const mglData &x, const mglData &y, const mglData &z, const char *text, const char *font=NULL, float size=-1)
Method on mglGraph: void Text (const mglData &x, const mglData &y, const mglData &z, const wchar_t *text, const char *font=NULL, float size=-1)

The function draws text along the curve between points {x[i], y[i], z[i]} by font style font and with size size. The string font may contain symbols ‘t’ for printing the text under the curve (default), or ‘T’ for printing the text above the curve. The sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. If array x is not specified then its an automatic array is used with values equidistantly distributed in interval [Min.x, Max.x] (see section Ranges (bounding box)). If array z is not specified then z[i] = zVal is used. See section Text sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.7 Axis and Colorbar

These functions draw the “things for measuring”, like axis with ticks, colorbar with ticks, grid along axis, bounding box and labels for axis. For more information see section Axis settings.

Method on mglGraph: void Axis (const char *dir="xyz", bool adjust=false)

Draws axes with ticks (see section Axis settings) in directions determined by string parameter dir.If string contain the symbol ‘_’ then tick labels are not printed. Font for ticks labels is determined by FontDef (see section Font settings). Ticks will be adjusted if adjust=true (by call of AdjustTicks()).

Method on mglGraph: void Colorbar (const char *sch=NULL, int where=0)

Draws colorbar with color scheme sch (current scheme if sch=NULL) at edge of plot. Parameter where specifies the position of the colorbar: ‘0’ - at right (default), ‘1’ - at left, ‘2’ - at top, ‘3’ - at bottom. See section Dens sample, for sample code and picture.

Method on mglGraph: void Colorbar (const char *sch, int where, float x, float y, float w, float h)
Method on mglGraph: void Colorbar (int where, float x, float y, float w, float h)

Draws colorbar with color scheme sch (current scheme if not specified) at arbitrary position of subplot {x, y} (supposed to be in range [0,1]). Parameter where specifies the position of colorbar labels: ‘0’ - at left, ‘1’ - at right, ‘2’ - at bottom, ‘3’ - at top. Parameters w, h set the relative width and height of the colorbar.

Method on mglGraph: void Colorbar (const mglData &v, const char *sch=NULL, int where=0)

Draws colorbar with sharp colors sch (current palette if sch=NULL) for values v at edge of plot. Parameter where specifies the position of the colorbar: ‘0’ - at right (default), ‘1’ - at left, ‘2’ - at top, ‘3’ - at bottom. See section ContD sample, for sample code and picture.

Method on mglGraph: void Grid (const char *dir="xyz", const char *pen="B-")

Draws grid lines perpendicular to direction determined by string parameter dir. The step of grid lines is the same as tick step for an Axis(). The style of lines is determined by pen parameter (default value is dark blue solid line (‘B-’).

Method on mglGraph: void Box (mglColor col=NC, bool ticks=true)
Method on mglGraph: void Box (const char *col, bool ticks=true)

Draws bounding box outside the plotting volume with color col.

Method on mglGraph: void Label (char dir, const char *text, int pos=+1, float size=-1.4, float shift=0)
Method on mglGraph: void Label (char dir, const wchar_t *text, int pos=+1, float size=-1.4, float shift=0)

Prints the label text for axis dir=‘x’,‘y’,‘z’,‘t’ (here ‘t’ is “ternary” axis t=1-x-y). The position of label is determined by pos parameter. If pos=0 then label is printed at the center of axis. If pos>0 then label is printed at the maximum of axis. If pos<0 then label is printed at the minimum of axis. Parameter size determines the font size for the label. By default the font size is 1.4 times larger than the one for ticks FontSize (see section Font settings). See section Text printing.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.8 Legend

These functions draw legend to the graph (useful for 1D plotting). Legend entry is a pair of strings: one for style of the line, another one with description text (with included LaTeX parsing). The array of string may be used directly or by accumulating first to the internal arrays (by function AddLegend()) and further plotting it. The position of the legend can be selected automatic or manually. Parameters font and size specify the font style and size (see section Font settings). Parameter llen set the relative width of the line sample and the text indent. If line style string for entry is empty then the corresponding text is printed without indent. See section Legend sample, for sample code and picture.

Method on mglGraph: void Legend (int where=0x3, const char *font="rL", float size=-0.8, float llen=0.1)

Draws legend of accumulated legend entries by font font with size. Parameter where sets the position of the legend: ‘0’ is bottom left corner, ‘1’ is bottom right corner, ‘2’ is top left corner, ‘3’ is top right corner (is default).

Method on mglGraph: void Legend (int n, wchar_t **text, char **style, int where=0x3, const char *font="rL", float size=-0.8, float llen=0.1)

Draws legend with n-th elements of string array text by font font with size. Entry strings text describe curves with line style style (including marks). Parameter where sets the position of the legend: ‘0’ is bottom left corner, ‘1’ is bottom right corner, ‘2’ is top left corner, ‘3’ is top right corner (is default).

Method on mglGraph: void Legend (float x, float y, const char *font="rL", float size=-0.8, float llen=0.1)

Draws legend of accumulated legend entries by font font with size. Position of legend is determined by parameter x, y which supposed to be normalized to interval [0,1].

Method on mglGraph: void Legend (int n, wchar_t **text, char **style, float x, float y, const char *font="rL", float size=-0.8, float llen=0.1)

Draws legend with n-th elements of string array text by font font with size. Entry strings text describe curves with line style style (including marks). Position of legend is determined by parameter x, y which supposed to be normalized to interval [0,1].

Method on mglGraph: void AddLegend (const char *text, const char *style)
Method on mglGraph: void AddLegend (const wchar_t *text, const char *style)

Adds string text to internal legend accumulator. The style of described line and mark is specified in string style (see section Line styles). Maximal number of entries is 100.

Method on mglGraph: void ClearLegend ()

Clears saved legend strings.

General option of mglGraph: bool LegendBox

Switch on/off drawing box near legend. By default (=true) box is drawn.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9 1D plotting

These functions perform plotting of 1D data. 1D means that data depended from only 1 parameter like parametric curve {x(i),y(i),z(i)}, i=1...n. There are 5 generally different types of data representations: simple line plot (Plot), line plot with filling under it (Area), stairs plot (Step), bar plot (Bars, Barh) and vertical lines (Stem). Each type of plotting has similar interface. There are 3D version and two 2D versions. One of last requires single array. The parameters of line and marks are specified by the string argument. If the string parameter is NULL then solid line with color from palette Pal is used (see section Pallete and colors). Also there are some special 1d plots having slightly different interface: surface of curve rotation (Torus), chart (Chart) and error boxes (Error), marks with variable size (Mark), tubes (Tube) and so on. See section Line styles.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.1 Plot

These functions draw continuous lines between points. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Area, Step, Stem, Tube, Mark, Error, Belt, Tens. See section Plot sample, for sample code and picture.

Method on mglGraph: void Plot (const mglData &x, const mglData &y, const mglData &z, const char *pen=NULL)

The function draws continuous lines between points {x[i], y[i], z[i]} in 3D space.

Method on mglGraph: void Plot (const mglData &x, const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Plot (const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: void Plot2 (const mglData &a, const char *pen=NULL, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x=a(2*k,:), y=a(2*k+1,:), k \in 0 ... a.ny/2. This function is obsolete – use Plot() and SubData() functions instead.

Method on mglGraph: void Plot3 (const mglData &a, const char *pen=NULL)

The function draws continuous lines between points {x[i], y[i], z[i]} in 3D space, where x=a(3*k,:), y=a(3*k+1,:), z=a(3*k+2,:), k \in 0 ... a.ny/3. This function is obsolete – use Plot() and SubData() functions instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.2 Radar

Method on mglGraph: void Plot (const mglData &a, const char *pen=NULL, float r=-1)

This functions draws radar chart which is continuous lines between points located on an radial lines (like plot in Polar coordinates). The plots are drawn for each row if one of the data is the matrix. Parameter r set the additional shift of data (i.e. the data a+r is used instead of a). If r<0 then r=max(0, -min(a). String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). If pen containt ‘#’ symbol then "grid" (radial lines and circle for r) is drawn See also Plot. See section Radar sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.3 Tens

These functions draw continuous lines between points with color defined by the special array (look like tension plot). The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color scheme (see section Color scheme) and style and/or width of line (see section Line styles). By default (pen=NULL) solid line with current color scheme is used. See also Plot, Mesh, Fall. See section Tens sample, for sample code and picture.

Method on mglGraph: void Tens (const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *pen=NULL)

The function draws continuous lines between points {x[i], y[i], z[i]} in 3D space with color defined by c[i].

Method on mglGraph: void Tens (const mglData &x, const mglData &y, const mglData &c, const char *pen=NULL, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z) with color defined by c[i].

Method on mglGraph: void Tens (const mglData &y, const mglData &c, const char *pen=NULL, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z) with color defined by c[i], where x[i] values are equidistantly distributed in interval [Min.x, Max.x].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.4 Area

These functions draw continuous lines between points and fills it to axis plane. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Plot, Bars, Stem. See section Area sample, for sample code and picture.

Method on mglGraph: void Area (const mglData &x, const mglData &y, const mglData &z, const char *pen=NULL)

The function draws continuous lines between points {x[i], y[i], z[i]} in 3D space and fills it down to z = Org.z.

Method on mglGraph: void Area (const mglData &x, const mglData &y, const char *pen=NULL, bool sum=false, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z) and fills it down to y = Org.y. Parameter sum set to draw a lines one above another (like summation). Note, you can reach the same effect if call y.CumSum("y"); before plot.

Method on mglGraph: void Area (const mglData &y, const char *pen=NULL, bool sum=false, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z) and fills it down to y = Org.y, where x[i] values are equidistantly distributed in interval [Min.x, Max.x]. Parameter sum set to draw a lines one above another (like summation). Note, you can reach the same effect if call y.CumSum("y"); before plot.

Method on mglGraph: void Area2 (const mglData &a, const char *pen=NULL, float zVal=NAN)

The function draws continuous lines between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z) and fills it down to y = Org.y, where x=a(2*k,:), y=a(2*k+1,:), k \in 0 ... a.ny/2. This function is obsolete – use Area() and SubData() functions instead.

Method on mglGraph: void Area3 (const mglData &a, const char *pen=NULL)

The function draws continuous lines between points {x[i], y[i], z[i]} in 3D space and fills it down to z = Org.z, where x=a(3*k,:), y=a(3*k+1,:), z=a(3*k+2,:), k \in 0 ... a.ny/3. This function is obsolete – use Area() and SubData() functions instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.5 Region

These functions fill area between 2 curves. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y1.nx=y2.nx and all dimensions of arrays y1 and y2 must be equal too. String pen specifies the color (see section Line styles). By default (pen=NULL) color from palette is used (see section Pallete and colors). See also Area, Bars, Stem. See section Region sample, for sample code and picture.

Method on mglGraph: void Region (const mglData &x, const mglData &y1, const mglData &y2, const char *pen=NULL, float zVal=NAN, bool inside=true)

The function fills area between curves {x[i], y[i]} and {x[i], y2[i]} at z=zVal.

Method on mglGraph: void Region (const mglData &y1, const mglData &y2, const char *pen=NULL, float zVal=NAN, bool inside=true)

The function fills area between curves {x[i], y[i]} and {x[i], y2[i]}, where x[i] values are equidistantly distributed in interval [Min.x, Max.x] at z=zVal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.6 Bars

These functions draw vertical bars from points to axis plane. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Barh, Area, Stem, Chart, Default sizes. See section Bars sample, for sample code and picture.

Method on mglGraph: void Bars (const mglData &x, const mglData &y, const mglData &z, const char *pen=NULL)

The function draws vertical bars from points {x[i], y[i], z[i]} down to z = Org.z.

Method on mglGraph: void Bars (const mglData &x, const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws vertical bars from points {x[i], y[i]} down to y = Org.y in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Bars (const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws vertical bars from points {x[i], y[i]} down to y = Org.y in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: void Bars2 (const mglData &a, const char *pen=NULL, float zVal=NAN)

The function draws vertical bars from points {x[i], y[i]} down to y = Org.y in plane z=zVal (default in plane z=Min.z), where x=a(2*k,:), y=a(2*k+1,:), k \in 0 ... a.ny/2. This function is obsolete – use Bars() and SubData() functions instead.

Method on mglGraph: void Bars3 (const mglData &a, const char *pen=NULL)

The function draws vertical bars from points {x[i], y[i], z[i]} down to z = Org.z, where x=a(3*k,:), y=a(3*k+1,:), z=a(3*k+2,:), k \in 0 ... a.ny/3. This function is obsolete – use Bars() and SubData() functions instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.7 Barh

These functions draw horizontal bars from points to axis plane. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Barh, Default sizes. See section Barh sample, for sample code and picture.

Method on mglGraph: void Barh (const mglData &y, const mglData &v, const char *pen=NULL, float zVal=NAN)

The function draws horizontal bars from points {v[i], y[i]} down to x = Org.x in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Barh (const mglData &v, const char *pen=NULL, float zVal=NAN)

The function draws horizontal bars from points {v[i], y[i]} down to x = Org.x in plane z=zVal (default in plane z=Min.z), where y[i] values are equidistantly distributed in interval [Min.y, Max.y].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.8 Stem

These functions draw vertical lines from points to axis plane. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Area, Bars, Plot. See section Stem sample, for sample code and picture.

Method on mglGraph: void Stem (const mglData &x, const mglData &y, const mglData &z, const char *pen=NULL)

The function draws vertical lines from points {x[i], y[i], z[i]} down to z = Org.z.

Method on mglGraph: void Stem (const mglData &x, const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws vertical lines from points {x[i], y[i]} down to y = Org.y in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Stem (const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws vertical lines from points {x[i], y[i]} down to y = Org.y in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: void Stem2 (const mglData &a, const char *pen=NULL, float zVal=NAN)

The function draws vertical lines from points {x[i], y[i]} down to y = Org.y in plane z=zVal (default in plane z=Min.z), where x=a(2*k,:), y=a(2*k+1,:), k \in 0 ... a.ny/2. This function is obsolete – use Stem() and SubData() functions instead.

Method on mglGraph: void Stem3 (const mglData &a, const char *pen=NULL)

The function draws vertical lines from points {x[i], y[i], z[i]} down to z = Org.z, where x=a(3*k,:), y=a(3*k+1,:), z=a(3*k+2,:), k \in 0 ... a.ny/3. This function is obsolete – use Stem() and SubData() functions instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.9 Step

These functions draw continuous stairs for points to axis plane. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Plot, Stem, Tile, Boxs. See section Step sample, for sample code and picture.

Method on mglGraph: void Step (const mglData &x, const mglData &y, const mglData &z, const char *pen=NULL)

The function draws continuous stairs for points {x[i], y[i], z[i]}.

Method on mglGraph: void Step (const mglData &x, const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws continuous stairs for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Step (const mglData &y, const char *pen=NULL, float zVal=NAN)

The function draws continuous stairs for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: void Step2 (const mglData &a, const char *pen=NULL, float zVal=NAN)

The function draws continuous stairs for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x=a(2*k,:), y=a(2*k+1,:), k \in 0 ... a.ny/2. This function is obsolete – use Step() and SubData() functions instead.

Method on mglGraph: void Step3 (const mglData &a, const char *pen=NULL)

The function draws continuous stairs for points {x[i], y[i], z[i]}, where x=a(3*k,:), y=a(3*k+1,:), z=a(3*k+2,:), k \in 0 ... a.ny/3. This function is obsolete – use Step() and SubData() functions instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.10 Torus

These functions draw surface which is result of curve {r, z} rotation around AxialDir axis (see section Other settings). The sizes of 1st dimension must be equal for all arrays r.nx=z.nx. String pen specifies the color (see section Line styles). By default (pen=NULL) color from palette is used (see section Pallete and colors). See also Plot, Axial. See section Torus sample, for sample code and picture.

Method on mglGraph: void Torus (const mglData &r, const mglData &z, const char *pen=NULL)

The function draws surface which is result of curve {r[i], z[i]} rotation.

Method on mglGraph: void Torus (const mglData &z, const char *pen=NULL)

The function draws surface which is result of curve {r[i], z[i]} rotation, where r[i] values are equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: void Torus2 (const mglData &a, const char *pen=NULL)

The function draws surface which is result of curve {x[i], y[i]} rotation, where r=a(2*k,:), z=a(2*k+1,:), k \in 0 ... a.ny/2. This function is obsolete – use Torus() and SubData() functions instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.11 Chart

Method on mglGraph: void Chart (const mglData &a, const char *col=NULL)

The function draws colored stripes (boxes) for data in array a. The number of stripes is equal to the number of rows in a (equal to a.ny). The color of each next stripe is cyclically changed from colors specified in string col or in palette Pal (see section Pallete and colors). Spaces in colors denote transparent “color”, i.e. if col contain space(s) then corresponding stripe(s) are not drawn. The stripe width is proportional to value of element in a. Chart is plotted only for data with non-negative elements. If string col have symbol ‘#’ then black border lines are drawn. The most nice form the chart have in 3d (after rotation of coordinates) or in cylindrical coordinates (becomes so called Pie chart). See section Chart sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.12 Mark

These functions draw marks with size r*MarkSize (see section Default sizes) at points {x[i], y[i], z[i]}. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx=r.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). If you need to draw markers of the same size then you may use Plot function. See also Plot, TextMark, Stem, Error. See section Mark sample, for sample code and picture.

Method on mglGraph: void Mark (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen=NULL)

The function draws marks for points {x[i], y[i], z[i]} in 3D space.

Method on mglGraph: void Mark (const mglData &x, const mglData &y, const mglData &r, const char *pen=NULL, float zVal=NAN)

The function draws marks for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Mark (const mglData &y, const mglData &r, const char *pen=NULL, float zVal=NAN)

The function draws marks for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.13 TextMark

These functions draw string text as marks with size proportional to r*MarkSize (see section Default sizes) at points {x[i], y[i], z[i]}. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx=r.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Plot, Mark, Stem. See section TextMark sample, for sample code and picture.

Method on mglGraph: void TextMark (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const wchar_t *text, const char *fnt=NULL)
Method on mglGraph: void TextMark (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *text, const char *fnt=NULL)

The function draws textual marks for points {x[i], y[i], z[i]} in 3D space.

Method on mglGraph: void TextMark (const mglData &x, const mglData &y, const mglData &r, const wchar_t *text, const char *fnt=NULL, float zVal=NAN)
Method on mglGraph: void TextMark (const mglData &x, const mglData &y, const mglData &r, const char *text, const char *fnt=NULL, float zVal=NAN)

The function draws textual marks for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void TextMark (const mglData &y, const mglData &r, const wchar_t *text, const char *fnt=NULL, float zVal=NAN)
Method on mglGraph: void TextMark (const mglData &y, const mglData &r, const char *text, const char *fnt=NULL, float zVal=NAN)

The function draws textual marks for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: void TextMark (const mglData &y, const wchar_t *text, const char *fnt=NULL, float zVal=NAN)
Method on mglGraph: void TextMark (const mglData &y, const char *text, const char *fnt=NULL, float zVal=NAN)

The function draws textual marks for points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x]. The mark sizes r[i]=1 for all points.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.14 Error

These functions draw error boxes at points {x[i], y[i]} on plane z = zVal (by default z=Min.z). This can be useful, for example, in experimental points, or to show numeric error or some estimations and so on. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx=r.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Plot. See section Error sample, for sample code and picture.

Method on mglGraph: void Error (const mglData &x, const mglData &y, const mglData &ex, const mglData &ey, const char *pen=NULL, floatzVal=NAN)

Draws a error box {ex, ey} in point position {x, y}.

Method on mglGraph: void Error (const mglData &x, const mglData &y, const mglData &ey, const wchar_t *pen=NULL, float zVal=NAN)

Draws a error box ey (along only one direction) in point position {x, y}.

Method on mglGraph: void Error (const mglData &y, const mglData &ey, const char *pen=NULL, float zVal=NAN)

Draws a error box ey (along only one direction) in point position {x, y}, where x values are equidistantly distributed in interval [Min.x, Max.x].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.9.15 Tube

These functions draw the tube with variable radius r[i] along the curve between points {x[i], y[i], z[i]}. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension must be equal for all arrays x.nx=y.nx=z.nx=r.nx. String pen specifies the color and style of line and marks (see section Line styles). By default (pen=NULL) solid line with color from palette is used (see section Pallete and colors). See also Plot. See section Tube sample, for sample code and picture.

Method on mglGraph: void Tube (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen=NULL)
Method on mglGraph: void Tube (const mglData &x, const mglData &y, const mglData &z, float r, const char *pen=NULL)

The function draws tube with radius r between points {x[i], y[i], z[i]} in 3D space.

Method on mglGraph: void Tube (const mglData &x, const mglData &y, const mglData &r, const char *pen=NULL, float zVal=NAN)
Method on mglGraph: void Tube (const mglData &x, const mglData &y, float r, const char *pen=NULL, float zVal=NAN)

The function draws tube with radius r between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z).

Method on mglGraph: void Tube (const mglData &y, const mglData &r, const char *pen=NULL, float zVal=NAN)
Method on mglGraph: void Tube (const mglData &y, float r, const char *pen=NULL, float zVal=NAN)

The function draws tube with radius r between points {x[i], y[i]} in plane z=zVal (default in plane z=Min.z), where x[i] values are equidistantly distributed in interval [Min.x, Max.x].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10 2D plotting

These functions perform plotting of 2D data. 2D means that data depend from 2 independent parameters like matrix f(x_i,y_j), i=1...n, j=1...m. There are 6 generally different types of data representations: simple mesh lines plot (Mesh), surface plot (Surf), surface plot by boxes (Boxs), surface plot by tiles (Tile), waterfall-like plot (Fall), belt plot (Belt), density plot (Dens), contour lines plot (Cont), solid contours plot (ContF) and its rotational figure (Axial). Cont, ContF and Axial functions have variants for automatic and manual selection of level values for contours. Also there are functions for plotting data grid lines according to the data format (Grid) for enhancing density or contour plots. Each type of plotting has similar interface. There are 2 kind of versions which handle the arrays of data and coordinates or only single data array. Parameters of color scheme are specified by the string argument. See section Color scheme.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.1 Mesh

Method on mglGraph: void Mesh (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws mesh lines for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. String sch sets the color scheme. Previous color scheme is used by default. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Mesh lines are plotted for each z slice of the data. See also Surf, Fall, NeshNum (see section Other settings), Cont, Tens. See section Mesh sample, for sample code and picture.

Method on mglGraph: void Mesh (const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.2 Fall

Method on mglGraph: void Fall (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws fall lines for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. String sch sets the color scheme. Previous color scheme is used by default. If sch contain ‘x’ then lines are drawn along x-direction else (by default) lines are drawn along y-direction. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Fall lines are plotted for each z slice of the data. See also Belt, Mesh, Tens, NeshNum (see section Other settings). See section Fall sample, for sample code and picture.

Method on mglGraph: void Fall (const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.3 Belt

Method on mglGraph: void Belt (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws belts for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. This plot can be used as 3d generalization of Plot (see section Plot). String sch sets the color scheme. Previous color scheme is used by default. If sch contain ‘x’ then belts are drawn along x-direction else (by default) belts are drawn along y-direction. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Belts are plotted for each z slice of the data. See also Fall, Surf, Plot, NeshNum (see section Other settings). See section Belt sample, for sample code and picture.

Method on mglGraph: void Belt (const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.4 Surf

Method on mglGraph: void Surf (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws surface specified parametrically {x[i,j], y[i,j], z[i,j]}. String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Mesh, Dens, Belt, Tile, Boxs, SurfC, SurfA. See section Surf sample, for sample code and picture.

Method on mglGraph: void Surf (const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.5 Boxs

Method on mglGraph: void Boxs (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws vertical boxes for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. String sch sets the color scheme. Previous color scheme is used by default. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Surf, Tile, Step. See section Boxs sample, for sample code and picture.

Method on mglGraph: void Boxs (const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.6 Tile

Method on mglGraph: void Tile (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws horizontal tiles for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. Such plot can be used as 3d generalization of Step (see section Step). String sch sets the color scheme. Previous color scheme is used by default. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Surf, Boxs, Step, TileS. See section Tile sample, for sample code and picture.

Method on mglGraph: void Tile (const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.7 Dens

Method on mglGraph: void Dens (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, float zVal=NAN)

The function draws density plot for surface specified parametrically {x[i,j], y[i,j], z[i,j]} at z = zVal. String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Surf, Cont, ContF, DensXYZ. See section Dens sample, for sample code and picture.

Method on mglGraph: void Dens (const mglData &z, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.8 Cont

Method on mglGraph: void Cont (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, float zVal=NAN)

The function draws contour lines for surface specified parametrically {x[i,j], y[i,j], z[i,j]} at z = zVal (or for z=v[k] if zVal==NAN). Contours are plotted for z[i,j]=v[k] where v[k] are values of data array v. String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Dens, ContF, Axial, ContXYZ. See section Cont sample, for sample code and picture.

Method on mglGraph: void Cont (const mglData &v, const mglData &z, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Cont (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, int num=7, float zVal=NAN)

The same as first one with vector v of num-th elements equidistantly distributed in range [Cmin, Cmax].

Method on mglGraph: void Cont (const mglData &z, const char *sch=NULL, int num=7, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.9 ContF

Method on mglGraph: void ContF (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, float zVal=NAN)

The function draws solid (or filled) contour lines for surface specified parametrically {x[i,j], y[i,j], z[i,j]} at z = zVal (or for z=v[k] if zVal==NAN). Contours are plotted for z[i,j]=v[k] where v[k] are values of data array v (must be v.nx>2). String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Dens, Cont, Axial, ContFXYZ. See section ContF sample, for sample code and picture.

Method on mglGraph: void ContF (const mglData &v, const mglData &z, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void ContF (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, int num=7, float zVal=NAN)

The same as first one with vector v of num-th elements equidistantly distributed in range [Cmin, Cmax].

Method on mglGraph: void ContF (const mglData &z, const char *sch=NULL, int num=7, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.10 ContD

Method on mglGraph: void ContD (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, float zVal=NAN)

The function draws solid (or filled) contour lines for surface specified parametrically {x[i,j], y[i,j], z[i,j]} at z = zVal (or for z=v[k] if zVal==NAN) with manual colors. Contours are plotted for z[i,j]=v[k] where v[k] are values of data array v (must be v.nx>2). String sch sets the contour colors: the color of k-th contour is determined by character sch[k%strlen(sch)]. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Dens, Cont, ContF. See section ContD sample, for sample code and picture.

Method on mglGraph: void ContD (const mglData &v, const mglData &z, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void ContD (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, int num=7, float zVal=NAN)

The same as first one with vector v of num-th elements equidistantly distributed in range [Cmin, Cmax].

Method on mglGraph: void ContD (const mglData &z, const char *sch=NULL, int num=7, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.11 Axial

Method on mglGraph: void Axial (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws surface which is result of contour plot rotation for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. Contours are plotted for z[i,j]=v[k] where v[k] are values of data array v. String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then wire plot is produced. If string contain symbols ‘x’, ‘y’ or ‘z’ then rotation axis AxialDir (see section Other settings) will be set to specified direction. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Cont, ContF, Torus, Surf3. See section Axial sample, for sample code and picture.

Method on mglGraph: void Axial (const mglData &v, const mglData &z, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Axial (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, int num=3)

The same as first one with vector v of num-th elements equidistantly distributed in range [Cmin, Cmax].

Method on mglGraph: void Axial (const mglData &z, const char *sch=NULL, int num=3)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.10.12 Grid

Method on mglGraph: void Grid (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, float zVal=NAN)

The function draws grid lines for density plot of surface specified parametrically {x[i,j], y[i,j], z[i,j]} at z = zVal. String sch sets the color scheme. Previous color scheme is used by default. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Grid is plotted for each z slice of the data. See also Dens, Cont, ContF.

Method on mglGraph: void Grid (const mglData &z, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11 3D plotting

These functions perform plotting of 3D data. 3D means that data depend from 3 independent parameters like matrix f(x_i,y_j,z_k), i=1...n, j=1...m, k=1...l. There are 4 generally different types of data representations: isosurface or surface of constant value (Surf3), density plot at slices (Dens3), contour lines plot at slices (Cont3), solid contours plot at slices (ContF3) and cloud-like plot (Cloud). Surf3, Cont3 and ContF3 functions have variants for automatic and manual selection of level values for surfaces/contours. Also there are functions for plotting data grid lines according to the data format (Grid3) for enhancing density or contour plots. Each type of plotting has similar interface. There are 2 kind of versions which handle the arrays of data and coordinates or only single data array. Parameters of color scheme are specified by the string argument. See section Color scheme.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.1 Surf3

Method on mglGraph: void Surf3 (float val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL)

The function draws isosurface plot for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) at a(x,y,z)=val. String sch sets the color scheme. Previous color scheme is used by default. If string contain ‘#’ then wire plot is produced. Arrays x, y, z can be vectors (not 3d arrays as a). Note, that there is possibility of incorrect plotting due to uncertainty of cross-section defining if there are two or more isosurface intersections inside one cell. See also Cloud, Dens3, Surf3C, Surf3A, Axial. See section Surf3 sample, for sample code and picture.

Method on mglGraph: void Surf3 (float val, const mglData &a, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Surf3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL, int num=3)

Draws num-th uniformly distributed in range [Cmin, Cmax] isosurfaces for 3d data specified parametrically.

Method on mglGraph: void Surf3 (const mglData &a, const char *sch=NULL, int num=3)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.2 Dens3

Method on mglGraph: void Dens3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl=NULL)

The function draws density plot for 3d data specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]). Density is plotted at slice sVal in dir={‘x’, ‘y’, ‘z’} direction. String sch sets the color scheme. Previous color scheme is used by default. If string stl have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). See also Cont3, ContF3, Dens, Grid3. See section Dens3 sample, for sample code and picture.

Method on mglGraph: void Dens3 (const mglData &a, char dir, int sVal=-1, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void DensA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL)

Draws density plots at all central slices of the 3d data specified parametrically.

Method on mglGraph: void DensA (const mglData &a, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.3 Cont3

Method on mglGraph: void Cont3 (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl=NULL)

The function draws contour plot for 3d data specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]). Contours are plotted for values specified in array v at slice sVal in dir={‘x’, ‘y’, ‘z’} direction. String sch sets the color scheme. Previous color scheme is used by default. If string stl have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). See also Dens3, ContF3, Cont, Grid3. See section Cont3 sample, for sample code and picture.

Method on mglGraph: void Cont3 (const mglData &v, const mglData &a, char dir, int sVal=-1, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Cont3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl=NULL, int num=7)

The same as first one with vector v of num-th elements equidistantly distributed in range [Cmin, Cmax].

Method on mglGraph: void Cont3 (const mglData &a, char dir, int sVal=-1, const char *sch=NULL, int num=7)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void ContA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL, int num=7)

Draws contour plots at all central slices of the 3d data specified parametrically.

Method on mglGraph: void ContA (const mglData &a, const char *sch=NULL, int num=7)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.4 ContF3

Method on mglGraph: void ContF3 (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl=NULL)

The function draws solid (or filled) contour plot for 3d data specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]). Contours are plotted for values specified in array v at slice sVal in dir={‘x’, ‘y’, ‘z’} direction. String sch sets the color scheme. Previous color scheme is used by default. If string stl have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). See also Dens3, Cont3, ContF, Grid3. See section ContF3 sample, for sample code and picture.

Method on mglGraph: void ContF3 (const mglData &v, const mglData &a, char dir, int sVal=-1, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void ContF3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl=NULL, int num=7)

The same as first one with vector v of num-th elements equidistantly distributed in range [Cmin, Cmax].

Method on mglGraph: void ContF3 (const mglData &a, char dir, int sVal=-1, const char *sch=NULL, int num=7)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void ContFA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL, int num=7)

Draws contour plots at all central slices of the 3d data specified parametrically.

Method on mglGraph: void ContFA (const mglData &a, const char *sch=NULL, int num=7)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.5 Grid3

Method on mglGraph: void Grid3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl=NULL)

The function draws grid for 3d data specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]). Density is plotted at slice sVal in dir={‘x’, ‘y’, ‘z’} direction. String sch sets the color scheme. Previous color scheme is used by default. If string stl have symbol ‘#’ then grid lines are drawn. The minor dimensions of arrays x, y, z must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). See also Cont3, ContF3, Dens3, Grid.

Method on mglGraph: void Grid3 (const mglData &a, char dir, int sVal=-1, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void GridA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL)

Draws grids at all central slices of the 3d data specified parametrically.

Method on mglGraph: void GridA (const mglData &a, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.6 Cloud

Method on mglGraph: void CloudQ (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL, float alpha=1)

The function draws cloud plot for 3d data specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]). This plot is a set of cubes with color and transparency proportional to value of a. The resulting plot is like cloud – low value is transparent but higher ones are not. The number of plotting cells depend on MeshNum (see section Other settings). String sch sets the color scheme. Previous color scheme is used by default. Parameter alpha changes the overall transparency of plot. The minor dimensions of arrays x, y, z must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). See also Surf3. See section CloudQ sample, for sample code and picture.

Method on mglGraph: void CloudQ (const mglData &a, const char *stl=NULL, float alpha=1)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void CloudP (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl=NULL, float alpha=1)

The same as first one but the semi-transparent points are used instead of cubes. See section CloudP sample, for sample code and picture.

Method on mglGraph: void CloudP (const mglData &a, const char *stl=NULL, float alpha=1)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11.7 Beam

Method on mglGraph: void Beam (float val, const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, float r, const char *stl=NULL, int flag=0)

Draws the isosurface for 3d array a at constant values of a=val. This is special kind of plot for a specified in accompanied coordinates along curve tr with orts g1, g2 and with transverse scale r. Variable flag is bitwise: ‘0x1’ - draw in accompanied (not laboratory) coordinates; ‘0x2’ - draw projection to \rho-z plane; ‘0x4’ - draw normalized in each slice field. The x-size of data arrays tr, g1, g2 must be nx>2. The y-size of data arrays tr, g1, g2 and z-size of the data array a must be equal. See section Surf3.

Method on mglGraph: void Beam (const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, float r, const char *stl=NULL, int flag=0, int num=3)

Draws num-th uniformly distributed in range [Cmin, Cmax] isosurfaces for 3d data specified parametrically.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12 Dual plotting

These plotting functions draw two matrix simultaneously. There are 5 generally different types of data representations: surface or isosurface colored by other data (SurfC, Surf3C), surface or isosurface transpared by other data (SurfA, Surf3A), tiles with variable size (TileS), mapping diagram (Map), STFA diagram (STFA). Surf3A and Surf3C have variants for automatic and manual selection of level values for isosurfaces. Each type of plotting has similar interface. There are 2 kind of versions which handle the arrays of data and coordinates or only single data array. Parameters of color scheme are specified by the string argument. See section Color scheme.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.1 SurfC

Method on mglGraph: void SurfC (const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch=NULL)

The function draws surface specified parametrically {x[i,j], y[i,j], z[i,j]} and color it by matrix c[i,j]. String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then grid lines are drawn. All dimensions of arrays z and c must be equal. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Surf, SurfA, Surf3C. See section SurfC sample, for sample code and picture.

Method on mglGraph: void SurfC (const mglData &z, const mglData &c, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.2 Surf3C

Method on mglGraph: void Surf3C (float val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl=NULL)

The function draws isosurface plot for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) at a(x,y,z)=val. It is mostly the same as Surf3() function but the color of isosurface depends on values of array c. String sch sets the color scheme. Previous color scheme is used by default. If string contain ‘#’ then wire plot is produced. All dimensions of arrays z and c must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). Note, that there is possibility of incorrect plotting due to uncertainty of cross-section defining if there are two or more isosurface intersections inside one cell. See also Surf3, SurfC, Surf3A. See section Surf3C sample, for sample code and picture.

Method on mglGraph: void Surf3C (float val, const mglData &a, const mglData &c, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Surf3C (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl=NULL, int num=3)

Draws num-th uniformly distributed in range [Cmin, Cmax] isosurfaces for 3d data specified parametrically.

Method on mglGraph: void Surf3C (const mglData &a, const mglData &c, const char *sch=NULL, int num=3)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.3 SurfA

Method on mglGraph: void SurfA (const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch=NULL)

The function draws surface specified parametrically {x[i,j], y[i,j], z[i,j]} and transparent it by matrix c[i,j]. String sch sets the color scheme. Previous color scheme is used by default. If string sch have symbol ‘#’ then grid lines are drawn. All dimensions of arrays z and c must be equal. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also Surf, SurfC, Surf3A, TileS. See section SurfA sample, for sample code and picture.

Method on mglGraph: void SurfA (const mglData &z, const mglData &c, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.4 Surf3A

Method on mglGraph: void Surf3A (float val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl=NULL)

The function draws isosurface plot for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) at a(x,y,z)=val. It is mostly the same as Surf3() function but the transparency of isosurface depends on values of b array. This allows one to remove the part of isosurface where b is negligibly small (useful for phase plotting of a beam or a pulse). String sch sets the color scheme. Previous color scheme is used by default. If string contain ‘#’ then wire plot is produced. All dimensions of arrays z and c must be equal. Arrays x, y, z can be vectors (not 3d arrays as a). Note, that there is possibility of incorrect plotting due to uncertainty of cross-section defining if there are two or more isosurface intersections inside one cell. See also Surf3, SurfA, Surf3C. See section Surf3A sample, for sample code and picture.

Method on mglGraph: void Surf3A (float val, const mglData &a, const mglData &c, const char *sch=NULL)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Surf3A (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl=NULL, int num=3)

Draws num-th uniformly distributed in range [Cmin, Cmax] isosurfaces for 3d data specified parametrically.

Method on mglGraph: void Surf3A (const mglData &a, const mglData &c, const char *sch=NULL, int num=3)

The same as previous with x, y, z equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.5 TileS

Method on mglGraph: void TileS (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *sch=NULL)

The function draws horizontal tiles for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. It is mostly the same as Tile() but the size of tiles is determined by r array. This is some kind of “transparency” useful for exporting to EPS files. String sch sets the color scheme. Previous color scheme is used by default. The minor dimensions of arrays x, y, z should be equal x.nx=z.nx && y.nx=z.ny or x.nx=y.nx=z.nx && x.ny=y.ny=z.ny. Arrays x and y can be vectors (not matrices as z). Surface is plotted for each z slice of the data. See also SurfA, Tile. See section Tiles sample, for sample code and picture.

Method on mglGraph: void TileS (const mglData &z, const mglData &c, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.6 Map

Method on mglGraph: void Map (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, int ks=0, bool pnts=true)

The function draws mapping plot for matrices {ax, ay } which parametrically depend on coordinates x, y. The previous position of the cell (point) is marked by color. Height is proportional to Jacobian(ax,ay). This plot is like Arnold diagram ???. If pnts=false then face is drawn otherwise the color ball at matrix knots are drawn. Parameter ks specifies the slice of matrices which will be used. String sch sets the color scheme. Previous color scheme is used by default. The size of ax and ay must be the same. The minor dimensions of arrays x, y, ax should be equal. Arrays x, y can be vectors (not matrix as ax). See section Color scheme. See section Map sample, for sample code and picture.

Method on mglGraph: void Map (const mglData &ax, const mglData &ay, const char *sch=NULL, int ks=0, bool pnts=true)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.12.7 STFA

Method on mglGraph: void STFA (const mglData &x, const mglData &y, const mglData &re, const mglData &im, int dn, const char *sch=NULL, float zVal=NAN)

Draws spectrogram of complex array re+i*im for Fourier size of dn points at plane z=zVal. Parameter dn is arbitrary even integer. For example in 1D case, result is density plot of data res[i,j]=|\sum_d^dn exp(I*j*d)*(re[i*dn+d]+I*im[i*dn+d])|/dn with size {int(nx/dn), dn, ny}. At this array re, im parametrically depend on coordinates x, y. String sch sets the color scheme. Previous color scheme is used by default. The size of re and im must be the same. The minor dimensions of arrays x, y, re should be equal. Arrays x, y can be vectors (not matrix as re). See section Color scheme.

Method on mglGraph: void STFA (const mglData &re, const mglData &im, int dn, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13 Vector fields

These functions perform plotting of 2D and 3D vector fields. There are 5 generally different types of vector fields representations: simple vector field (Vect, VectL), vector field with coloring (VectC), vector field by dew-drops (Dew), flow threads (Flow), flow pipes (Pipe). Each type of plotting has similar interface. There are 2 kind of versions which handle the arrays of data and coordinates or only single data array. Parameters of color scheme are specified by the string argument. See section Color scheme.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.1 Traj

Method on mglGraph: void Traj (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, float len=0)
Method on mglGraph: void Traj (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN, float len=0)

The function draws vectors {ax, ay, az} along a curve {x, y, z}. The length and color of arrows are proportional to \sqrtax^2+ay^2+az^2. The color is specified by the string argument sch. Previous color scheme is used by default. Parameter len set the vector length factor (if non-zero) or vector length to be proportional the distance between curve points (if len=0). The minor sizea of all arrays must be equal and large 2. Vectors are plotted for each column of the arrays. See also Vect. See section Traj sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.2 Vect

Method on mglGraph: void Vect (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN, int flag=0)

The function draws plane vector field plot for the field {ax, ay} depending parametrically on coordinates x, y at level z=zVal. The length and color of arrows are proportional to \sqrtax^2+ay^2. The number of arrows depend on MeshNum (see section Other settings). The color is specified by the string argument sch. Previous color scheme is used by default. Parameter flag setup the hachures (arrows). It is compination of vlaues: MGL_VEC_COL for drawing bi-color arrow, MGL_VEC_LEN for drawing fixed length arrows, MGL_VEC_DOT for drawing hachures with dots instead of arrows, MGL_VEC_END for drawing arrows to the cell point, MGL_VEC_MID for drawing arrows with center at cell point. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also VectL, VectC, Flow, Dew. See section Vect sample, for sample code and picture.

Method on mglGraph: void Vect (const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN, int flag=0)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Vect (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, int flag=0)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the length and color of arrows is proportional to \sqrtax^2+ay^2+az^2. See section Vect 3D sample, for sample code and picture.

Method on mglGraph: void Vect (const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, int flag=0)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.3 VectL

These functions are obsolete – use Vect() functions instead.

Method on mglGraph: void VectL (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN)

The function draws plane vector field plot for the field {ax, ay} depending parametrically on coordinates x, y at level z=zVal. The length of hachures is proportional to \sqrtax^2+ay^2. The number of hachures depend on MeshNum (see section Other settings). Points are denote the start of hachures. The color is specified by the string argument sch. Previous color scheme is used by default. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also Vect, VectC, Flow, Dew. See section VectL sample, for sample code and picture.

Method on mglGraph: void VectL (const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void VectL (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the length of hachures is proportional to \sqrtax^2+ay^2+az^2. See section VectL 3D sample, for sample code and picture.

Method on mglGraph: void VectL (const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.4 VectC

These functions are obsolete – use Vect() functions instead.

Method on mglGraph: void VectC (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN)

The function draws plane vector field plot for the field {ax, ay} depending parametrically on coordinates x, y at level z=zVal. The color of hachures is proportional to \sqrtax^2+ay^2. The number of hachures depend on MeshNum (see section Other settings). Points are denote the start of hachures. The color is specified by the string argument sch. Previous color scheme is used by default. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also Vect, VectL, Flow, Dew. See section VectC sample, for sample code and picture.

Method on mglGraph: void VectC (const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void VectC (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the color of hachures is proportional to \sqrtax^2+ay^2+az^2. See section VectC 3D sample, for sample code and picture.

Method on mglGraph: void VectC (const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.5 Dew

Method on mglGraph: void Dew (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN)

The function draws dew-drops for plane vector field {ax, ay} depending parametrically on coordinates x, y at level z=zVal. Note that this is very expensive plot in memory usage and creation time! The color of drops is proportional to \sqrtax^2+ay^2. The number of drops depend on MeshNum (see section Other settings). The color is specified by the string argument sch. Previous color scheme is used by default. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also Vect, VectC. See section Dew sample, for sample code and picture.

Method on mglGraph: void Dew (const mglData &ax, const mglData &ay, const char *sch=NULL, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.6 Flow

Method on mglGraph: void Flow (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, int num=5, bool central=true, float zVal=NAN)

The function draws flow threads for the plane vector field {ax, ay} parametrically depending on coordinates x, y at level z = zVal. Number of threads is proportional to num. Parameter central sets the thread start from center (if true) or only from edges (if false). The color of lines is proportional to \sqrtax^2+ay^2. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). String sch sets the color scheme. Previous color scheme is used by default. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also Pipe, VectC, Vect. See section Flow sample, for sample code and picture.

Method on mglGraph: void Flow (const mglData &ax, const mglData &ay, const char *sch=NULL, int num=5, bool central=true, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Flow (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, int num=3, bool central=true)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the color of line is proportional to \sqrtax^2+ay^2+az^2. See section Flow 3D sample, for sample code and picture.

Method on mglGraph: void Flow (const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, int num=3, bool central=true)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Flow (mglPoint p0, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL)

The function draws flow thread for the plane vector field {ax, ay} parametrically depending on coordinates x, y from point {p0.x, p0.z} at level z = p0.z. The color of lines is proportional to \sqrtax^2+ay^2. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). String sch sets the color scheme. Previous color scheme is used by default. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also Pipe, VectC, Vect. See section Flow sample, for sample code and picture.

Method on mglGraph: void Flow (mglPoint p0, const mglData &ax, const mglData &ay, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Flow (mglPoint p0, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the color of line is proportional to \sqrtax^2+ay^2+az^2. See section Flow 3D sample, for sample code and picture.

Method on mglGraph: void Flow (mglPoint p0, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.13.7 Pipe

Method on mglGraph: void Pipe (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch=NULL, float r0=0.05, int num=5, bool central=true, float zVal=NAN)

The function draws flow pipes for the plane vector field {ax, ay} parametrically depending on coordinates x, y at level z = zVal. Number of pipes is proportional to num. Parameter central sets the pipe start from center (if true) or only from edges (if false). The color of lines is proportional to \sqrtax^2+ay^2. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). String sch sets the color scheme. Previous color scheme is used by default. Parameter r0 set the base pipe radius. If r0<0 then pipe radius is inverse proportional to amplitude. The size of ax and ay must be equal. The minor dimensions of arrays x, y and ax must be equal too. Arrays x and y can be vectors (not matrices as ax). The vector field is plotted for each z slice of ax, ay. See also Pipe, VectC, Vect. See section Pipe sample, for sample code and picture.

Method on mglGraph: void Pipe (const mglData &ax, const mglData &ay, const char *sch=NULL, float r0=0.05, int num=5, bool central=true, float zVal=NAN)

The same as previous with x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: void Pipe (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, float r0=0.05, int num=3, bool central=true)

This is 3D version of the first functions. Here arrays ax, ay, az must be 3-ranged tensors with equal sizes and the color of line is proportional to \sqrtax^2+ay^2+az^2. See section Pipe 3D sample, for sample code and picture.

Method on mglGraph: void Pipe (const mglData &ax, const mglData &ay, const mglData &az, const char *sch=NULL, float r0=0.05, int num=3, bool central=true)

The same as previous with x, y equidistantly distributed in interval [Min, Max].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14 Other plotting

These functions perform miscelaneous plotting. There is unstructured data points plots (Dots), surface reconstruction (Crust), surfaces on the triangular mesh (TriPlot), textual formula plotting (Plots by formula), data plots at edges (Dens[XYZ], Cont[XYZ], ContF[XYZ]), simple plot (SimplePlot). Each type of plotting has similar interface. There are 2 kind of versions which handle the arrays of data and coordinates or only single data array. Parameters of color scheme are specified by the string argument. See section Color scheme.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.1 DensXYZ

These plotting functions draw density plot in x, y, or z plain. If a is a tensor (3-dimensional data) then interpolation to a given sVal is performed. These functions are useful for creating projections of the 3D data array to the bounding box. For example, code like

 
gr->DensX(c.Sum("x"),"BbcyrR",-1);
gr->DensY(c.Sum("y"),0,1);
gr->DensZ(c.Sum("z"),0,-1);

will produce the following picture. See also ContXYZ, ContFXYZ, Dens. See section Dens projection sample, for sample code and picture.

Method on mglGraph: void DensX (const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws density plot for data a at x = sVal.

Method on mglGraph: void DensY (const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws density plot for data a at y = sVal.

Method on mglGraph: void DensZ (const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws density plot for data a at z = sVal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.2 ContXYZ

These plotting functions draw density plot in x, y, or z plain. If a is a tensor (3-dimensional data) then interpolation to a given sVal is performed. These functions are useful for creating projections of the 3D data array to the bounding box. For example, code like

 
gr->ContX(c.Sum("x"),"BbcyrR",-1);
gr->ContY(c.Sum("y"),0,1);
gr->ContZ(c.Sum("z"),0,-1);

will produce the following picture. See also ContFXYZ, DensXYZ, Cont. See section Cont projection sample, for sample code and picture.

Method on mglGraph: void ContX (const mglData &a, const char *stl=NULL, float sVal=NAN, int num=7)

Draws num-th contour lines for data a at x = sVal.

Method on mglGraph: void ContY (const mglData &a, const char *stl=NULL, float sVal=NAN, int num=7)

Draws num-th contour lines for data a at y = sVal.

Method on mglGraph: void ContZ (const mglData &a, const char *stl=NULL, float sVal=NAN, int num=7)

Draws num-th contour lines for data a at z = sVal.

Method on mglGraph: void ContX (const mglData &v, const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws contour lines for data a=v[i] at x = sVal.

Method on mglGraph: void ContY (const mglData &v, const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws contour lines for data a=v[i] at y = sVal.

Method on mglGraph: void ContZ (const mglData &v, const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws contour lines for data a=v[i] at z = sVal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.3 ContFXYZ

These plotting functions draw density plot in x, y, or z plain. If a is a tensor (3-dimensional data) then interpolation to a given sVal is performed. These functions are useful for creating projections of the 3D data array to the bounding box. See also ContXYZ, DensXYZ, ContF.

Method on mglGraph: void ContFX (const mglData &a, const char *stl=NULL, float sVal=NAN, int num=7)

Draws num-th solid contours for data a at x = sVal.

Method on mglGraph: void ContFY (const mglData &a, const char *stl=NULL, float sVal=NAN, int num=7)

Draws num-th solid contours for data a at y = sVal.

Method on mglGraph: void ContFZ (const mglData &a, const char *stl=NULL, float sVal=NAN, int num=7)

Draws num-th solid contours for data a at z = sVal.

Method on mglGraph: void ContFX (const mglData &v, const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws solid contours for data a=v[i] at x = sVal.

Method on mglGraph: void ContFY (const mglData &v, const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws solid contours for data a=v[i] at y = sVal.

Method on mglGraph: void ContFZ (const mglData &v, const mglData &a, const char *stl=NULL, float sVal=NAN)

Draws solid contours for data a=v[i] at z = sVal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.4 Dots

Method on mglGraph: void Dots (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)
Method on mglGraph: void Dots (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch=NULL)

The function draws the arbitrary placed points {x[i], y[i], z[i]}. String sch sets the color scheme. Previous color scheme is used by default. If array a is specified then it define the transparency of dots. Arrays x, y, z, a must have equal sizes. See also Crust, Mark, Plot. See section Dots sample, for sample code and picture.

Method on mglGraph: void Dots (const mglData &tr, const char *sch=NULL)

The same as previous with x=tr(0,:), y=tr(1,:), z=tr(2,:) and if tr.nx>3 then a=tr(3,:).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.5 Crust

Method on mglGraph: void Crust (const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL, float er=0)

The function reconstruct and draws the surface for arbitrary placed points {x[i], y[i], z[i]}. Parameter er set relative radius for (increase it for removing holes). String sch sets the color scheme. Previous color scheme is used by default. If string contain ‘#’ then wire plot is produced. Arrays x, y, z must have equal sizes. See also Dots, TriPlot. See section Crust sample, for sample code and picture.

Method on mglGraph: void Crust (const mglData &tr, const char *sch=NULL, float er=0)

The same as previous with x=tr(0,:), y=tr(1,:), z=tr(2,:).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.6 TriPlot

Method on mglGraph: void TriPlot (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch=NULL)
Method on mglGraph: void TriPlot (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const char *sch=NULL)

The function draws the surface of triangles. Triangle vertexes are set by indexes id of data points {x[i], y[i], z[i]}. String sch sets the color scheme. Previous color scheme is used by default. If string contain ‘#’ then wire plot is produced. First dimensions of id must be 3 or greater. Arrays x, y, z must have equal sizes. Parameter c set the colors of triangles (if id.ny=c.nx) or colors of vertexes (if x.nx=c.nx). See also Dots, Crust.

Method on mglGraph: void TriPlot (const mglData &id, const mglData &x, const mglData &y, const char *sch=NULL, float zVal=NAN)

The same as previous with z[i]=zVal.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.7 Plots by formula

These functions perform plotting of 1D or 2D functions specified by textual formula. You do not need to create the data arrays to plot it. The parameter stl set the line style (see section Line styles) for Plot() or color scheme (see section Color scheme) for Surf(). The parameter n set the minimal number of points along coordinate(s) for plots. At this time (v. 1.7) there is no adaptive increase of data points numbers but in future it will appear.

Method on mglGraph: void Plot (const char *eqY, const char *stl=NULL, float zVal=NAN, int n=100)

The function draws function ‘eqY(x)’ at plane z=zVal where ‘x’ variable is changed in range [Min.x, Max.x]. See also Plot.

Method on mglGraph: void Plot (const char *eqX, const char *eqY, const char *eqZ, const char *stl=NULL, float zVal=NAN, int n=100)

The function draws parametrical curve {‘eqX(t)’, ‘eqY(t)’, ‘eqZ(t)’} where ‘t’ variable is changed in range [0, 1]. See also Plot.

Method on mglGraph: void Surf (const char *eqZ, const char *stl=NULL, int n=100);

The function draws surface for function ‘eqY(x,y)’ where ‘x’, ‘y’ variables are changed in range [Min, Max]. See also Surf.

Method on mglGraph: void Surf (const char *eqX, const char *eqY, const char *eqZ, const char *stl=NULL, int n=100)

The function draws parametrical surface {‘eqX(u,v)’, ‘eqY(u,v)’, ‘eqZ(u,v)’} where ‘u’, ‘v’ variables are changed in range [0, 1]. See also Surf.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.14.8 SimplePlot

Method on mglGraph: void SimplePlot (const mglData &a, int type=0, const char *stl=NULL)

Plots the array a depending on it’s dimensions and type parameter. String stl specifies the style of plotting. For 1d data: type=0Plot, type=1Area, type=2Step, type=3Stem, type=4Bars. For 2d data: type=0Surf, type=1Dens, type=2Mesh, type=3Cont. For 3d data: type=0Surf3, type=1Dens3, type=2Cont3, type=2Cloud.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.15 Nonlinear fitting

These functions fit data to formula. Fitting goal is to find formula parameters for the best fit the data points, i.e. to minimize the sum \sum_i (f(x_i, y_i, z_i) - a_i)^2/s_i^2. At this, approximation function ‘f’ can depend only on one argument ‘x’ (1D case), on two arguments ‘x,y’ (2D case) and on three arguments ‘x,y,z’ (3D case). The function ‘f’ also may depend on parameters. Normally the list of fitted parameters is specified by var string (like, ‘abcd’). Usually user should supply initial values for fitted parameters by ini variable. But if he/she don’t supply it then the zeros are used. Parameter print=true switch on printing the found coefficients to Message (see section Error handling).

Functions Fit() and FitS() do not draw the obtained data themselves. They fill the data fit by formula ‘f’ with found coefficients and return the \chi^2 error of approximation. At this, the ‘x,y,z’ coordinates are equidistantly distributed in the interval MinMax. Number of points in fit is selected as maximal value of fit size and the value of FitPnts. Note, that this functions use GSL library and do something only if MathGL was compiled with GSL support. See section Fitting sample, for sample code and picture.

Method on mglGraph: float FitS (mglData &fit, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float FitS (mglData &fit, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-, y- and z-directions for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]).

Method on mglGraph: float FitS (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float FitS (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-, and y-directions for 2d array specified parametrically a[i,j](x[i,j], y[i,j]) for each data slice.

Method on mglGraph: float FitS (mglData &fit, const mglData &x, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float FitS (mglData &fit, const mglData &x, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-direction for 1d array specified parametrically a[i](x[i]) for each data slice.

Method on mglGraph: float FitS (mglData &fit, const mglData &a, const mglData &s, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float FitS (mglData &fit, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-direction for 1d array with x equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-, y- and z-directions for 3d array specified parametrically a[i,j,k](x[i,j,k], y[i,j,k], z[i,j,k]) with s[i,j,k]=1.

Method on mglGraph: float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-, and y-directions for 2d array specified parametrically a[i,j](x[i,j], y[i,j]) with s[i,j]=1 for each data slice.

Method on mglGraph: float Fit (mglData &fit, const mglData &x, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float Fit (mglData &fit, const mglData &x, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-direction for 1d array specified parametrically a[i](x[i]) with s[i]=1 for each data slice.

Method on mglGraph: float Fit (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float Fit (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-direction for 1d array a with s=1 and x equidistantly distributed in interval [Min.x, Max.x].

Method on mglGraph: float Fit2 (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float Fit2 (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-, and y-directions for 2d array a with s=1 and x, y equidistantly distributed in interval [Min, Max].

Method on mglGraph: float Fit3 (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph: float Fit3 (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)

Fit data along x-, y- and z-directions for 3d array a with s=1 and x, y, z equidistantly distributed in interval [Min, Max].

Method on mglGraph: void PutsFit (mglPoint p, const char *prefix=NULL, const char *font=NULL, float size=-1)

Print last fitted formula with found coefficients (as numbers) at position p0. The string prefix will be printed before formula. All other parameters are the same as in Text printing.

General option of mglGraph: int FitPnts

Minimal number of points for output array after nonlinear fitting.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.16 Frames/Animation

These functions provide ability to create several pictures simultaneously. For most of cases it is useless but for widget classes (see section Widget classes) they can provide a way to show animation. Also you can write several frames into animated GIF file.

Method on mglGraph: int NewFrame ()

Creates new frame. Function returns current frame id. This is not thread safe function in OpenGL mode! Use direct list creation in multi-threading drawing. The function EndFrame() must be call after the finishing of the frame drawing for each call of this function.

Method on mglGraph: void EndFrame ()

Finishes the frame drawing.

Method on mglGraph: int GetNumFrame ()

Gets the number of created frames.

Method on mglGraph: void ResetFrames ()

Reset frames counter (start it from zero).

Method on mglGraph: void StartGIF (const char *fname, int ms=100)

Start writing frames into animated GIF file fname. Parameter ms set the delay between frames in milliseconds. You should not change the picture size during writing the cinema. Use CloseGIF() to finalize writing. Note, that this function is disabled in OpenGL mode.

Method on mglGraph: int CloseGIF ()

Finish writing animated GIF and close connected pointers.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.17 IDTF functions

These functions provide IDTF specific features. In all other cases they do nothing.

Method on mglGraph: void VertexColor (bool enable)

Enables smooth color change.

Method on mglGraph: void Compression (bool enable)

Gives smaller files, but quality degrades.

Method on mglGraph: void StartGroup (const char *name)

Starts group definition. Groups contain objects and other groups, they are used to select a part of a model to zoom to or to make invizible or to make transparent and so on.

Method on mglGraph: void EndGroup ()

Ends group definition.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by root on December 28, 2009 using texi2html 1.82.