[ < ] [ > ]   [ << ] [ 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.

There is a C++ wrapper class which have the same name mglGraph and defined in mgl/mgl_graph.h. You can use this class even with non-GNU compilers (i.e. in Borland or Microsoft one), but you should not include any mgl/mgl.h or mgl/mgl_parse.h headers in this case! This wrapper class also used as base for all SWIG-based interfaces (Python, Octave and so on). So, later it is refered as ‘Python’ class for distinguish from original ‘C++’ class defined in mgl/mgl.h .


[ < ] [ > ]   [ << ] [ 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 (C++, Python): void DefaultPlotParam ()
C function: void mgl_set_def_param (HMGL gr)

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). Function SetAlphaDef specify the default value of alpha-channel. You may switch off transparency of selected plot by function SetTransparent. Finally, function SetTranspType set the kind of transparency. See section Transparent surface sample, for sample code and picture.

Method on mglGraph (C++, Python): bool Alpha (bool enable)
C function: void mgl_set_alpha (HMGL gr, int enable)

Sets the transparency on/off and returns previous value of transparency. It is recommended to call this function before any plotting command. 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 SetTransparent(false) in particular plot to disable its transparency.

Method on mglGraph (C++, Python): void SetAlphaDef (float val)
C function: void mgl_set_alpha_default (HMGL gr, float alpha)

Sets 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.

Method on mglGraph (C++, Python): void SetTransparent (bool val)
C function: void mgl_set_transp (HMGL gr, int enable)

Flag which temporary switches transparency on/off for the plot. This is the same as Alpha(val) but more correctly work in mglGraphGL class.

Method on mglGraph (C++, Python): void SetTranspType (int type)
C function: void mgl_set_transp_type (HMGL gr, int enable)

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 SetAlphaDef(0.3) or less for lamp-like transparency. See section Normal transparency, Glass-like transparency, Lamp-like transparency.

Obsolete option of mglGraph: float AlphaDef

Default value of alpha channel. See SetAlphaDef().

Obsolete option of mglGraph: bool Transparent

Flag which temporary switches transparency on/off for the plot. See SetTransparent().

Obsolete option of mglGraph: int TranspType

This variable set the transparency type. See SetTranspType().


[ < ] [ > ]   [ << ] [ 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 (C++, Python): bool Light (bool enable)
C function: void mgl_set_light (HMGL gr, int enable)

Sets the using of light on/off for overall plot. Function returns previous value of lighting. Default value is lightning off.

Method on mglGraph (C++, Python): void Light (int n, bool enable)
C function: void mgl_set_light_n (HMGL gr, int n, int enable)

Switch on/off n-th light source separately.

Method on mglGraph (C++, Python): void AddLight (int n, float x, float y, float z, char c='w')
Method on mglGraph (C++): void Light (int n, mglPoint p, char c='w', float bright=0.5, bool infty=true)
Method on mglGraph (C++): void Light (int n, mglPoint p, mglColor c, float bright=0.5, bool infty=true)
C function: void mgl_add_light (HMGL gr, int n, float x, float y, float z, char c)

The function adds a light source with identification n at position p with color c and with brightness bright (which must be in range [0,1]). Flag infty=true puts the source to infinite distance (for the faster drawing).

Method on mglGraph (C++, Python): void Ambient (float bright=0.5)
C function: void mgl_set_ambbr (HMGL gr, float bright)

Sets the brightness of ambient light. The value should be in range [0,1].


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

3.1.3 Fog

Method on mglGraph (C++, Python): void Fog (float d, float dz=0.25)
C function: void mgl_set_fog (HMGL gr, float d, float dz)

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 (C++, Python): void SetBarWidth ( float val)
C function: void mgl_set_bar_width (HMGL gr, float val)

Sets relative width of rectangles in Bars, Barh, BoxPlot (see section Bars). Default value is 0.7.

Method on mglGraph (C++, Python): void SetMarkSize (float val)
C function: void mgl_set_mark_size (HMGL gr, float val)

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

Method on mglGraph (C++, Python): void SetArrowSize (float val)
C function: void mgl_set_arrow_size (HMGL gr, float val)

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

Method on mglGraph (C++, Python): void SetBaseLineWidth (float val)
C function: void mgl_set_base_line_width (HMGL gr, float val)

Defines 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.

Method on mglGraph (C++, Python): void SetTickLen (float val, float stt=1)
C function: void mgl_set_tick_len (HMGL gr, float val, float stt)

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 (C++, Python): void SetTickStl (const char *stl, const char *sub=0)
C function: void mgl_set_tick_stl (HMGL gr, 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).

Obsolete option of mglGraph: float BarWidth

Relative width of rectangles. See SetBarWidth().

Obsolete option of mglGraph: float MarkSize

The size of marks. See SetMarkSize().

Obsolete option of mglGraph: float ArrowSize

The size of arrows. See SetArrowSize().

Obsolete option of mglGraph: float BaseLineWidth

The variable define the base width for all lines. See SetBaseLineWidth().


[ < ] [ > ]   [ << ] [ 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.

Method on mglGraph (C++, Python): void SetPlotFactor (float val)
C function: void mgl_set_plotfactor (HMGL gr, float val)

Sets the factor of plot size. It is not recommended to set it lower then 1.5. This is some analogue of function Zoom() but applied not to overall image but for each InPlot. Use negative value or zero to enable automatic PlotFactor selection.

Method on mglGraph (C++, Python): void Zoom (float x1, float y1, float x2, float y2)
C function: void mgl_set_zoom (HMGL gr, 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.

Obsolete option of mglGraph: float PlotFactor

The factor of plot size. See SetPlotFactor().

Obsolete option of mglGraph: bool AutoPlotFactor

Switch on/off automatic change of PlotFactor variable during plot rotation. See SetPlotFactor().


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

3.1.6 Cutting

These variables and functions set the condition when the points are excluded (cutted) from the drawing. Note, that a point with NAN value(s) of coordinate or amplitude will be automatically excluded from the drawing.

Method on mglGraph (C++, Python): void SetCut (bool val)
C function: void mgl_set_cut (HMGL gr, int val)

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.

cut

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

Method on mglGraph (C++, Python): void SetCutBox (float x1, float y1, float z1, float x2, float y2, float z2)
C function: void mgl_set_cut_box (HMGL gr, float x1, float y1, float z1, float x2, float y2, float z2)

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.

Method on mglGraph (C++, Python): void CutOff (const char *EqC)
C function: void mgl_set_cutoff (HMGL gr, 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 "" to disable cutting off condition. See section CutOff sample, for sample code and picture.

Obsolete option of mglGraph: bool Cut

Flag which determines how points outside bounding box are drawn. See SetCut().

Obsolete option of mglGraph: mglPoint CutMin, CutMax

Lower and upper edge of the box in which never points are drawn. See SetCutBox().


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

3.1.7 Font settings

Method on mglGraph (C++, Python): void SetFontSize (float val)
C function: void mgl_set_font_size (HMGL gr, float val)

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

Method on mglGraph (C++, Python): void SetFontDef (const char *fnt)
C function: void mgl_set_font_def (HMGL gr, const char * val)

Sets the font specification (see section Text printing). Default is ‘rC’ – Roman font centering.

Method on mglGraph (C++, Python): void SetRotatedText (bool val)
C function: void mgl_set_rotated_text (HMGL gr, int val)

Sets to use or not text rotation along axis.

Method on mglGraph (C++, Python): void LoadFont (const char *name, const char *path="")
C function: void mgl_load_font (HMGL gr, const char *name, const char *path)

Load font typeface from path/name.

Method on mglGraph (C++, Python): void CopyFont (mglGraph * from)
C function: void mgl_copy_font (HMGL gr, HMGL gr_from)

Copy font data from another mglGraph object.

Method on mglGraph (C++, Python): void RestoreFont ()
C function: void mgl_restore_font (HMGL gr)

Restore font data to default typeface.

Method on mglGraph (C++): 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 (C++): 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 (C++): 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 (C++): 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=="" then default font is used.

Method on mglGraph (C++): inline mglFont * GetFont ()

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

Obsolete option of mglGraph: float FontSize

The font size. See SetFontSize().

Obsolete option of mglGraph: char FontDef[32]

Font style. See SetFontDef().

Obsolete option of mglGraph: bool RotatedText

Set to use or not text rotation along axis.


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

3.1.8 Pallete and colors

Method on mglGraph (C++, Python): void SetPalette (const char *colors)
C function: void mgl_set_palette (HMGL gr, 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.

Method on mglGraph (C++, Python): void SetPalColor (int n, float r, float g, float b)
C function: void mgl_set_pal_color (HMGL gr, int n, float r, float g, float b)

Sets color for individual palette entry. Look at SetPalette() function for simplified palette setting.

Method on mglGraph (C++, Python): void SetPalNum (int num)
C function: void mgl_set_pal_num (HMGL gr, int num)

Sets the number of actual colors in palette. The value must be less then 100.

Method on mglGraph (C++, Python): void SetScheme (const char *sch)
C function: void mgl_set_scheme (HMGL gr, const char *sch)

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

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

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

Obsolete option of mglGraph: mglColor Pal[101]

Color palette for 1D plotting. See SetPalette().

Obsolete option of mglGraph: int NumPal

Number of actual colors in palette. See SetPalette().


[ < ] [ > ]   [ << ] [ 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. Only last warning will be saved. All warnings/errors produced by MathGL is not critical – the plot just will not be drawn.

Method on mglGraph (C++): 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);.

General option (C++) 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

Method on mglGraph (C++, Python): int GetWarnCode ()
C function: int mgl_get_warn_code (HMGL gr)

Return the 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

Obsolete option of mglGraph: int WarnCode

Numerical ID of warning about the not drawn plot.


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

3.1.10 Other settings

Method on mglGraph (C++, Python): void SetMeshNum (int val)
C function: void mgl_set_meshnum (HMGL gr, int num)

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.

Method on mglGraph (C++, Python): void SetAxialDir (char val)
C function: mgl_set_axial_dir (HMGL gr, char dir)

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

Method on mglGraph (C++, Python): void SetDrawFace (bool val)
C function: void mgl_set_draw_face (HMGL gr, int val)

Enable/disable faces drawing. It is useful for speeding up drawing (for example, during rotation and so on).

General option (C++) of mglGraph: const char * PlotId

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

Obsolete option of mglGraph: int MeshNum

Sets approximate number of lines/hachures/cells. See SetMeshNum().

Obsolete option of mglGraph: char AxialDir

Set rotation direction. See SetAxialDir().

Obsolete option of mglGraph: bool DrawFace

Flag for preventing faces drawing. See SetDrawFace().

General option (C++) 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 (C++) of mglGraph: int GridPnts

Number of points used for grid lines drawing (it is important for curved coordinates). Default value is 50.


[ < ] [ > ]   [ << ] [ 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 (C++, Python): void SetRanges (float x1, float x2, float y1, float y2, float z1=0, float z2=0)
Method on mglGraph (C++): void Axis (mglPoint min, mglPoint max, mglPoint org=mglPoint(NAN,NAN,NAN))
C function: void mgl_set_axis_2d (HMGL gr, float x1, float y1, float x2, float y2)
C function: void mgl_set_axis_3d (HMGL gr, float x1, float y1, float z1, float x2, float y2, float z2)

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 (C++, Python): void SetCRange (float min, float max)
Method on mglGraph (C++): void CAxis (float min, float max)
C function: void mgl_set_caxis (HMGL gr, float min, float max)

Safely sets minimal and maximal values of data for coloring. This values are used later for determining the color of the surface.

Method on mglGraph (C++, Python): void XRange (const mglData & dat, bool add=false, float fact=0)
C function: void mgl_set_xrange (HMGL gr, const HMDT a, int add)

Sets values of Min.x and Max.x as minimal and maximal values of data a. Parameter add specify to add or not the new range to current one. Parameter fact add additional range increase on value (Max-Min)*fact. See also Axis().

Method on mglGraph (C++, Python): void YRange (const mglData & dat, bool add=false, float fact=0)
C function: void mgl_set_yrange (HMGL gr, const HMDT a, int add)

Sets values of Min.y and Max.y as minimal and maximal values of data a. Parameter add specify to add or not the new range to current one. Parameter fact add additional range increase on value (Max-Min)*fact. See also Axis().

Method on mglGraph (C++, Python): void ZRange (const mglData & dat, bool add=false, float fact=0)
C function: void mgl_set_zrange (HMGL gr, const HMDT a, int add)

Sets values of Min.z and Max.z as minimal and maximal values of data a. Parameter add specify to add or not the new range to current one. Parameter fact add additional range increase on value (Max-Min)*fact. See also Axis().

Method on mglGraph (C++, Python): void CRange (const mglData & dat, bool add=false, float fact=0)
C function: void mgl_set_crange (HMGL gr, const HMDT a, int add)

Sets values of Cmin and Cmax as minimal and maximal values of data a. Parameter add specify to add or not the new range to current one. Parameter fact add additional range increase on value (Cmax-Cmin)*fact. See also CAxis().

Method on mglGraph (C++, Python): void SetAutoRanges (float x1, float x2, float y1=0, float y2=0, float z1=0, float z2=0)
C function: void mgl_set_auto (HMGL gr, float x1, float x2, float y1, float y2, float z1, float z2)

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).

Method on mglGraph (C++, Python): void SetOrigin (float x0, float y0, float z0=NAN)
C function: void mgl_set_origin (HMGL gr, float x0, float y0, float z0)

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

Method on mglGraph (C++): 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.

General option (C++) 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 (C++) of mglGraph: float Cmin, Cmax

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

General option (C++) 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 (C++) 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 Curved coordinates

Method on mglGraph (C++, Python): void SetFunc (const char *EqX, const char *EqY, const char *EqZ="", const char *EqA="")
C function: void mgl_set_func (HMGL gr, const char *EqX, const char *EqY, const char *EqZ)
C function: void mgl_set_func_ext (HMGL gr, const char *EqX, const char *EqY, const char *EqZ, const char *EqA)

Sets transformation formulas for curvilinear coordinate. Each string should contain mathematical expression for real coordinate depending on internal coordinates ‘x’, ‘y’, ‘z’ and ‘a’ or ‘c’ for colorbar. 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 empty or NULL. Using transformation formulas will slightly slowing the program. Parameter EqA set the similar transformation formula for color scheme. See section Textual formulas.

Method on mglGraph (C++, Python): void SetCoor (int how)
C function: void mgl_set_coor (HMGL gr, 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 (C++, Python): void Ternary (bool tern)
C function: void mgl_set_ternary (HMGL gr, int 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.


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

3.2.3 Ticks

Method on mglGraph (C++, Python): void AdjustTicks (const char *dir="xyz")
C function: void mgl_adjust_ticks (HMGL gr, 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 SetTuneTicks(true).

Method on mglGraph (C++, Python): void SetTicks (char dir, float d=-5, int ns=0, float org=NAN)
C function: void mgl_set_ticks_dir (HMGL gr, char dir, float d, int ns, float org)
C function: void mgl_set_ticks (HMGL gr, float dx, float dy, float dz)
C function: void mgl_set_subticks (HMGL gr, int nx, int ny, int nz)
C function: void mgl_set_tick_origin (HMGL gr, float x0, float y0, float z0)

Set the ticks step d, number of sub-ticks ns and initial ticks position org for the axis along direction dir (use ’c’ for colorbar ticks). 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 (C++, Python): void SetTicksVal (char dir, int n, float *val, const char **lbl)
Method on mglGraph (C++, Python): void SetTicksVal (char dir, int n, float *val, const wchar_t **lbl)
Method on mglGraph (C++): void SetTicksVal (char dir, int n, float val1, wchar_t *lbl1, ...)
C function: void mgl_set_ticks_vals (HMGL gr, char dir, int n, float *val, const char **lbl)
C function: void mgl_set_ticks_val (HMGL gr, char dir, int n, double val, const char *lbl, ...)

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.

Method on mglGraph (C++, Python): void SetTuneTicks (bool tune, float pos=1.15)
C function: void mgl_tune_ticks (HMGL gr, bool tune, float pos)

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). Also set the position pos of common multiplier/component on the axis: =0 at minimal axis value, =1 at maximal axis value. Default value is 1.15.

Method on mglGraph (C++, Python): void SetXTT (const char *xtt)
Method on mglGraph (C++, Python): void SetYTT (const char *ytt)
Method on mglGraph (C++, Python): void SetZTT (const char *ztt)
Method on mglGraph (C++, Python): void SetCTT (const char *ctt)
Method on mglGraph (C++, Python): void SetXTT (const wchar_t *xtt)
Method on mglGraph (C++, Python): void SetYTT (const wchar_t *ytt)
Method on mglGraph (C++, Python): void SetZTT (const wchar_t *ztt)
Method on mglGraph (C++, Python): void SetCTT (const wchar_t *ctt)
C function: void mgl_set_xttw (HMGL gr, const wchar_t *xtt)
C function: void mgl_set_yttw (HMGL gr, const wchar_t *ytt)
C function: void mgl_set_zttw (HMGL gr, const wchar_t *ztt)
C function: void mgl_set_cttw (HMGL gr, const wchar_t *ctt)
C function: void mgl_set_xtt (HMGL gr, const wchar_t *xtt)
C function: void mgl_set_ytt (HMGL gr, const wchar_t *ytt)
C function: void mgl_set_ztt (HMGL gr, const wchar_t *ztt)
C function: void mgl_set_ctt (HMGL gr, const wchar_t *ctt)

The template for x-,y-,z-axis ticks or colorbar ticks. It may contain TeX symbols also. If xtt, ytt, ztt, ctt="" then default template is used (in simplest case it is ‘%.2g’). Setting of template switch off automatic ticks tuning (see SetTuneTicks()).

Obsolete option of mglGraph: float dx, dy, dz

Step for axis ticks. See SetTicks().

Obsolete option of mglGraph: int NSx, NSy, NSz

Number of axis sub-ticks. See SetTicks().

Obsolete option of mglGraph: mglPoint OrgT

Starting point for ticks. See SetTicks().

Obsolete option of mglGraph: bool TuneTicks

Switch on/off ticks enhancing by factoring common multiplier. See SetTuneTicks().

Obsolete option of mglGraph: float FactorPos

The position of common multiplier/component on the axis. See SetTuneTicks().


[ < ] [ > ]   [ << ] [ 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 (C++, Python): void SubPlot (int nx, int ny, int m, float dx=0, float dy=0)
C function: void mgl_subplot (HMGL gr, int nx, int ny, int m)
C function: void mgl_subplot_d (HMGL gr, int nx, int ny, int m, float dx, float dy)

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 (C++, Python): void SubPlot (int nx, int ny, int m, const char *style)
C function: void mgl_subplot_s (HMGL gr, int nx, int ny, int m, const char *style)

The same as previous but space reserved for axis/colorbar is saved only if style contain: ‘L’ or ‘<’ – at left side, ‘R’ or ‘>’ – at right side, ‘A’ or ‘^’ – at top side, ‘U’ or ‘_’ – at bottom side.

Method on mglGraph (C++, Python): void InPlot (float x1, float x2, float y1, float y2, bool rel=false)
C function: void mgl_inplot (HMGL gr, float x1, float x2, float y1, float y2)
C function: void mgl_relplot (HMGL gr, float x1, float x2, float y1, float y2)

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 (C++, Python): void ColumnPlot (int num, int ind, float d=0)
C function: void mgl_columnplot (HMGL gr, int num, int ind)
C function: void mgl_columnplot_d (HMGL gr, int num, int ind, float d)

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). Parameter d set extra gap between cells. See section ColumnPlot sample, for sample code and picture.

Method on mglGraph (C++, Python): void StickPlot (int num, int ind, float tet, float phi)
C function: void mgl_stickplot (HMGL gr, int num, int ind, float tet, float phi)

Puts further plotting in ind-th cell of stick with num cells. At this, stick is rotated on angles tet, phi. The position is relative to previous SubPlot() call (or InPlot() with rel=false). See section StickPlot sample, for sample code and picture.

Method on mglGraph (C++, Python): void Rotate (float TetX, float TetZ, float TetY=0)
C function: void mgl_rotate (HMGL gr, float TetX, float TetZ, float TetY)

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

Method on mglGraph (C++, Python): void RotateN (float Tet, float x, float y, float z)
C function: void mgl_rotate_vector (HMGL gr, float Tet, float x, float y, float z)

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

Method on mglGraph (C++, Python): void Aspect (float Ax, float Ay, float Az)
C function: void mgl_aspect (HMGL gr, 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 (C++, Python): void Perspective (float a)
C function: void mgl_perspective (HMGL gr, 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 (C++, Python): void Identity (bool rel=false)
C function: void mgl_identity (HMGL gr, int rel)

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,rel).

Method on mglGraph (C++, Python): void Push ()
C function: void mgl_mat_push (HMGL gr)

Push transformation matrix into stack. Later you can restore its current state by Pop() function. Stack can keep up to 10 matrices.

Method on mglGraph (C++, Python): void Pop ()
C function: void mgl_mat_pop (HMGL gr)

Pop (restore last ’pushed’) transformation matrix into stack.


[ < ] [ > ]   [ << ] [ 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 (C++, Python): void WriteFrame (const char *fname="", const char *descr="")
C function: void mgl_write_frame (HMGL gr, const char *fname, const char *descr)

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

Method on mglGraph (C++, Python): void WritePNG (const char *fname, const char *descr="", int compr="", bool alpha=true)
C function: void mgl_write_png (HMGL gr, const char *fname, const char *descr)
C function: void mgl_write_png_solid (HMGL gr, const char *fname, const char *descr)

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 (C++, Python): void WriteJPEG (const char *fname, const char *descr="")
C function: void mgl_write_jpg (HMGL gr, const char *fname, const char *descr)

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 (C++, Python): void WriteGIF (const char *fname, const char *descr="")
C function: void mgl_write_gif (HMGL gr, const char *fname, const char *descr)

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 (C++, Python): void WriteBMP (const char *fname, const char *descr="")
C function: void mgl_write_bmp (HMGL gr, const char *fname, const char *descr)

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 (C++, Python): void WriteEPS (const char *fname, const char *descr="")
C function: void mgl_write_eps (HMGL gr, const char *fname, const char *descr)

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. If file name is terminated by ‘z’ (for example, ‘fname.eps.gz’) then file will be compressed in gzip format.

Method on mglGraph (C++, Python): void WriteSVG (const char *fname, const char *descr="")
C function: void mgl_write_svg (HMGL gr, const char *fname, const char *descr)

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). If file name is terminated by ‘z’ (for example, ‘fname.svgz’) then file will be compressed in gzip format.

Method on mglGraph (C++, Python): void WriteIDTF (const char *fname, const char *descr="")
C function: void mgl_write_idtf (HMGL gr, const char *fname, const char *descr)

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 (C++, Python): void ShowImage (const char *viewer="kuickshow", bool nowait=false)
C function: void mgl_show_image (const char *viewer, int nowait)

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 (C++, Python): void SetSize (int width, int height)
C function: void mgl_set_size (HMGL gr, 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 (C++, Python): void Flush ()
C function: void mgl_flush (HMGL gr)

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.

Method on mglGraph (C++): void Finish ()

Finishes plotting and create a picture. Normally this function is called 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 (C++, Python): void Clf (mglColor Back=WC)
C function: void mgl_clf (HMGL gr)
C function: void mgl_clf_rgb (HMGL gr, float r, float g, float b)

Clear the picture and fill it by color Back.

Method on mglGraph (C++): void Ball (float x, float y, float z, mglColor col=RC, float alpha=1)
Method on mglGraph (C++): void Ball (mglPoint p, char col='r')
Method on mglGraph (Python): void Ball (float x, float y, float z, char col='r')
C function: void mgl_ball (HMGL gr, float x, float y, float z)
C function: void mgl_ball_rgb (HMGL gr, float x, float y, float z, float r, float g, float b, float alpha)
C function: void mgl_ball_str (HMGL gr, float x, float y, float z, char col)

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

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

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

Method on mglGraph (C++): void Line (mglPoint p1, mglPoint p2, char *stl="B", intnum=2)
Method on mglGraph (Python): void Line (float x1, float y1, float z1, float x2, float y2, float z2, char *stl="B", intnum=2)
C function: void mgl_line (HMGL gr, float x1, float y1, float z1, float x2, float y2, float z2, char *stl, intnum)

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 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 (C++): void Curve (mglPoint p1, mglPoint d1, mglPoint p2, mglPoint d2, const char *stl="B", int num=100)
Method on mglGraph (Python): void Curve (float x1, float y1, float z1, float dx1, float dy1, float dz1, float x2, float y2, float z2, float dx2, float dy2, float dz2, const char *stl="B", int num=100)
C function: void mgl_curve (HMGL gr, float x1, float y1, float z1, float dx1, float dy1, float dz1, float x2, float y2, float z2, float dx2, float dy2, float dz2, const char *stl, int num)

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 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 (C++): void Face (mglPoint p1, mglPoint p2, mglPoint p3, mglPoint p4, const char *stl="w", int num=2, float val=NAN)

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. In first case parameter val (if not NAN) set the color according color scheme. Face will be drawn even if it lies out of bounding box.

Method on mglGraph (C++, Python): void FaceX (float x0, float y0, float z0, float wy, float wz, const char *stl="w", float dx=0, float dy=0)
Method on mglGraph (C++, Python): void FaceY (float x0, float y0, float z0, float wx, float wz, const char *stl="w", float dx=0, float dy=0)
Method on mglGraph (C++, Python): void FaceZ (float x0, float y0, float z0, float wx, float wy, const char *stl="w", float dx=0, float dy=0)
C function: void mgl_facex (HMGL gr, float x0, float y0, float z0, float wy, float wz, const char *stl, float d1, float d2)
C function: void mgl_facey (HMGL gr, float x0, float y0, float z0, float wx, float wz, const char *stl, float d1, float d2)
C function: void mgl_facez (HMGL gr, float x0, float y0, float z0, float wx, float wy, const char *stl, float d1, float d2)

Draws the solid rectangle (face) perpendicular to [x,y,z]-axis correspondingly at position {x0, y0, z0} with color stl and with widths wx, wy, wz along corresponding directions. At this colors can be the same for all vertexes or separately if all 4 colors are specified for each vertex. Parameters d1!=0, d2!=0 set additional shift of the last vertex (i.e. to draw quadrangle).

Method on mglGraph (C++): void Sphere (mglPoint p, float r, const char *stl="r")
Method on mglGraph (Python): void Sphere (float x0, float y0, float z0, float r, const char *stl="r")
C function: void mgl_sphere (HMGL gr, float x0, float y0, float z0, float r, const char *stl)

Draw the sphere with radius r and center at point p={x, y, z} and color stl.

Method on mglGraph (C++): void Drop (mglPoint p, mglPoint q, float r, mglColor col, float shift=1, float ap=1)
Method on mglGraph (C++): void Drop (mglPoint p, mglPoint q, float r, const char *col="r", float shift=1, float ap=1)
Method on mglGraph (Python): void Drop (float x0, float y0, float z0, float dx, float dy, float dz, float r, const char *col="r", float shift=1, float ap=1)
C function: void mgl_drop (HMGL gr, float x0, float y0, float z0, float dx, float dy, float dz, float r, const char *col, float shift, float ap)

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 (C++): void Cone (mglPoint p1, mglPoint p2, float r1, float r2=-1, const char *stl="B", bool edge=false)
Method on mglGraph (Python): void Cone (float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2=-1, const char *stl="B", bool edge=false)
C function: void mgl_cone (HMGL gr, float x1, float y1, float z1, float x2, float y2, float z2, float r1, float r2, const char *stl, int draw_edge)

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 (C++): void Mark (mglPoint p, char mark='.')
Method on mglGraph (Python): void Mark (float x, float y, float z, char mark='.')
C function: void mgl_mark (HMGL gr, float x, float y, float z, char mark)

Draws a marks of different type at position p.

Method on mglGraph (C++): 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 (for detail see section Font styles). 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 Line styles) 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. For example, string ‘iC:b’ correspond to italic font style for centered text which printed by blue color.

If string contains symbols ‘aA’ then text is printed at arbitrary position {x, y} (supposed to be in range [0,1]) of subplot (for ‘a’) or picture (for ‘A’).

Method on mglGraph (C++): void Puts (mglPoint p, const char *text, const char *font="", float size=-1, char dir=0, float shift=0)
Method on mglGraph (C++): void Putsw (mglPoint p, const wchar_t *text, const char *font="", float size=-1, char dir=0, float shift=0)
Method on mglGraph (Python): void Puts (float x, float y, float z, const char *text, const char *font="", float size=-1, char dir=0)
C function: void mgl_puts (HMGL gr, float x, float y, float z, const char *text)
C function: void mgl_putsw (HMGL gr, float x, float y, float z, const wchar_t *text)
C function: void mgl_puts_ext (HMGL gr, float x, float y, float z, const char *text, const char *font, float size, char dir)
C function: void mgl_putsw_ext (HMGL gr, float x, float y, float z, const wchar_t *text, const char *font, float size, char dir)

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 (C++): float Puts (mglPoint p, mglPoint l, const char *text, charwhere='t', float size=-1)
Method on mglGraph (C++): float Putsw (mglPoint p, mglPoint l, const wchar_t *text, charwhere='t', float size=-1)
Method on mglGraph (Python): void Puts (float x, float y, float z, float dx, float dy, float dz, const char *text, charwhere='t', float size=-1)
C function: void mgl_puts_dir (HMGL gr, float x, float y, float z, float dx, float dy, float dz, const char *text, float size)
C function: void mgl_putsw_dir (HMGL gr, float x, float y, float z, float dx, float dy, float dz, const wchar_t *text, float size)

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 (C++): void Text (mglPoint p, const char *text, const char *font="", float size=-1, char dir=0)
Method on mglGraph (C++): void Text (mglPoint p, const wchar_t *text, const char *font="", 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 (C++): void Printf (mglPoint p, const char *arg, ...)

Print formatted string at point p.

Method on mglGraph (C++): void Label (float x, float y, const char *text, const char *font="", float size=-1)
Method on mglGraph (C++): void Labelw (float x, float y, const wchar_t *text, const char *font="", float size=-1)
C function: void mgl_label_xy (HMGL gr, float x, float y, const char *text, const char *font, float size)
C function: void mgl_labelw_xy (HMGL gr, float x, float y, const wchar_t *text, const char *font, float size)

The function draws the string text at position {x, y} with fonts specifying by font. The size of font is set by size parameter (default is FontSize). Coordiantes x, y are supposed to be in range [0,1].

Method on mglGraph (C++): void Title (const char *text, const char *font=0, float size=-2)
Method on mglGraph (C++): void Title (const wchar_t *text, const char *font=0, float size=-2)
Method on mglGraph (Python): void Title (const char *text, const char *font=0, int size=-2)
C function: void mgl_title (HMGL gr, const char *text, const char *font, int size)
C function: void mgl_titlew (HMGL gr, const wchar_t *text, const char *font, int size)

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 (C++, Python): void Text (const mglData &y, const char *text, const char *font="", float size=-1)
Method on mglGraph (C++): void Text (const mglData &y, const wchar_t *text, const char *font="", float size=-1)
Method on mglGraph (C++, Python): void Text (const mglData &x, const mglData &y, const char *text, const char *font="", float size=-1)
Method on mglGraph (C++): void Text (const mglData &x, const mglData &y, const wchar_t *text, const char *font="", float size=-1)
Method on mglGraph (C++, Python): void Text (const mglData &x, const mglData &y, const mglData &z, const char *text, const char *font="", float size=-1)
Method on mglGraph (C++): void Text (const mglData &x, const mglData &y, const mglData &z, const wchar_t *text, const char *font="", float size=-1)
C function: void mgl_text_y (HMGL gr, const HMDT y, const char *text, const char *font, float size)
C function: void mgl_text_xy (const HMDT x, const HMDT y, const char *text, const char *font, float size)
C function: void mgl_text_xyz (const HMDT x, const HMDT y, const HMDT z, const char *text, const char *font, float size)

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 (C++, Python): void Axis (const char *dir="xyz", bool adjust=false)
C function: void mgl_axis (HMGL gr, const char *dir)

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()). You may specified an arrow at the end of axis (see see section Line styles)

Method on mglGraph (C++, Python): void Colorbar (const char *sch="", int where=0)
C function: void mgl_colorbar (HMGL gr, const char *sch, int where)

Draws colorbar with color scheme sch (current scheme if sch="") 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. If string sch contains ‘<>^_’ then the parameter pos is defined as: pos=0 for ‘>’ (right), pos=1 for ‘<’ (left), pos=2 for ‘^’ (top), pos=3 for ‘_’ (bottom). If string have ‘A’ then absolute (relative to picture) coordinates is used. See section Dens sample, for sample code and picture.

Method on mglGraph (C++, Python): void Colorbar (const mglData &v, const char *sch="", int where=0)
C function: void mgl_colorbar_val (HMGL gr, const HMDT v, const char *sch, int where)

The same as previous but with sharp colors sch (current palette if sch="") for values v. See section ContD sample, for sample code and picture.

Method on mglGraph (C++, Python): void Colorbar (const char *sch, int where, float x, float y, float w, float h)
Method on mglGraph (C++, Python): void Colorbar (int where, float x, float y, float w, float h)
C function: void mgl_colorbar_ext (HMGL gr, const char *sch, int where, float x, float y, float w, float h)

The same as first one but at arbitrary position of subplot {x, y} (supposed to be in range [0,1]). Parameters w, h set the relative width and height of the colorbar.

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

The same as previous but with sharp colors sch (current palette if sch="") for values v. See section ContD sample, for sample code and picture.

Method on mglGraph (C++, Python): void Grid (const char *dir="xyz", const char *pen="B-")
C function: void mgl_axis_grid (HMGL gr, const char *dir, const char *pen)

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 (C++, Python): void Box (const char *col="", bool ticks=true)
Method on mglGraph (C++): void Box (mglColor col, bool ticks=true)
C function: void mgl_box (HMGL gr, int ticks)
C function: void mgl_box_rgb (HMGL gr, float r, float g, float b, int ticks)
C function: void mgl_box_str (HMGL gr, const char *col, int ticks)

Draws bounding box outside the plotting volume with color col.

Method on mglGraph (C++, Python): void Label (char dir, const char *text, float pos=0, float size=-1.4, float shift=0)
Method on mglGraph (C++): void Label (char dir, const wchar_t *text, float pos=0, float size=-1.4, float shift=0)
C function: void mgl_label (HMGL gr, char dir, const char *text)
C function: void mgl_label_ext (HMGL gr, char dir, const char *text, float pos, float size, float shift)
C function: void mgl_labelw_ext (HMGL gr, char dir, const wchar_t *text, float pos, float size, float shift)

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 TeX parsing). The arrays of strings 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. If string font contains symbol ‘A’ then legend coordinates set position in the picture (not in the current subplot). See section Legend sample, for sample code and picture.

Method on mglGraph (C++, Python): void Legend (int where=0x3, const char *font="rL", float size=-0.8, float llen=0.1)
C function: void mgl_legend (HMGL gr, int where, const char *font, float size, float llen)

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 (C++): 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 (C++, Python): void Legend (float x, float y, const char *font="rL", float size=-0.8, float llen=0.1)
C function: void mgl_legend_xy (HMGL gr, float x, float y, const char *font, float size, float llen)

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 (C++): 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 (C++, Python): void AddLegend (const char *text, const char *style)
Method on mglGraph (C++): void AddLegend (const wchar_t *text, const char *style)
C function: void mgl_add_legend (HMGL gr, const char *text, const char *style)
C function: void mgl_add_legendw (HMGL gr, 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 (C++, Python): void ClearLegend ()
C function: void mgl_clear_legend (HMGL gr)

Clears saved legend strings.

Method on mglGraph (C++, Python): void SetLegendBox (bool enable)
C function: void mgl_set_legend_box (HMGL gr, int enable)

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

Method on mglGraph (C++, Python): void SetLegendMarks (int num)
C function: void mgl_set_legend_marks (HMGL gr, int num)

Set the number of marks in the legend. By default 1 mark is used.

Obsolete option of mglGraph: bool LegendBox

Switch on/off drawing box near legend. See SetLegendBox().


[ < ] [ > ]   [ << ] [ 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 "" 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. See section 1D plot sample, for sample code and picture.


[ < ] [ > ]   [ << ] [ 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="") 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 (C++, Python): void Plot (const mglData &x, const mglData &y, const mglData &z, const char *pen="")
C function: void mgl_plot_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *pen)

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

Method on mglGraph (C++, Python): void Plot (const mglData &x, const mglData &y, const char *pen="")
C function: void mgl_plot_xy (HMGL gr, const HMDT x, const HMDT y, const char *pen)

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

Method on mglGraph (C++, Python): void Plot (const mglData &y, const char *pen="")
C function: void mgl_plot (HMGL gr, const HMDT y, const char *pen)

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].


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

3.9.2 Radar

Method on mglGraph (C++, Python): void Radar (const mglData &a, const char *pen="", float r=-1)
C function: void mgl_radar (HMGL gr, const HMDT a, const char *pen, float r)

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="") 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="") 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 (C++, Python): void Tens (const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *pen="")
C function: void mgl_tens_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *pen)

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 (C++, Python): void Tens (const mglData &x, const mglData &y, const mglData &c, const char *pen="")
C function: void mgl_tens_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT c, const char *pen)

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 (C++, Python): void Tens (const mglData &y, const mglData &c, const char *pen="")
C function: void mgl_tens (HMGL gr, const HMDT y, const HMDT c, const char *pen)

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="") solid line with color from palette is used (see section Pallete and colors). Also you can use gradient filling if number of specified colors is equal to 2*number of curves. If string contain symbol ‘a’ then lines are drawn one above another (like summation) – you can reach the same effect if call y.CumSum("y"); before plot. See also Plot, Bars, Stem. See section Area sample, for sample code and picture.

Method on mglGraph (C++, Python): void Area (const mglData &x, const mglData &y, const mglData &z, const char *pen="")
C function: void mgl_area_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *pen)

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 (C++, Python): void Area (const mglData &x, const mglData &y, const char *pen="")
C function: void mgl_area_xy (HMGL gr, const HMDT x, const HMDT y, const char *pen)

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.

Method on mglGraph (C++, Python): void Area (const mglData &y, const char *pen="")
C function: void mgl_area (HMGL gr, const HMDT y, const char *pen)

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].


[ < ] [ > ]   [ << ] [ 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="") color from palette is used (see section Pallete and colors). Also you can use gradient filling if number of specified colors is equal to 2*number of curves. See also Area, Bars, Stem. See section Region sample, for sample code and picture.

Method on mglGraph (C++, Python): void Region (const mglData &x, const mglData &y1, const mglData &y2, const char *pen="", float zVal=NAN, bool inside=true)
C function: void mgl_region_xy (HMGL gr, const HMDT x, const HMDT y1, const HMDT y2, const char *pen, int inside)

The function fills area between curves {x[i], y1[i]} and {x[i], y2[i]} at z=zVal. Parameter inside=false set to fill are with y1<y<y2 else the area with y2<y<y1 will be also filled.

Method on mglGraph (C++, Python): void Region (const mglData &y1, const mglData &y2, const char *pen="", float zVal=NAN, bool inside=true)
C function: void mgl_region (HMGL gr, const HMDT y1, const HMDT y2, const char *pen, int inside)

The function fills area between curves {x[i], y1[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 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="") solid line with color from palette is used (see section Pallete and colors). See also Area, Bars, Plot, Mark. See section Stem sample, for sample code and picture.

Method on mglGraph (C++, Python): void Stem (const mglData &x, const mglData &y, const mglData &z, const char *pen="")
C function: void mgl_stem_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *pen)

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

Method on mglGraph (C++, Python): void Stem (const mglData &x, const mglData &y, const char *pen="")
C function: void mgl_stem_xy (HMGL gr, const HMDT x, const HMDT y, const char *pen)

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 (C++, Python): void Stem (const mglData &y, const char *pen="")
C function: void mgl_stem (HMGL gr, const HMDT y, const char *pen)

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].


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

3.9.7 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="") solid line with color from palette is used (see section Pallete and colors). If string contain symbol ‘a’ then lines are drawn one above another (like summation). If string contain symbol ‘f’ then waterfall chart is drawn for determining the cumulative effect of sequentially introduced positive or negative values. You can different colors for positive and negative values if number of specified colors is equal to 2*number of curves. See also Barh, Area, Stem, Chart, Default sizes. See section Bars sample, for sample code and picture.

Method on mglGraph (C++, Python): void Bars (const mglData &x, const mglData &y, const mglData &z, const char *pen="")
C function: void mgl_bars_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *pen)

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

Method on mglGraph (C++, Python): void Bars (const mglData &x, const mglData &y, const char *pen="")
C function: void mgl_bars_xy (HMGL gr, const HMDT x, const HMDT y, const char *pen)

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 (C++, Python): void Bars (const mglData &y, const char *pen="")
C function: void mgl_bars (HMGL gr, const HMDT y, const char *pen)

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].


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

3.9.8 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="") solid line with color from palette is used (see section Pallete and colors). If string contain symbol ‘a’ then lines are drawn one above another (like summation). See also Barh, Default sizes. See section Barh sample, for sample code and picture.

Method on mglGraph (C++, Python): void Barh (const mglData &y, const mglData &v, const char *pen="")
C function: void mgl_barh_xy (HMGL gr, const HMDT y, const HMDT v, const char *pen)

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 (C++, Python): void Barh (const mglData &v, const char *pen="")
C function: void mgl_barh (HMGL gr, const HMDT v, const char *pen)

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.9 Chart

Method on mglGraph (C++, Python): void Chart (const mglData &a, const char *col="")
C function: void mgl_chart (HMGL gr, const HMDT a, const char *col)

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.10 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="") 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 (C++, Python): void Step (const mglData &x, const mglData &y, const mglData &z, const char *pen="")
C function: void mgl_step_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *pen)

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

Method on mglGraph (C++, Python): void Step (const mglData &x, const mglData &y, const char *pen="")
C function: void mgl_step_xy (HMGL gr, const HMDT x, const HMDT y, const char *pen)

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

Method on mglGraph (C++, Python): void Step (const mglData &y, const char *pen="")
C function: void mgl_step (HMGL gr, const HMDT y, const char *pen)

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].


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

3.9.11 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="") 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 (C++, Python): void Torus (const mglData &r, const mglData &z, const char *pen="")
C function: void mgl_torus (HMGL gr, const HMDT r, const HMDT z, const char *pen)

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

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

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].


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

3.9.12 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="") 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 (C++, Python): void Tube (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen="")
Method on mglGraph (C++, Python): void Tube (const mglData &x, const mglData &y, const mglData &z, float r, const char *pen="")
C function: void mgl_tube_xyzr (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT r, const char *pen)
C function: void mgl_tube_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, float r, const char *pen)

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

Method on mglGraph (C++, Python): void Tube (const mglData &x, const mglData &y, const mglData &r, const char *pen="")
Method on mglGraph (C++, Python): void Tube (const mglData &x, const mglData &y, float r, const char *pen="")
C function: void mgl_tube_xyr (HMGL gr, const HMDT x, const HMDT y, const HMDT r, const char *pen)
C function: void mgl_tube_xy (HMGL gr, const HMDT x, const HMDT y, float r, const char *pen)

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 (C++, Python): void Tube (const mglData &y, const mglData &r, const char *pen="")
Method on mglGraph (C++, Python): void Tube (const mglData &y, float r, const char *pen="")
C function: void mgl_tube_r (HMGL gr, const HMDT y, const HMDT r, const char *pen)
C function: void mgl_tube (HMGL gr, const HMDT y, float r, const char *pen)

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.9.13 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="") 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 (C++, Python): void Mark (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen="")
C function: void mgl_mark_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT r, const char *pen)

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

Method on mglGraph (C++, Python): void Mark (const mglData &x, const mglData &y, const mglData &r, const char *pen="")
C function: void mgl_mark_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT r, const char *pen)

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

Method on mglGraph (C++, Python): void Mark (const mglData &y, const mglData &r, const char *pen="")
C function: void mgl_mark_y (HMGL gr, const HMDT y, const HMDT r, const char *pen)

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.14 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="") 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 (C++, Python): void TextMark (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *text, const char *fnt="")
Method on mglGraph (C++): void TextMark (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const wchar_t *text, const char *fnt="")
C function: void mgl_textmarkw_xyzr (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT r, const wchar_t *text, const char *fnt)
C function: void mgl_textmark_xyzr (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT r, const char *text, const char *fnt)

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

Method on mglGraph (C++, Python): void TextMark (const mglData &x, const mglData &y, const mglData &r, const char *text, const char *fnt="")
Method on mglGraph (C++): void TextMark (const mglData &x, const mglData &y, const mglData &r, const wchar_t *text, const char *fnt="")
C function: void mgl_textmarkw_xyr (HMGL gr, const HMDT x, const HMDT y, const HMDT r, const wchar_t *text, const char *fnt)
C function: void mgl_textmark_xyr (HMGL gr, const HMDT x, const HMDT y, const HMDT r, const char *text, const char *fnt)

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

Method on mglGraph (C++, Python): void TextMark (const mglData &y, const mglData &r, const char *text, const char *fnt="")
Method on mglGraph (C++): void TextMark (const mglData &y, const mglData &r, const wchar_t *text, const char *fnt="")
C function: void mgl_textmarkw_yr (HMGL gr, const HMDT y, const HMDT r, const wchar_t *text, const char *fnt)
C function: void mgl_textmark_yr (HMGL gr, const HMDT y, const HMDT r, const char *text, const char *fnt)

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 (C++, Python): void TextMark (const mglData &y, const char *text, const char *fnt="")
Method on mglGraph (C++): void TextMark (const mglData &y, const wchar_t *text, const char *fnt="")
C function: void mgl_textmarkw (HMGL gr, const HMDT y, const wchar_t *text, const char *fnt)
C function: void mgl_textmark (HMGL gr, const HMDT y, const char *text, const char *fnt)

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.15 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="") 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 (C++, Python): void Error (const mglData &x, const mglData &y, const mglData &ex, const mglData &ey, const char *pen="")
C function: void mgl_error_exy (HMGL gr, const HMDT x, const HMDT y, const HMDT ex, const HMDT ey, const char *pen)

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

Method on mglGraph (C++, Python): void Error (const mglData &x, const mglData &y, const mglData &ey, const char *pen="")
C function: void mgl_error_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ey, const char *pen)

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

Method on mglGraph (C++, Python): void Error (const mglData &y, const mglData &ey, const char *pen="")
C function: void mgl_error (HMGL gr, const HMDT y, const HMDT ey, const char *pen)

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


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

3.9.16 BoxPlot

These functions draw boxplot (also known as a box-and-whisker diagram) at points x[i] on plane z = zVal (by default z=Min.z). This is five-number summaries of data a[i,j] (minimum, lower quartile (Q1), median (Q2), upper quartile (Q3) and maximum) along second (j-th) direction. The sizes of 1st dimension must be equal for all arrays x.nx=a.nx. String pen specifies the color and style of line (see section Line styles). By default (pen="") solid line with color from palette is used (see section Pallete and colors). See also Plot, Error, Bars, Default sizes. See section BoxPlot sample, for sample code and picture.

Method on mglGraph (C++, Python): void BoxPlot (const mglData &x, const mglData &a, const char *pen="")
C function: void mgl_boxplot_xy (HMGL gr, const HMDT x, const HMDT a, const char *pen)

Draws a boxplot with specified values of coordinate x[i].

Method on mglGraph (C++, Python): void BoxPlot (const mglData &a, const char *pen="")
C function: void mgl_boxplot (HMGL gr, const HMDT a, const char *pen)

Draws a boxplot with x[i] values 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 several 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. See section 2D plot sample, for sample code and picture.


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

3.10.1 Mesh

Method on mglGraph (C++, Python): void Mesh (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_mesh_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)

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, MeshNum (see section Other settings), Cont, Tens. See section Mesh sample, for sample code and picture.

Method on mglGraph (C++, Python): void Mesh (const mglData &z, const char *sch="")
C function: void mgl_mesh (HMGL gr, const HMDT z, const char *sch)

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


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

3.10.2 Fall

Method on mglGraph (C++, Python): void Fall (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_fall_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)

The function draws fall lines for surface specified parametrically {x[i,j], y[i,j], z[i,j]}. This plot can be used for plotting several curves shifted in depth one from another. 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, MeshNum (see section Other settings). See section Fall sample, for sample code and picture.

Method on mglGraph (C++, Python): void Fall (const mglData &z, const char *sch="")
C function: void mgl_fall (HMGL gr, const HMDT z, const char *sch)

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


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

3.10.3 Belt

Method on mglGraph (C++, Python): void Belt (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_belt_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)

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, MeshNum (see section Other settings). See section Belt sample, for sample code and picture.

Method on mglGraph (C++, Python): void Belt (const mglData &z, const char *sch="")
C function: void mgl_belt (HMGL gr, const HMDT z, const char *sch)

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


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

3.10.4 Surf

Method on mglGraph (C++, Python): void Surf (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_surf_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)

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 (C++, Python): void Surf (const mglData &z, const char *sch="")
C function: void mgl_surf (HMGL gr, const HMDT z, const char *sch)

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


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

3.10.5 Boxs

Method on mglGraph (C++, Python): void Boxs (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_boxs_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)

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, Dens, Tile, Step. See section Boxs sample, for sample code and picture.

Method on mglGraph (C++, Python): void Boxs (const mglData &z, const char *sch="")
C function: void mgl_boxs (HMGL gr, const HMDT z, const char *sch)

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


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

3.10.6 Tile

Method on mglGraph (C++, Python): void Tile (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_tile_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)

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 (C++, Python): void Tile (const mglData &z, const char *sch="")
C function: void mgl_tile (HMGL gr, const HMDT z, const char *sch)

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


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

3.10.7 Dens

Method on mglGraph (C++, Python): void Dens (const mglData &x, const mglData &y, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_dens_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, float zVal)

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, Boxs, Tile, DensXYZ. See section Dens sample, for sample code and picture.

Method on mglGraph (C++, Python): void Dens (const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_dens (HMGL gr, const HMDT z, const char *sch, float zVal)

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


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

3.10.8 Cont

Method on mglGraph (C++, Python): void Cont (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_cont_xy_val (HMGL gr, const HMDT v, const HMDT x, const HMDT y, const HMDT z, const char *sch, float zVal)

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. If string sch have symbol ‘t’ or ‘T’ then contour labels v[k] will be drawn below (or above) the contours. 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, ContD, Axial, ContXYZ. See section Cont sample, for sample code and picture.

Method on mglGraph (C++, Python): void Cont (const mglData &v, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_cont__val (HMGL gr, const HMDT v, const HMDT z, const char *sch, float zVal)

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

Method on mglGraph (C++, Python): void Cont (const mglData &x, const mglData &y, const mglData &z, const char *sch="", int num=7, float zVal=NAN)
C function: void mgl_cont_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, int num, float zVal)

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

Method on mglGraph (C++, Python): void Cont (const mglData &z, const char *sch="", int num=7, float zVal=NAN)
C function: void mgl_cont (HMGL gr, const HMDT z, const char *sch, int num, float zVal)

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


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

3.10.9 ContF

Method on mglGraph (C++, Python): void ContF (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_contf_xy_val (HMGL gr, const HMDT v, const HMDT x, const HMDT y, const HMDT z, const char *sch, float zVal)

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 (C++, Python): void ContF (const mglData &v, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_contf_val (HMGL gr, const HMDT v, const HMDT z, const char *sch, float zVal)

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

Method on mglGraph (C++, Python): void ContF (const mglData &x, const mglData &y, const mglData &z, const char *sch="", int num=7, float zVal=NAN)
C function: void mgl_contf_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, int num, float zVal)

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

Method on mglGraph (C++, Python): void ContF (const mglData &z, const char *sch="", int num=7, float zVal=NAN)
C function: void mgl_contf (HMGL gr, const HMDT z, const char *sch, int num, float zVal)

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


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

3.10.10 ContD

Method on mglGraph (C++, Python): void ContD (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_contd_xy_val (HMGL gr, const HMDT v, const HMDT x, const HMDT y, const HMDT z, const char *sch, float zVal)

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 (C++, Python): void ContD (const mglData &v, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_contd_val (HMGL gr, const HMDT v, const HMDT z, const char *sch, float zVal)

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

Method on mglGraph (C++, Python): void ContD (const mglData &x, const mglData &y, const mglData &z, const char *sch="", int num=7, float zVal=NAN)
C function: void mgl_contd_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, int num, float zVal)

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

Method on mglGraph (C++, Python): void ContD (const mglData &z, const char *sch="", int num=7, float zVal=NAN)
C function: void mgl_contd (HMGL gr, const HMDT z, const char *sch, int num, float zVal)

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


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

3.10.11 Axial

Method on mglGraph (C++, Python): void Axial (const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_axial_xy_val (HMGL gr, const HMDT v, const HMDT x, const HMDT y, const HMDT z, const char *sch)

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 (C++, Python): void Axial (const mglData &v, const mglData &z, const char *sch="")
C function: void mgl_axial_val (HMGL gr, const HMDT v, const HMDT z, const char *sch)

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

Method on mglGraph (C++, Python): void Axial (const mglData &x, const mglData &y, const mglData &z, const char *sch="", int num=3)
C function: void mgl_axial_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, int num)

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

Method on mglGraph (C++, Python): void Axial (const mglData &z, const char *sch="", int num=3)
C function: void mgl_axial (HMGL gr, const HMDT z, const char *sch, int num)

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


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

3.10.12 Grad

Method on mglGraph (C++, Python): void Grad (const mglData &x, const mglData &y, const mglData &z, const mglData &phi, const char *sch="", int num=5)
C function: void mgl_grad_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, int num, float zVal)

The function draws gradient lines for scalar field phi[i,j,k] specified parametrically {x[i,j,k], y[i,j,k], z[i,j,k]}. String sch sets the color scheme. Previous color scheme is used by default. Number of lines is proportional to num. If num<0 then lines start from borders only. The minor dimensions of arrays x, y, z, phi should be equal x.nx=phi.nx && y.nx=phi.ny && z.nx=phi.nz or x.nx=y.nx=z.nx=phi.nx && x.ny=y.ny=z.ny=phi.ny && x.nz=y.nz=z.nz=phi.nz. Arrays x, y and z can be vectors (not matrices as phi). See also Dens3, Cont3, Flow.

Method on mglGraph (C++, Python): void Grad (const mglData &x, const mglData &y, const mglData &z, const char *sch="", int num=5, float zVal=NAN)
C function: void mgl_grad_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, int num, float zVal)

The function draws gradient lines for scalar field phi[i,j] specified parametrically {x[i,j], y[i,j], phi[i,j]} at z = zVal. String sch sets the color scheme. Previous color scheme is used by default. Number of lines is proportional to num. If num<0 then lines start from borders only. The minor dimensions of arrays x, y, phi should be equal x.nx=phi.nx && y.nx=phi.ny or x.nx=y.nx=phi.nx && x.ny=y.ny=phi.ny. Arrays x and y can be vectors (not matrices as phi). Lines are plotted for each z slice of the data. See also Dens, Cont, ContF, Flow. See section Grad sample, for sample code and picture.

Method on mglGraph (C++, Python): void Grad (const mglData &z, const char *sch="", int num=5, float zVal=NAN)
C function: void mgl_grad (HMGL gr, const HMDT z, const char *sch, int num, float zVal)

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


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

3.10.13 Grid

Method on mglGraph (C++, Python): void Grid (const mglData &x, const mglData &y, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_grid_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, float zVal)

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 (C++, Python): void Grid (const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_grid (HMGL gr, const HMDT z, const char *sch, float zVal)

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 5 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. See section 3D plot sample, for sample code and picture.


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

3.11.1 Surf3

Method on mglGraph (C++, Python): void Surf3 (float val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="")
C function: void mgl_surf3_xyz_val (HMGL gr, float val, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl)

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 (C++, Python): void Surf3 (float val, const mglData &a, const char *sch="")
C function: void mgl_surf3_val (HMGL gr, float val, const HMDT a, const char *sch)

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

Method on mglGraph (C++, Python): void Surf3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", int num=3)
C function: void mgl_surf3_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl, int num)

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

Method on mglGraph (C++, Python): void Surf3 (const mglData &a, const char *sch="", int num=3)
C function: void mgl_surf3 (HMGL gr, const HMDT a, const char *sch, int num)

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 (C++, Python): void Dens3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl="")
C function: void mgl_dens3_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, char dir, int sVal, const char *stl)

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 (C++, Python): void Dens3 (const mglData &a, char dir, int sVal=-1, const char *sch="")
C function: void mgl_dens3 (HMGL gr, const HMDT a, char dir, int sVal, const char *sch)

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

Method on mglGraph (C++, Python): void DensA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="")
C function: void mgl_dens3_all_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl)

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

Method on mglGraph (C++, Python): void DensA (const mglData &a, const char *sch="")
C function: void mgl_dens3_all (HMGL gr, const HMDT a, const char *sch)

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 (C++, Python): 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="")
C function: void mgl_cont3_xyz_val (HMGL gr, const HMDT v, const HMDT x, const HMDT y, const HMDT z, const HMDT a, char dir, int sVal, const char *stl)

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 stl sets the color scheme. Previous color scheme is used by default. If string stl have symbol ‘#’ then grid lines are drawn. If string stl have symbol ‘t’ or ‘T’ then contour labels v[k] will be drawn below (or above) the contours. 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 (C++, Python): void Cont3 (const mglData &v, const mglData &a, char dir, int sVal=-1, const char *sch="")
C function: void mgl_cont3_val (HMGL gr, const HMDT v, const HMDT a, char dir, int sVal, const char *sch)

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

Method on mglGraph (C++, Python): void Cont3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl="", int num=7)
C function: void mgl_cont3_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, char dir, int sVal, const char *stl, int num)

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

Method on mglGraph (C++, Python): void Cont3 (const mglData &a, char dir, int sVal=-1, const char *sch="", int num=7)
C function: void mgl_cont3 (HMGL gr, const HMDT a, char dir, int sVal, const char *sch, int num)

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

Method on mglGraph (C++, Python): void ContA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", int num=7)
C function: void mgl_cont3_all_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl, int num)

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

Method on mglGraph (C++, Python): void ContA (const mglData &a, const char *sch="", int num=7)
C function: void mgl_cont3_all (HMGL gr, const HMDT a, const char *sch, int num)

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 (C++, Python): 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="")
C function: void mgl_contf3_xyz_val (HMGL gr, const HMDT v, const HMDT x, const HMDT y, const HMDT z, const HMDT a, char dir, int sVal, const char *stl)

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 (C++, Python): void ContF3 (const mglData &v, const mglData &a, char dir, int sVal=-1, const char *sch="")
C function: void mgl_contf3_val (HMGL gr, const HMDT v, const HMDT a, char dir, int sVal, const char *sch)

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

Method on mglGraph (C++, Python): void ContF3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl="", int num=7)
C function: void mgl_contf3_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, char dir, int sVal, const char *stl, int num)

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

Method on mglGraph (C++, Python): void ContF3 (const mglData &a, char dir, int sVal=-1, const char *sch="", int num=7)
C function: void mgl_contf3 (HMGL gr, const HMDT a, char dir, int sVal, const char *sch, int num)

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

Method on mglGraph (C++, Python): void ContFA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", int num=7)
C function: void mgl_contf3_all_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl, int num)

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

Method on mglGraph (C++, Python): void ContFA (const mglData &a, const char *sch="", int num=7)
C function: void mgl_contf3_all (HMGL gr, const HMDT a, const char *sch, int num)

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 (C++, Python): void Grid3 (const mglData &x, const mglData &y, const mglData &z, const mglData &a, char dir, int sVal=-1, const char *stl="")
C function: void mgl_grid3_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, char dir, int sVal, const char *stl)

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]). Grid is plotted at slice sVal in dir={‘x’, ‘y’, ‘z’} direction. String sch sets the color scheme. Previous color scheme is used by default. 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 (C++, Python): void Grid3 (const mglData &a, char dir, int sVal=-1, const char *sch="")
C function: void mgl_grid3 (HMGL gr, const HMDT a, char dir, int sVal, const char *sch)

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

Method on mglGraph (C++, Python): void GridA (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="")
C function: void mgl_grid3_all_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl)

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

Method on mglGraph (C++, Python): void GridA (const mglData &a, const char *sch="")
C function: void mgl_grid3_all (HMGL gr, const HMDT a, const char *sch)

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 (C++, Python): void Cloud (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", float alpha=1)
C function: void mgl_cloud_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl, 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 Cloud sample, for sample code and picture.

Method on mglGraph (C++, Python): void Cloud (const mglData &a, const char *stl="", float alpha=1)
C function: void mgl_cloud (HMGL gr, const HMDT a, const char *stl, float alpha=1)

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

Method on mglGraph (C++): void CloudP (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", float alpha=1)
C function: void mgl_cloudp_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *stl, 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 (C++): void CloudP (const mglData &a, const char *stl="", float alpha=1)
C function: void mgl_cloudp (HMGL gr, const HMDT a, const char *stl, 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 (C++, Python): void Beam (float val, const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, float r, const char *stl="", int flag=0)
C function: void mgl_beam_val (HMGL gr, float val, const HMDT tr, const HMDT g1, const HMDT g2, const HMDT a, float r, const char *stl, int flag)

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 (C++, Python): void Beam (const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, float r, const char *stl="", int flag=0, int num=3)
C function: void mgl_beam (HMGL gr, const HMDT tr, const HMDT g1, const HMDT g2, const HMDT a, float r, const char *stl, 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 (C++, Python): void SurfC (const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="")
C function: void mgl_surfc_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *sch)

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 (C++, Python): void SurfC (const mglData &z, const mglData &c, const char *sch="")
C function: void mgl_surfc (HMGL gr, const HMDT z, const HMDT c, const char *sch)

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


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

3.12.2 Surf3C

Method on mglGraph (C++, Python): void Surf3C (float val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl="")
C function: void mgl_surf3c_xyz_val (HMGL gr, float val, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT c, const char *stl)

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 (C++, Python): void Surf3C (float val, const mglData &a, const mglData &c, const char *sch="")
C function: void mgl_surf3c_val (HMGL gr, float val, const HMDT a, const HMDT c, const char *sch)

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

Method on mglGraph (C++, Python): void Surf3C (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl="", int num=3)
C function: void mgl_surf3c_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT c, const char *stl, int num)

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

Method on mglGraph (C++, Python): void Surf3C (const mglData &a, const mglData &c, const char *sch="", int num=3)
C function: void mgl_surf3c (HMGL gr, const HMDT a, const HMDT c, const char *sch, int num)

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 (C++, Python): void SurfA (const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="")
C function: void mgl_surfa_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *sch)

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 (C++, Python): void SurfA (const mglData &z, const mglData &c, const char *sch="")
C function: void mgl_surfa (HMGL gr, const HMDT z, const HMDT c, const char *sch)

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


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

3.12.4 Surf3A

Method on mglGraph (C++, Python): void Surf3A (float val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl="")
C function: void mgl_surf3a_xyz_val (HMGL gr, float val, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT c, const char *stl)

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 (C++, Python): void Surf3A (float val, const mglData &a, const mglData &c, const char *sch="")
C function: void mgl_surf3a_val (HMGL gr, float val, const HMDT a, const HMDT c, const char *sch)

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

Method on mglGraph (C++, Python): void Surf3A (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &c, const char *stl="", int num=3)
C function: void mgl_surf3a_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT c, const char *stl, int num)

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

Method on mglGraph (C++, Python): void Surf3A (const mglData &a, const mglData &c, const char *sch="", int num=3)
C function: void mgl_surf3a (HMGL gr, const HMDT a, const HMDT c, const char *sch, int num)

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 (C++, Python): void TileS (const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *sch="")
C function: void mgl_tiles_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT r, const char *sch)

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 (C++, Python): void TileS (const mglData &z, const mglData &c, const char *sch="")
C function: void mgl_tiles (HMGL gr, const HMDT z, const HMDT c, const char *sch)

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


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

3.12.6 Map

Method on mglGraph (C++, Python): void Map (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", int ks=0, bool pnts=true)
C function: void mgl_map_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, int ks, int pnts)

The function draws mapping plot for matrices {ax, ay } which parametrically depend on coordinates x, y. The initial 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 (C++, Python): void Map (const mglData &ax, const mglData &ay, const char *sch="", int ks=0, bool pnts=true)
C function: void mgl_map (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, int ks, int pnts)

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


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

3.12.7 STFA

Method on mglGraph (C++, Python): void STFA (const mglData &x, const mglData &y, const mglData &re, const mglData &im, int dn, const char *sch="", float zVal=NAN)
C function: void mgl_stfa_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT re, const HMDT im, int dn, const char *sch, float zVal)

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 STFA sample, for sample code and picture.

Method on mglGraph (C++, Python): void STFA (const mglData &re, const mglData &im, int dn, const char *sch="", float zVal=NAN)
C function: void mgl_stfa (HMGL gr, const HMDT re, const HMDT im, int dn, const char *sch, float zVal)

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), vectors along the curve (Traj), vector field by dew-drops (Dew), flow threads (Flow, FlowP), 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 (C++, Python): void Traj (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", float len=0)
Method on mglGraph (C++, Python): void Traj (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN, float len=0)
C function: void mgl_traj_xyz (HMGL gr, const HMDTx, const HMDTy, const HMDTz, const HMDTax, const HMDTay, const HMDTaz, const char *sch, float len)
C function: void mgl_traj_xy (HMGL gr, const HMDTx, const HMDTy, const HMDTax, const HMDTay, const char *sch, float zVal, float len)

The function draws vectors {ax, ay, az} along a curve {x, y, z}. The length of arrows are proportional to \sqrtax^2+ay^2+az^2. String pen specifies the color (see section Line styles). By default (pen="") color from palette is used (see section Pallete and colors). 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 sizes of all arrays must be equal and large 2. The plots are drawn for each row if one of the data is the matrix. See also Vect. See section Traj sample, for sample code and picture.


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

3.13.2 Vect

Method on mglGraph (C++, Python): void Vect (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN, int flag=0)
C function: void mgl_vect_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, float zVal, int flag)

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 is bitwise flag for setup the hachures (arrows): 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 (C++, Python): void Vect (const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN, int flag=0)
C function: void mgl_vect_2d (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, float zVal, int flag)

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

Method on mglGraph (C++, Python): void Vect (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", int flag=0)
C function: void mgl_vect_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT ax, const HMDT ay, const HMDT az, const char *sch, int flag)

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 (C++, Python): void Vect (const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", int flag=0)
C function: void mgl_vect_3d (HMGL gr, const HMDT ax, const HMDT ay, const HMDT az, const char *sch, int flag)

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 (C++, Python): void VectL (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN)
C function: void mgl_vectl_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, float zVal)

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 (C++, Python): void VectL (const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN)
C function: void mgl_vectl_2d (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, float zVal)

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

Method on mglGraph (C++, Python): void VectL (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
C function: void mgl_vectl_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT ax, const HMDT ay, const HMDT az, const char *sch)

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 (C++, Python): void VectL (const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
C function: void mgl_vectl_3d (HMGL gr, const HMDT ax, const HMDT ay, const HMDT az, const char *sch)

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 (C++, Python): void VectC (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN)
C function: void mgl_vectc_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, float zVal)

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 (C++, Python): void VectC (const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN)
C function: void mgl_vectc_2d (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, float zVal)

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

Method on mglGraph (C++, Python): void VectC (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
C function: void mgl_vectc_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT ax, const HMDT ay, const HMDT az, const char *sch)

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 (C++, Python): void VectC (const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
C function: void mgl_vectc_3d (HMGL gr, const HMDT ax, const HMDT ay, const HMDT az, const char *sch)

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


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

3.13.5 Dew

Method on mglGraph (C++, Python): void Dew (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN)
C function: void mgl_dew_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, float zVal)

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 (C++, Python): void Dew (const mglData &ax, const mglData &ay, const char *sch="", float zVal=NAN)
C function: void mgl_dew (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, float zVal)

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


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

3.13.6 Flow

Method on mglGraph (C++, Python): void Flow (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", int num=5, bool central=true, float zVal=NAN)
C function: void mgl_flow_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, int num, int central, float zVal)

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). From v.1.11 it is ignored and always equal to (num>0). 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 (C++, Python): void Flow (const mglData &ax, const mglData &ay, const char *sch="", int num=5, bool central=true, float zVal=NAN)
C function: void mgl_flow_2d (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, int num, int central, float zVal)

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

Method on mglGraph (C++, Python): void Flow (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", int num=3, bool central=true)
C function: void mgl_flow_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT ax, const HMDT ay, const HMDT az, const char *sch, int num, int central)

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 (C++, Python): void Flow (const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", int num=3, bool central=true)
C function: void mgl_flow_3d (HMGL gr, const HMDT ax, const HMDT ay, const HMDT az, const char *sch, int num, int central)

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


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

3.13.7 FlowP

Method on mglGraph (C++): void FlowP (mglPoint p0, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="")
Method on mglGraph (Python): void FlowP (float x0, float y0, float z0, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="")
C function: void mgl_flowp_xy (HMGL gr, float x0, float y0, float z0, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch)

The function draws flow thread for the plane vector field {ax, ay} parametrically depending on coordinates x, y from point p0 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.

Method on mglGraph (C++): void FlowP (mglPoint p0, const mglData &ax, const mglData &ay, const char *sch="")
Method on mglGraph (Python): void FlowP (float x0, float y0, float z0, const mglData &ax, const mglData &ay, const char *sch="")
C function: void mgl_flowp_2d (HMGL gr, float x0, float y0, float z0, const HMDT ax, const HMDT ay, const char *sch)

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

Method on mglGraph (C++): void FlowP (mglPoint p0, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
Method on mglGraph (Python): void FlowP (float x0, float y0, float z0, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
C function: void mgl_flowp_xyz (HMGL gr, float x0, float y0, float z0, const HMDT x, const HMDT y, const HMDT z, const HMDT ax, const HMDT ay, const HMDT az, const char *sch)

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 (C++): void FlowP (mglPoint p0, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
Method on mglGraph (Python): void FlowP (float x0, float y0, float z0, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="")
C function: void mgl_flowp_3d (HMGL gr, float x0, float y0, float z0, const HMDT ax, const HMDT ay, const HMDT az, const char *sch)

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


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

3.13.8 Pipe

Method on mglGraph (C++, Python): void Pipe (const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", float r0=0.05, int num=5, bool central=true, float zVal=NAN)
C function: void mgl_pipe_xy (HMGL gr, const HMDT x, const HMDT y, const HMDT ax, const HMDT ay, const char *sch, float r0, int num, int central, float zVal)

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). From v.1.11 it is ignored and always equal to (num>0). 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 Flow, VectC, Vect. See section Pipe sample, for sample code and picture.

Method on mglGraph (C++, Python): void Pipe (const mglData &ax, const mglData &ay, const char *sch="", float r0=0.05, int num=5, bool central=true, float zVal=NAN)
C function: void mgl_pipe_2d (HMGL gr, const HMDT ax, const HMDT ay, const char *sch, float r0, int num, int central, float zVal)

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

Method on mglGraph (C++, Python): void Pipe (const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", float r0=0.05, int num=3, bool central=true)
C function: void mgl_pipe_xyz (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT ax, const HMDT ay, const HMDT az, const char *sch, float r0, int num, int central)

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 (C++, Python): void Pipe (const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", float r0=0.05, int num=3, bool central=true)
C function: void mgl_pipe_3d (HMGL gr, const HMDT ax, const HMDT ay, const HMDT az, const char *sch, float r0, int num, int central)

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, Data distributions. See section Dens projection sample, for sample code and picture.

Method on mglGraph (C++, Python): void DensX (const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_dens_x (HMGL gr, const HMDT a, const char *stl, float sVal)

Draws density plot for data a at x = sVal.

Method on mglGraph (C++, Python): void DensY (const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_dens_y (HMGL gr, const HMDT a, const char *stl, float sVal)

Draws density plot for data a at y = sVal.

Method on mglGraph (C++, Python): void DensZ (const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_dens_z (HMGL gr, const HMDT a, const char *stl, float sVal)

Draws density plot for data a at z = sVal.


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

3.14.2 ContXYZ

These plotting functions draw contour lines 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, Data distributions. See section Cont projection sample, for sample code and picture.

Method on mglGraph (C++, Python): void ContX (const mglData &a, const char *stl="", float sVal=NAN, int num=7)
C function: void mgl_cont_x (HMGL gr, const HMDT a, const char *stl, float sVal, int num)

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

Method on mglGraph (C++, Python): void ContY (const mglData &a, const char *stl="", float sVal=NAN, int num=7)
C function: void mgl_cont_y (HMGL gr, const HMDT a, const char *stl, float sVal, int num)

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

Method on mglGraph (C++, Python): void ContZ (const mglData &a, const char *stl="", float sVal=NAN, int num=7)
C function: void mgl_cont_z (HMGL gr, const HMDT a, const char *stl, float sVal, int num)

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

Method on mglGraph (C++, Python): void ContX (const mglData &v, const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_cont_x_val (HMGL gr, const HMDT v, const HMDT a, const char *stl, float sVal)

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

Method on mglGraph (C++, Python): void ContY (const mglData &v, const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_cont_y_val (HMGL gr, const HMDT v, const HMDT a, const char *stl, float sVal)

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

Method on mglGraph (C++, Python): void ContZ (const mglData &v, const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_cont_z_val (HMGL gr, const HMDT v, const HMDT a, const char *stl, float sVal)

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


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

3.14.3 ContFXYZ

These plotting functions draw solid contour lines 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, Data distributions.

Method on mglGraph (C++, Python): void ContFX (const mglData &a, const char *stl="", float sVal=NAN, int num=7)
C function: void mgl_contf_x (HMGL gr, const HMDT a, const char *stl, float sVal, int num)

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

Method on mglGraph (C++, Python): void ContFY (const mglData &a, const char *stl="", float sVal=NAN, int num=7)
C function: void mgl_contf_y (HMGL gr, const HMDT a, const char *stl, float sVal, int num)

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

Method on mglGraph (C++, Python): void ContFZ (const mglData &a, const char *stl="", float sVal=NAN, int num=7)
C function: void mgl_contf_z (HMGL gr, const HMDT a, const char *stl, float sVal, int num)

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

Method on mglGraph (C++, Python): void ContFX (const mglData &v, const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_contf_x_val (HMGL gr, const HMDT v, const HMDT a, const char *stl, float sVal)

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

Method on mglGraph (C++, Python): void ContFY (const mglData &v, const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_contf_y_val (HMGL gr, const HMDT v, const HMDT a, const char *stl, float sVal)

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

Method on mglGraph (C++, Python): void ContFZ (const mglData &v, const mglData &a, const char *stl="", float sVal=NAN)
C function: void mgl_contf_z_val (HMGL gr, const HMDT v, const HMDT a, const char *stl, float sVal)

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


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

3.14.4 Dots

Method on mglGraph (C++, Python): void Dots (const mglData &x, const mglData &y, const mglData &z, const char *sch="")
Method on mglGraph (C++, Python): void Dots (const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="")
C function: void mgl_dots (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch)
C function: void mgl_dots_a (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *sch)

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 (C++): void Dots (const mglData &tr, const char *sch="")
C function: void mgl_dots_tr (HMGL gr, const HMDT tr, const char *sch)

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 (C++, Python): void Crust (const mglData &x, const mglData &y, const mglData &z, const char *sch="", float er=0)
C function: void mgl_crust (HMGL gr, const HMDT x, const HMDT y, const HMDT z, const char *sch, float er)

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 (C++): void Crust (const mglData &tr, const char *sch="", float er=0)
C function: void mgl_crust_tr (HMGL gr, const HMDT tr, const char *sch, float er)

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 (C++, Python): void TriPlot (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="")
Method on mglGraph (C++, Python): void TriPlot (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_triplot_xyz (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const char *sch)
C function: void mgl_triplot_xyzc (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *sch)

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, QuadPlot.

Method on mglGraph (C++, Python): void TriPlot (const mglData &id, const mglData &x, const mglData &y, const char *sch="", float zVal=NAN)
C function: void mgl_triplot_xy (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const char *sch, float zVal)

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


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

3.14.7 TriCont

Method on mglGraph (C++, Python): void TriContV (const mglData &v, const mglData &id, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", float zVal=NAN)
Method on mglGraph (C++, Python): void TriContV (const mglData &v, const mglData &id, const mglData &x, const mglData &y, const mglData &z, const char *sch="", float zVal=NAN)
C function: void mgl_tricont_xyzcv (HMGL gr, const HMDT v, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *sch, float zVal)
C function: void mgl_tricont_xyzv (HMGL gr, const HMDT v, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const char *sch, float zVal)

The function draws contour lines for surface of triangles at z = zVal (or for z=v[k] if zVal==NAN). Triangle vertexes are set by indexes id of data points {x[i], y[i], z[i]}. 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. Array c (if specified) is used for contour coloring. 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 TriPlot, Cont.

Method on mglGraph (C++, Python): void TriCont (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", num=7, float zVal=NAN)
Method on mglGraph (C++, Python): void TriCont (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const char *sch="", num=7, float zVal=NAN)
C function: void mgl_tricont_xyzc (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *sch, num, float zVal)
C function: void mgl_tricont_xyz (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const char *sch, num, float zVal)

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


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

3.14.8 QuadPlot

Method on mglGraph (C++, Python): void QuadPlot (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="")
Method on mglGraph (C++, Python): void QuadPlot (const mglData &id, const mglData &x, const mglData &y, const mglData &z, const char *sch="")
C function: void mgl_quadplot_xyz (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const char *sch)
C function: void mgl_quadplot_xyzc (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const HMDT z, const HMDT c, const char *sch)

The function draws the surface of quadrangles. Quadrangles 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 4 or greater. Arrays x, y, z must have equal sizes. Parameter c set the colors of quadrangles (if id.ny=c.nx) or colors of vertexes (if x.nx=c.nx). See also TriPlot.

Method on mglGraph (C++, Python): void QuadPlot (const mglData &id, const mglData &x, const mglData &y, const char *sch="", float zVal=NAN)
C function: void mgl_quadplot_xy (HMGL gr, const HMDT id, const HMDT x, const HMDT y, const char *sch, float zVal)

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


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

3.14.9 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.10) there is adaptive increase of data points numbers but only for 1D variant (i.e. for Plot()).

Method on mglGraph (C++, Python): void Plot (const char *eqY, const char *stl="", float zVal=NAN, int n=100)
C function: void mgl_fplot (HMGL gr, const char *eqY, const char *stl, float zVal, int n)

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 (C++, Python): void Plot (const char *eqX, const char *eqY, const char *eqZ, const char *stl="", float zVal=NAN, int n=100)
C function: void mgl_fplot_xyz (HMGL gr, const char *eqX, const char *eqY, const char *eqZ, const char *stl, float zVal, int n)

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 (C++, Python): void Surf (const char *eqZ, const char *stl="", int n=100);
C function: void mgl_fsurf (HMGL gr, const char *eqZ, const char *stl, int n);

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 (C++, Python): void Surf (const char *eqX, const char *eqY, const char *eqZ, const char *stl="", int n=100)
C function: void mgl_fsurf_xyz (HMGL gr, const char *eqX, const char *eqY, const char *eqZ, const char *stl, int n)

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.10 SimplePlot

Method on mglGraph (C++, Python): void SimplePlot (const mglData &a, int type=0, const char *stl="")
C function: void mgl_simple_plot (HMGL gr, const HMDT a, int type, const char *stl)

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 (C++, Python): 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 (C++, Python): 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)
C function: float mgl_fit_xyzas (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyzas_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

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 (C++, Python): 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 (C++, Python): 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)
C function: float mgl_fit_xyzs (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyzs_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

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 (C++, Python): 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 (C++, Python): float FitS (mglData &fit, const mglData &x, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xys (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_xys_d (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

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

Method on mglGraph (C++, Python): 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 (C++, Python): float FitS (mglData &fit, const mglData &a, const mglData &s, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_ys (HMGL gr, HMDT fit, const HMDT a, const HMDT s, const char *func, const char *var, float *ini)
C function: float mgl_fit_ys_d (HMGL gr, HMDT fit, const HMDT a, const HMDT s, const char *func, const char *var, HMDT ini)

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

Method on mglGraph (C++, Python): 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 (C++, Python): 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)
C function: float mgl_fit_xyza (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyza_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT z, const HMDT a, const char *func, const char *var, HMDT ini)

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 (C++, Python): 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 (C++, Python): float Fit (mglData &fit, const mglData &x, const mglData &y, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xyz (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_xyz_d (HMGL gr, HMDT fit, const HMDT x, const HMDT y, const HMDT a, const char *func, const char *var, HMDT ini)

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 (C++, Python): 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 (C++, Python): float Fit (mglData &fit, const mglData &x, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_xy (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_xy_d (HMGL gr, HMDT fit, const HMDT x, const HMDT a, const char *func, const char *var, HMDT ini)

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 (C++, Python): float Fit (mglData &fit, const mglData &a, const char *func, const char *var, float *ini="", bool print=false)
Method on mglGraph (C++, Python): float Fit (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_1 (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_1_d (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, HMDT ini)

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 (C++, Python): float Fit2 (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit2 (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_2 (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_2_d (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, HMDT ini)

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 (C++, Python): float Fit3 (mglData &fit, const mglData &a, const char *func, const char *var, float *ini=NULL, bool print=false)
Method on mglGraph (C++, Python): float Fit3 (mglData &fit, const mglData &a, const char *func, const char *var, mglData &ini, bool print=false)
C function: float mgl_fit_3 (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, float *ini)
C function: float mgl_fit_3_d (HMGL gr, HMDT fit, const HMDT a, const char *func, const char *var, HMDT ini)

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 (C++, Python): void PutsFit (mglPoint p, const char *prefix="", const char *font=NULL, float size=-1)
C function: void mgl_puts_fit (HMGL gr, float x, float y, float z, const char *prefix, const char *font, 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.

Method on mglGraph (C++, Python): const char * GetFit ()
C function: const char * mgl_get_fit (HMGL gr)

Get last fitted formula with found coefficients (as numbers).

General option (C++) of mglGraph: int FitPnts

Minimal number of points for output array after nonlinear fitting.


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

3.16 Data distributions

These functions make distribution (histogram) of data. They do not draw the obtained data themselves. These functions can be useful if user have data defined for random points (for example, after PIC simulation) and he want to produce a plot which require regular data (defined on grid(s)). The range for grids is always selected as axis range Min...Max. Arrays x, y, z define the positions (coordinates) of random points. Array a define the data value. Number of points in output array res is selected as maximal value of res size and the value of FitPnts.

Method on mglGraph (C++, Python): void Hist (mglData &res, const mglData &x, const mglData &a)
C function: int mgl_hist_x (HMGL gr, HMDT res, const HMDT x, const HMDT a)

Creates 1D distribution of the data values a in range [Min, Max].

Method on mglGraph (C++, Python): void Hist (mglData &res, const mglData &x, const mglData &y, const mglData &a)
C function: int mgl_hist_xy (HMGL gr, HMDT res, const HMDT x, const HMDT y, const HMDT a)

Creates 2D distribution of the data values a in range [Min, Max].

Method on mglGraph (C++, Python): void Hist (mglData &res, const mglData &x, const mglData &y, const mglData &z, const mglData &a)
C function: int mgl_hist_xyz (HMGL gr, HMDT res, const HMDT x, const HMDT y, const HMDT z, const HMDT a)

Creates 3D distribution of the data values a in range [Min, Max].


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

3.17 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 (C++, Python): int NewFrame ()
C function: int mgl_new_frame (HMGL gr)

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 (C++, Python): void EndFrame ()
C function: void mgl_end_frame (HMGL gr)

Finishes the frame drawing.

Method on mglGraph (C++, Python): int GetNumFrame ()
C function: int mgl_get_num_frame (HMGL gr)

Gets the number of created frames.

Method on mglGraph (C++, Python): void ResetFrames ()
C function: int mgl_reset_frames (HMGL gr)

Reset frames counter (start it from zero).

Method on mglGraph (C++, Python): void StartGIF (const char *fname, int ms=100)
C function: void mgl_start_gif (HMGL gr, const char *fname, int ms)

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 (C++, Python): int CloseGIF ()
C function: void mgl_close_gif (HMGL gr)

Finish writing animated GIF and close connected pointers.


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

3.18 IDTF functions

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

Method on mglGraph (C++): void VertexColor (bool enable)

Enables smooth color change.

Method on mglGraph (C++): void Compression (bool enable)

Gives smaller files, but quality degrades.

Method on mglGraph (C++): 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 (C++): void EndGroup ()

Ends group definition.


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

This document was generated by Alexey Balakin on May 2, 2013 using texi2html 1.82.