MGL script language
Reference manual
Alexey Balakin, 2007
Contents
- Introduction
- Graphics setup
- Scaling, moving and rotating
- Axis functions
- Primitive drawing functions
- 1d plotting commands
- 2d plotting commands
- 3d plotting commands
- Dual plotting commands
- Other plotting function
- Data creation and deleting
- New data extraction (forming)
- Data handling
- Color specification
- Line style specification
- Color scheme specification
- Text and font specification
- Formulas and functions
- Command options
- Suffixes for variable
1. Introduction
MathGL library supports (from version 1.3) the simplest scripts for data handling and plotting. These scripts can be used independently (with the help of mgl2png, mgl2eps, mgl2svg programs and others) or in the frame of the library using.
MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Command may have up to 1000 arguments (at least for now). Words are separated from each other by space or tabulation symbol. The upper or lower case of words is suficient, i.e. variables a and A are different variables. Symbol #
starts the comment (all characters after #
will be ignored). The exception is situation when #
is a part of some string. Also options can be specified at the end of string (after symbol ';
', see Sec. 19).
If string contain references to external parameters (substrings "$0", "$1" ... "$9") then before execution the values of parameter will be substituted instaed of reference. It allows to use the same MGL script for different parameters (filenames, paths, condition and so on).
Argument can be a variable name, a string or a number. Variable name is arbitrary combination of symbols (except spaces and '
) started from a letter and with length less than 64. It is possible to use subarrays (like in subdata command) as command argument. For example, a(1)
or a(1,:)
or a(1,:,:)
is second row, a(:,2)
or a(:,2,:)
is third column, a(:,:,0)
is first slice and so on. The string is any symbols between ordinary marks ('
). Special variables nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1
are treated as number if they were not redefined by user. Also variables with suffixes are treated as numbers. Before the first using all variables must bedefined with the help of commands new, var, list, copy or read.
All MGL commands can be divided on several groups. I will use the following notation for a command description: command names are bold, strings are denoted by commas, variable names are italic, numbers are typewriter. Optional arguments are placed in square brackets and default values for them are shown. Detailed description of color, line styles, color schemes, font types , TeX-like symbols and formulas can be found in corresponding section.
[contents]
2. Graphics setup
Commands in this group influences on overall graphics appearance. So all of them should placed before any actual plotting commands.
- alpha [
val=on
]
Sets the transparency on/off. It is recommended to call this function before any plotting command. Initial value is off
. Use command transparent off
in particular plot to disable its transparency.
- alphadef
val
Default value of alpha channel for transparency for all plotting functions. Initial value is 0.5.
- ambient
val
Sets the brightness of an ambient light. The value should be in range [0,1]. It is recommended to call this function before any plotting command. Initial value is 0.5.
- axialdir 'dir'
Sets the direction around which curve rotated in axial and torus commands. Initial value is 'z'.
- fog
val [dist=0.25]
Set the density of fog val
for the picture. If val=0
then fog is absent. Fog will start from relative distance dist
from the leading edge.
- font 'fnt' [
val=6
]
Font style for text and labels (see text). Initial style is 'fnt'='rC' – Roman font with centerin. Parameter 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. For more detail see Sec. 17.
- legendbox
val
Switches on/off the drawing of a box near legend. By default, the box is drawn.
- light [
val=on
]
Sets the using of light on/off. It is recommended to call this function before any plotting command. Initial value is lightning off.
- light
num xpos ypos zpos
['col'='w' br=0.5
]
The function adds a light source with identification num
at position {xpos, ypos, zpos
}. The color of light is 'col' (white by default). The brightness of light is br
in [0,1]. It is recommended to call this function before any plotting command.
- light
num val
Switches on/off n-th light source separately depending on parameter val
.
- linewidth
val
Base line width for all lines. Should be larger or equal to 1.
- marksize
val
Base size for all marks. Initial value is 1.
- meshnum
val
Sets approximate number of lines in mesh, fall and grid. Initially (=0) it draws all lines.
- once
val
The code between once on
and once off
executed only once. Useful for large data manipulation in programs like UDAV.
- rotatetext
val
The using of text rotation along axis. Initial value is on
.
- setsize
w h
Sets size of picture in pixels. This function call have to be before any plotting command. In some program the call of this function is forbidden.
- ternary
val
Flag that switch on/off drawing of ternary plot (triangular axis and so on).
- transparent
val
Flag that temporarily switches transparency on/off for the plot. Initial value is on
.
- transptype
val
Type of transparency: 0 -- normal transparency, 1 -- glass-like transparency, 2 -- light-like transparency. Initial value is off
.
- xtick
dx
[sx=0
]
Step for x axis ticks (if dx
>0) or it's number (if dx
<0) in x-direction. Zero value dx
=0 sets logarithmic ticks. Parameter sx
sets the number of subticks in x direction.
- xtick 'template'
Set template (like '%g') for tick labels along x axis ticks. Do not influence on logarithmic ticks.
- ytick
dy
[sy=0
]
Step for y axis ticks (if dy
>0) or it's number (if dy
<0) in y-direction. Zero value dy
=0 sets logarithmic ticks. Parameter sx
sets the number of subticks in y direction.
- ytick 'template'
Set template (like '%g') for tick labels along y axis ticks. Do not influence on logarithmic ticks.
- ztick
dz
[sz=0
]
Step for z axis ticks (if dz
>0) or it's number (if dz
<0) in z-direction. Zero value dz
=0 sets logarithmic ticks. Parameter sx
sets the number of subticks in z direction.
- ztick 'template'
Set template (like '%g') for tick labels along z axis ticks. Do not influence on logarithmic ticks.
3. Scaling, moving and rotating
These command define the position of plot on the picture and its properties. There is a curtain order of calling of these functions for the better plot view. The first one should be subplot or inplot for specifying of the place. After it a rotate and aspect. And finally any other plotting function may be called.
- aspect
ax ay 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 command.
- inplot
x1 x2 y1 y2
Puts the further plotting in some region of the whole frame surface. This command 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]. This command sets any aspects or rotations off. So, it should be used first for creating subplot. See also subplot.
- rotate
tetz tetx
[tety=0
]
Rotates a further plotting relative to each axis (x, z, y) consecutively on angles tetz
, tetx
, tety
.
- rotate
tet x y z
Rotates a further plotting around vector {x,y,z
} on angle tet
.
- subplot
w h pos
Puts further plotting in a pos
-th cell of w*h
grid of the whole frame area. This function sets 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. See also inplot.
[contents]
4. Axis functions
Axis functions control and draw the axes. There is the twofold axis representation in MGL. First one consists in normalizing of the data point coordinates in box specified in axis command. If cut is on
then the outer point is omitted otherwise it is projected to bounding box. Also the points are omitted if they are inside the box specified in cut command. After it transformation formulas 'fx', 'fy', 'fz' are applied to the data point. Finally, the data point is plotted by one of functions.
- axis
x1 y1 z1 x2 y2 z2
Sets the ranges (bounding box) of coordinates changing. Also it sets the range for coloring (analogous to caxis z1 z2
). Initial ranges are [-1, 1].
- axis
x1 y1 x2 y2
Sets the ranges (bounding box) of coordinates changing. Initial ranges are [-1, 1].
- axis 'fx' 'fy' 'fz'
Sets the transformation formulas for curvilinear coordinates. Each string should contain mathematical expression for real coordinate depending on internal coordinates x, y, z. For example, the cylindrical coordinates are introduced as axis 'x*cos(y)' 'x*sin(y)' 'z'. For removing of formulas the corresponding parameter should be ''. The using of transformation formulas will slightly slowing the program, i.e. axis '' '' ''
is faster than axis 'x' 'y' 'z'
. Initially all formulas are absent (Cartesian coordinates are used). For more details about functions and formulas see Sec. 18.
- axis ['dirs'='xyz']
Draws axes with ticks (defined by xtick, ytick, ztick) in directions determined by string parameter dir. If the string contains symbol '_' then tick labels are not printed. Font for ticks text is determined by font.
- box ['stl'='k-']
Draws bounding box outside the plotting volume with line style 'stl'.
- caxis
c1 c2
Sets the range for surface coloring. Initial range is [-1, 1].
- crange dat [
add=off
]
Sets the range for surface coloring as minimal and maximal values of data dat. Parameter add=on
shows that the new range will be joined to existed one (but will not replace it). See also caxis.
- crange
c1 c2
Sets the range for surface coloring as [c1, c2]
. The same as caxis.
- cut
val
Flag which determines how points outside the bounding box are drawn. If it is on
then points are excluded from the plot (it is default) otherwise the points are projected to edges of the bounding box.
- cut
x1 y1 z1 x2 y2 z2
Lower and upper edge of the box in which no points are drawn. If both edges are the same (the variables are equal) then the cutting box is empty.
- cut 'condition'
Set cutting off formula. If 'condition' is nonzero for point coordinates then this point is excluded from the plot.
- grid ['dir'='xyz' 'stl'='B-']
Draws grid lines perpendicular to direction determined by string parameter 'dir'. The step of grid lines is the same as tick step for an axis. The style of lines is determined by 'stl'.
- origin
x0 y0 [z0]
Places the point of intersection of coordinate axes to the point {x0, y0, z0
}.
- xlabel 'txt' [
pos=1
]
Prints the label 'txt' for x axis. 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. Font style and size are defined by font command. See also text. For more detail see Sec. 17.
- xrange dat [
add=off
]
Sets the range for x coordinate as minimal and maximal values of data dat. Parameter add=on
shows that the new range will be joined to existed one (nut will not replace it). See also axis.
- xrange
x1 x2
Sets the range for x coordinate as [x1, x2]
. See also axis.
- ylabel 'txt' [
pos=1
]
Prints the label 'txt' for y axis. 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. Font style and size are defined by font command. See also text. For more detail see Sec. 17.
- yrange dat [
add=off
]
Sets the range for y coordinate as minimal and maximal values of data dat. Parameter add=on
shows that the new range will be joined to existed one (but will not replace it). See also axis.
- yrange
y1 y2
Sets the range for x coordinate as [y1, y2]
. See also axis.
- zlabel 'txt' [
pos=1
]
Prints the label 'txt' for z axis. 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. Font style and size are defined by font command. See also text. For more detail see Sec. 17.
- zrange dat [
add=off
]
Sets the range for z coordinate as minimal and maximal values of data dat. Parameter add=on
shows that the new range will be joined to existed one (but will not replace it). See also axis.
- zrange
z1 z2
Sets the range for x coordinate as [z1, z2]
. See also axis.
5. Primitive drawing functions
These functions draw some simple objects like point, line, marker or text string.
- addlegend 'txt' 'stl'
Adds string 'txt' to internal legend accumulator. The style of described line and mark is specified in string 'stl'. The maximal number of entries is 100.
- ball
x y z
['col'='r']
Draws a point (ball) at position {x y z
} with color 'col'.
- clearlegend
Clears saved legend strings.
- clf
Clears up the picture. Removes all drawing from it. Does not change transformation matrix.
- colorbar ['sch'=''
pos=0
]
Draws colorbar with color scheme 'sch' (current scheme if 'sch'='') at the edge of plot. Parameter pos
specifies the position of colorbar: 0 - at right (default), 1 - at left, 2 - at top, 3 - at bottom.
- curve
x1 y1 z1 dx1 dy1 dz1 x2 y2 z2 dx2 dy2 dz2
['stl'='']
Draws Bezier-like curve from point {x1, y1, z1
} to {x2, y2, z2
} using line style 'stl'. At this tangent is co-directed with {dx1, dy1, dz1
}, {dx2, dy2, dz2
} and proportional to its amplitude.
- drop
x0 y0 z0 dx dy dz r
['col'='' sh=1 asp=1
]
Draws drop with size r
starting from point {x0, y0, z0
} and directed to {dx, dy, dz
}. The drop color is determined by 'col'. Parameter sh
(in range [0, 1]) determines the drop oblongness. Parameter asp
set relative width of the drop.
- drop
x0 y0 dx dy r
['col'='' sh=1 asp=1
]
Draws drop with size r
starting from point {x0, y0, 0
} and directed to {dx, dy, 0
}. The drop color is determined by 'col'. Parameter sh
(in range [0, 1]) determines the drop oblongness. Parameter asp
set relative width of the drop.
- legend [
pos=3
'fnt'='rL' size=-1
]
Draws legend of accumulated string by font 'fnt' with size
. Parameter pos
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).
- line
x1 y1 z1 x2 y2 z2
['stl'=0]
Draws geodesic line (stright-line in Cartesian coordinates) from point {x1, y1, z1
} to {x2, y2, z2
}, using line style 'stl'.
- line
x1 y1 x2 y2
['stl'=0]
Draws geodesic line (stright-line in Cartesian coordinates) from point {x1, y1
} to {x2, y2
}, using line style 'stl'.
- rect
x1 y1 z1 x2 y2 z2
['stl'='']
Draws rectangle from point {x1, y1, z1
} to {x2, y2, z2
}, using colors 'stl'. If 'stl' have 4 or more colors then it defines colors for each rectangle vertex (useful for making gradients, like 'wwrr'
) else first color is used for whole rectangle.
- rect
x1 y1 x2 y2
['stl'='']
Draws rectangle from point {x1, y1
} to {x2, y2
}, using colors 'stl'. If 'stl' have 4 or more colors then it defines colors for each rectangle vertex (useful for making gradients, like 'wwrr'
) else first color is used for whole rectangle.
- sphere
x0 y0 z0 r
['col'='']
Draws sphere with radius r
and center at point {x0, y0, z0
} using color 'col'.
- sphere
x0 y0 r
['col'='']
Draws sphere with radius r
and center at point {x0, y0, 0
} using color 'col'.
- text
x y z
'txt' ['fnt'='' size=-1.4
]
Draws unrotated text string 'txt' at position {x y z
} by font 'fnt' with size
. By default font parameters from font command are used. For more details see Sec. 17.
- text
x y
'txt' ['fnt'='' size=-1.4
]
Draws unrotated text string 'txt' at position {x y 0
} by font 'fnt' with size
. By default font parameters from font command are used. For more details see Sec. 17.
6. 1d plotting commands
These functions perform plotting of 1D data. 1D means that the data depend on the only 1 parameter (index). Most of commands have similar interface. There are version for drawing in 3d space or in plain. For the last one there is a possibility to use single data array. If command allows to use parametric curve definition (depends on 2 or 3 data arrays) then its minor dimensions should be equal. If one of the arrays is 2d array (matrix) then the curves will be drawn for each of rows. At this the other arrays can be one-dimensional. Optional string parameter 'stl' sets the style and color of line and marks for all 1d plotting commands. By default ('stl'='') solid line with next color from palette is used. See also color and line styles specification.
- area ydat ['stl'=''
zval=nan
]
Draws continuous lines between equidistantly distributed points ydat along x axis and fills it down to y axis in plane z = zval
(the default is at the bottom of the bounding box).
- area xdat ydat ['stl'=''
zval=nan
]
Draws continuous lines between points {xdat, ydat} and fills it down to y axis in plane z = zval
(the default is at the bottom of the bounding box).
- area xdat ydat zdat ['stl'='']
Draws continuous lines between points {xdat, ydat, zdat} and fills it down to x-y axis plane.
- bars ydat ['stl'=''
zval=nan
]
Draws vertical bars from equidistantly distributed points ydat along x axis to y axis in plane z = zval
(the default is at the bottom of the bounding box). Marks at data points are not drawn.
- bars xdat ydat ['stl'=''
zval=nan
]
Draws vertical bars from points {xdat, ydat} to y axis in plane z = zval
(the default is at the bottom of the bounding box). Marks at data points are not drawn.
- bars xdat ydat zdat ['stl'='']
Draws vertical bars from points {xdat, ydat, zdat} to x-y axis plane. Marks at data points are not drawn.
- chart dat ['col'='']
Draws colored stripes (boxes) for data in array dat. The number of stripes is equal to the number of rows in dat. The color of each next stripe is cyclically changed from colors specified in string 'col' or in palette (for 'col'=''). The stripe width is proportional to value of element in dat. Chart is plotted only for data arrays with non-negative elements. If string 'col' has symbol # then black border lines are drawn. The most nice form the chart has in 3d (after rotation of coordiantes) or in cylindrical coordinates (the so called Pie chart).
- error ydat yerr ['stl'=''
zval=nan
]
Draws vertical error boxes yerr in position of equidistantly distributed data points ydat (for example, experimental one) along x axis in plane z = zval
(the default is at the bottom of the bounding box). All dimensions of arrays yerr and ydat must be equal.
- error xdat ydat yerr ['stl'=''
zval=nan
]
Draws vertical error boxes yerr in position of data points {xdat, ydat} (for example, experimental one) in plane z = zval
(the default is at the bottom of the bounding box). All dimensions of arrays yerr and ydat must be equal. See also plot.
- error xdat ydat xerr yerr ['stl'=''
zval=nan
]
Draws error boxes {xerr, yerr} in position of data points {xdat, ydat} (for example, experimental one) in plane z = zval
(the default is at bottom of bounding box). All dimensions of arrays xerr, yerr and xdat, ydat must be equal.
- mark ydat rdat ['stl'=''
zval=nan
]
Draws marks with relative size rdat in equidistantly distributed along x points ydat in plane z = zval
(the default is at the bottom of the bounding box).
- mark xdat ydat rdat ['stl'=''
zval=nan
]
Draws marks with relative size rdat in points {xdat, ydat} in plane z = zval
(the default is at the bottom of the bounding box).
- mark xdat ydat zdat rdat ['stl'='']
Draws marks with relative size rdat in points {xdat, ydat, zdat}.
- plot ydat ['stl'=''
zval=nan
]
Draws continuous lines between equidistantly distributed along x points ydat in plane z = zval
(the default is at the bottom of the bounding box).
- plot xdat ydat ['stl'=''
zval=nan
]
Draws continuous lines between points {xdat, ydat} in plane z = zval
(the default is at the bottom of the bounding box).
- plot xdat ydat zdat ['stl'='']
Draws continuous lines between points {xdat, ydat, zdat}.
- stem ydat ['stl'=''
zval=nan
]
Draws vertical lines from equidistantly distributed along x points ydat to y axis in plane z = zval
(the default is at the bottom of the bounding box).
- stem xdat ydat ['stl'=''
zval=nan
]
Draws vertical lines from points {xdat, ydat} to y axis in plane z = zval
(the default is at the bottom of the bounding box).
- stem xdat ydat zdat ['stl'='']
Draws vertical lines from points {xdat, ydat, zdat} to x-y axis plane.
- step ydat ['stl'=''
zval=nan
]
Draws continuous stairs for equidistantly distributed along x points ydat in plane z = zval
(the default is at the bottom of the bounding box).
- step xdat ydat ['stl'=''
zval=nan
]
Draws continuous stairs for points {xdat, ydat} in plane z = zval
(the default is at the bottom of the bounding box).
- step xdat ydat zdat ['stl'='']
Draws continuous stairs for points {xdat, ydat, zdat}.
- text ydat 'text' [font=''
sise=-1 zval=nan
]
Prints text along the curve between equidistantly distributed along x points ydat in plane z = zval
(the default is at the bottom of the bounding box). If string contain 'T' symbol then the text will be drawn above the curve.
- text xdat ydat 'text' [font=''
sise=-1 zval=nan
]
Prints text along the curve between points {xdat, ydat} in plane z = zval
(the default is at the bottom of the bounding box). If string contain 'T' symbol then the text will be drawn above the curve.
- text xdat 'text' [font=''
sise=-1
]
Prints text along the curve between points {xdat, ydat, zdat}. If string contain 'T' symbol then the text will be drawn above the curve.
- torus zdat ['stl'='']
Draws surface which is result of curve zdat rotation around axis. String 'stl' sets the color of the surface. First color of previous color scheme is used by default. If the string 'stl' contains symbols 'x', 'y' or 'z' then rotation axis axialdir will be set to specified direction.
- torus rdat zdat ['stl'='']
Draws surface which is result of curve {rdat, zdat} rotation around axis. Size of arrays {rdat, zdat} must be the same. String 'stl' sets the color of the surface. First color of previous color scheme is used by default. If the string 'stl' contains symbols 'x', 'y' or 'z' then rotation axis axialdir will be set to specified direction. See also axial.
- tube ydat rdat ['stl'=''
zval=nan
]
Draws tube with radius rdat along the curve between equidistantly distributed along x points ydat in plane z = zval
(the default is at the bottom of the bounding box).
- tube ydat
rval
['stl'='' zval=nan
]
Draws tube with radius rval
along the curve between equidistantly distributed along x points ydat in plane z = zval
(the default is at the bottom of the bounding box).
- tube xdat ydat rdat ['stl'=''
zval=nan
]
Draws tube with radius rdat along the curve between points {xdat, ydat} in plane z = zval
(the default is at the bottom of the bounding box).
- tube xdat ydat
rval
['stl'='' zval=nan
]
Draws tube with radius rval
along the curve between points {xdat, ydat} in plane z = zval
(the default is at the bottom of the bounding box).
- tube xdat ydat zdat rdat ['stl'='']
Draws tube with radius rdat along the curve between points {xdat, ydat, zdat}.
- tube xdat ydat zdat
rval
['stl'='']
Draws tube with radius rval
along the curve between points {xdat, ydat, zdat}.
2d plotting commands
These functions perform plotting of 2D data. 2D means that the data depend on 2 independent parameter (indexes). Most of commands have similar interface. There are 2 versions for drawing of the surface of single data array and for parametrically specified surface. If command allows to use parametric surface definition (depends on 3 data arrays xdat, ydat, zdat) then its minor dimensions should be equal. At this arrays xdat, ydat can be one-dimensional. If zdat is 3d array then the surfaces will be drawn for each of slices. Optional string parameter 'stl' sets the color scheme. Previous color scheme is used by default. See also color and color schemes specification.
- axial zdat ['sch'=''
num=3
]
Draws num
-th surfaces which is result of contour plot rotation for the matrix zdat. Contours are plotted at constant zdat. Contours are plotted only for the first z slice of the data.
- axial xdat ydat zdat ['sch'=''
num=3
]
Draws num
-th surfaces which is result of contour plot rotation for the surface specified parametrically {xdat, ydat, zdat}. Contours are plotted at constant zdat. Surfaces are drawn only for the first z slice of the data.
- belt zdat ['sch'='']
Draws belts (types) for matrix zdat. This plot can be used as 3d generalization of plot.
- belt xdat ydat zdat ['sch'='']
Draws belts (types) for surface specified parametrically {xdat, ydat, zdat}. This plot can be used as 3d generalization of plot.
- boxs zdat ['sch'='']
Draws vertical boxes for matrix zdat from data points to x-y axis plane.
- boxs xdat ydat zdat ['sch'='']
Draws vertical boxes for surface specified parametrically {xdat, ydat, zdat} from data points to x-y axis plane.
- cont zdat ['sch'=''
num=7 zval=nan
]
Draws num
-th contour lines for the matrix zdat at plane z = zval
(or at contour level if zval=nan
). Contours are plotted at constant zdat. If string contain 't' (or 'T') symbol then contour labels will be drawn below (or above) the contours.
- cont xdat ydat zdat ['sch'=''
num=7 zval=nan
]
Draws num
-th solid contours for the surface specified parametrically {xdat, ydat, zdat} at plane z = zval
(or at contour level if zval=nan
). Contours are plotted at constant zdat. If string contain 't' (or 'T') symbol then contour labels will be drawn below (or above) the contours. See also grid.
- contf zdat ['sch'=''
num=7 zval=nan
]
Draws num
-th solid contours for the matrix zdat at plane z = zval
(or at contour level if zval=nan
). Contours are plotted at constant zdat.
- contf xdat ydat zdat ['sch'=''
num=7 zval=nan
]
Draws num
-th solid contours for the surface specified parametrically {xdat, ydat, zdat} at plane z = zval
(or at contour level if zval=nan
). Contours are plotted at constant zdat.
- dens zdat ['sch'=''
zval=nan
]
Draws density plot for the matrix zdat at plane z = zval
.
- dens xdat ydat zdat ['sch'=''
zval=nan
]
Draws density plot for the surface specified parametrically {xdat, ydat, zdat} at plane z = zval
.
- fall zdat ['sch'='']
Draws fall lines for matrix zdat. This plot can be used as 3d generalization of plot. The number of lines depends on command meshnum.
- fall xdat ydat zdat ['sch'='']
Draws fall lines for surface specified parametrically {xdat, ydat, zdat}. This plot can be used as 3d generalization of plot. The number of lines depends on command meshnum.
- grid zdat ['sch'='']
Draws plane grid for the matrix zdat at plane z = zval
. The number of lines depends on command meshnum.
- grid xdat ydat zdat ['sch'='']
Draws plane grid for the surface specified parametrically {xdat, ydat, zdat} at plane z = zval
. The number of lines depends on command meshnum.
- mesh zdat ['sch'='']
Draws mesh lines for matrix zdat. The number of lines depends on command meshnum.
- mesh xdat ydat zdat ['sch'='']
Draws mesh lines for surface specified parametrically {xdat, ydat, zdat}. The number of lines depends on command meshnum.
- surf zdat ['sch'='']
Draws solid surface for matrix zdat.
- surf xdat ydat zdat ['sch'='']
Draws solid surface specified parametrically {xdat, ydat, zdat}.
- tile zdat ['sch'='']
Draws horizontal tiles for matrix zdat. This plot can be used as 3d generalization of step.
- tile xdat ydat zdat ['sch'='']
Draws horizontal tiles for surface specified parametrically {xdat, ydat, zdat}. This plot can be used as 3d generalization of step.
8. 3d plotting commands
These functions perform plotting of 3D data. 3D means that the data depended on 3 independent parameter (indexes). Most of commands have similar interface. There are 2 versions for drawing single data array and for parametrically specified data. If command allows to use parametric surface definition (depends on 4 data arrays xdat, ydat, zdat, adat) then its minor dimensions should be equal. At this arrays xdat, ydat, zdat can be one-dimensional. Optional string parameter 'stl' sets the color scheme. Previous color scheme is used by default. See also color and color schemes specification.
- cloud adat ['sch'='']
Draws cloud plot for 3d array adat. This plot is a set of faces with color and transparency proportional to value of adat. The resulting plot looks like cloud – low value is transparent but higher ones are not. See also surf3.
- cloud xdat ydat zdat adat ['sch'='']
Draws cloud plot for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. This plot is a set of faces with color and transparency proportional to value of adat. The resulting plot looks like cloud – low value is transparent but higher ones are not. See also surf3.
- cont3 adat 'dir' [
val=-1
'sch'='' num=7
]
Draws num
-th contour lines for 3d array adat. Contours are plotted at constant adat
at slice sval
in 'dir' direction. If string contain 't' (or 'T') symbol then contour labels will be drawn below (or above) the contours.
- cont3 xdat ydat zdat adat 'dir' [
val=-1
'sch'='' num=7
]
Draws num
-th contour lines for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. Contours are plotted at constant adat
at slice sval
in 'dir' direction. If string contain 't' (or 'T') symbol then contour labels will be drawn below (or above) the contours.
- conta adat ['sch'=''
num=7
]
Draws num
-th contour lines for 3d array adat. Contours are plotted at constant adat
at all central slices (in 'x','y','z' directions). If string contain 't' (or 'T') symbol then contour labels will be drawn below (or above) the contours.
- conta xdat ydat zdat adat ['sch'=''
num=7
]
Draws num
-th contour lines for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. Contours are plotted at constant adat
at all central slices (in 'x','y','z' directions). If string contain 't' (or 'T') symbol then contour labels will be drawn below (or above) the contours.
- contf3 adat 'dir' [
val=-1
'sch'='' num=7
]
Draws num
-th solid contours for 3d array adat. Contours are plotted at constant adat
at slice sval
in 'dir' direction.
- contf3 xdat ydat zdat adat 'dir' [
val=-1
'sch'='' num=7
]
Draws num
-th solid contours for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. Contours are plotted at constant adat
at slice sval
in 'dir' direction.
- contfa adat ['sch'=''
num=7
]
Draws num
-th solid contours for 3d array adat. Contours are plotted at constant adat
at all central slices (in 'x','y','z' directions).
- contfa xdat ydat zdat adat ['sch'=''
num=7
]
Draws num
-th solid contours for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. Contours are plotted at constant adat
at all central slices (in 'x','y','z' directions).
- dens3 adat 'dir' [
val=-1
'sch'='']
Draws density plot for 3d array adat. Density is plotted at slice sval
in 'dir' direction.
- dens3 xdat ydat zdat adat 'dir' [
val=-1
'sch'='']
Draws density plot for 3d array adat parametrically depending on coordinates {xdat ydat zdat}. Density is plotted at slice sval
in 'dir' direction.
- densa adat ['sch'='']
Draws density plot for 3d array adat. Density is plotted at all central slices (in 'x','y','z' directions).
- densa xdat ydat zdat adat ['sch'='']
Draws density plot for 3d array adat parametrically depending on coordinates {xdat ydat zdat}. Density is plotted at all central slices (in 'x','y','z' directions).
- grid3 adat 'dir' [
val=-1
'sch'='']
Draws grid for 3d array adat. Grid is plotted at slice sval
in 'dir' direction. The number of lines depends on command meshnum.
- grid3 xdat ydat zdat adat 'dir' [
val=-1
'sch'='']
Draws grid for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. Grid is plotted at slice sval
in 'dir' direction. The number of lines depends on command meshnum.
- grida adat ['sch'='']
Draws grid for 3d array adat. Grid is plotted at all central slices (in 'x','y','z' directions). The number of lines depends on command meshnum.
- grida xdat ydat zdat adat ['sch'='']
Draws grid for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat}. Grid is plotted at all central slices (in 'x','y','z' directions). The number of lines depends on command meshnum.
- surf3 adat ['sch'=''
num=5
]
Draws num
-th isosurfaces for 3d array adat at constatnt values of adat.
- surf3 xdat ydat zdat adat ['sch'=''
num=5
]
Draws num
-th isosurfaces for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat.
- surf3 adat
val
['sch'='']
Draws
isosurface for 3d array adat at constatnt values of adat=val
.
- surf3 xdat ydat zdat adat
val
['sch'=''
]
Draws num
-th isosurfaces for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat=val
. See also cloud, surf3c, surf3a.
9. Dual plotting commands
These plotting functions draw two (or three) data arrays simultaneously in different forms: as coloring or transparing, vector field, flow chart or mapping. There are 2 versions for drawing single data array and for parametrically specified data. If the command allows to use parametric surface definition (depends on 4, 5 or 6 data arrays xdat, ydat, zdat, adat, bdat, cdat) then its minor dimensions should be equal. At this arrays xdat, ydat, zdat can be one-dimensional. The dimensions of other data arrays (adat, bdat, cdat) must be equal. Optional string parameter 'stl' sets the color scheme. Previous color scheme is used by default. See also color and color schemes specification.
Commands for 2d arrays:
- dew udat vdat ['sch'=''
val=nan
]
Draws dew-drops (like drops under wind) for the plane vector field {udat, vdat} at level z = zval
. The color of drops is proportional to
. If string 'sch' contain 'A' then it looks as arrow plot (inverse drop direction). Note that this plot may require a lot of memory and CPU time.
- dew xdat ydat udat vdat ['sch'=''
val=nan
]
Draws dew-drops (like drops under wind) for the plane vector field {udat, vdat} parametrically depending on coordinates {xdat, ydat} at level z = zval
. The color of drops is proportional to
. If string 'sch' contain 'A' then it looks as arrow plot (inverse drop direction). Note that this plot may require a lot of memory and CPU time.
- flow udat vdat ['sch'=''
num=5 val=nan
]
Draws flow threads for the plane vector field {udat, vdat} at level z = zval
. The color of lines is proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source).
- flow xdat ydat udat vdat ['sch'=''
num=5 val=nan
]
Draws flow threads for the plane vector field {udat, vdat} parametrically depending on coordinates {xdat, ydat} at level z = zval
. The color of lines is proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source).
- pipe udat vdat ['sch'=''
rad=0.05 num=5 val=nan
]
Draws flow pipes for the plane vector field {udat, vdat} at level z = zval
. The color of pipes and its radius are proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). Negative rad
switch to pipe radius inverse proportional to
.
- pipe xdat ydat udat vdat ['sch'=''
rad=0.05 num=5 val=nan
]
Draws flow pipes for the plane vector field {udat, vdat} parametrically depending on coordinates {xdat, ydat} at level z = zval
. The color of pipes and its radius are proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). Negative rad
switch to pipe radius inverse proportional to
.
- surfa zdat cdat ['sch'='']
Draws solid surface for matrix zdat. Surface transparency is determined by values of cdat data array.
- surfa xdat ydat zdat cdat ['sch'='']
Draws solid surface specified parametrically {xdat, ydat, zdat}. Surface transparency is determined by values of cdat data array.
- surfc zdat cdat ['sch'='']
Draws solid surface for matrix zdat. Surface coloring is determined by values of cdat data array.
- surfc xdat ydat zdat cdat ['sch'='']
Draws solid surface specified parametrically {xdat, ydat, zdat}. Surface coloring is determined by values of cdat data array.
- vect udat vdat ['sch'=''
val=nan
]
Draws vector field for the plane vector field {udat, vdat} at level z = zval
. The length of hachures is proportional to
.
- vect xdat ydat udat vdat ['sch'=''
val=nan
]
Draws vector field for the plane vector field {udat, vdat} parametrically depending on coordinates {xdat, ydat} at level z = zval
. The length of hachures is proportional to
.
- vectc udat vdat ['sch'=''
val=nan
]
Draws vector field for the plane vector field {udat, vdat} at level z = zval
. The color of hachures is proportional to
and changes from colder (lower) at the start to warmer (higher) at the end. It allows one to determine the direction of the vector field.
- vectc xdat ydat udat vdat ['sch'=''
val=nan
]
Draws vector field for the plane vector field {udat, vdat} parametrically depending on coordinates {xdat, ydat} at level z = zval
. The color of hachures is proportional to
and changes from colder (lower) at the start to warmer (higher) at the end. It allows one to determine the direction of the vector field.
Commands for 3d arrays:
- flow udat vdat wdat ['sch'=''
num=3
]
Draws flow threads for the vector field {udat, vdat, wdat}. The color of lines is proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source).
- flow xdat ydat zdat udat vdat wdat ['sch'=''
num=3
]
Draws flow threads for the vector field {udat, vdat, wdat} parametrically depending on coordinates {xdat, ydat, zdat}. The color of lines is proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source).
- pipe udat vdat wdat ['sch'=''
rad=0.05 num=3
]
Draws flow pipes for the vector field {udat, vdat, wdat}. The color of pipes and its radius are proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). Negative rad
switch to pipe radius inverse proportional to
.
- pipe xdat ydat zdat udat vdat wdat ['sch'=''
rad=0.05 num=3
]
Draws flow pipes for the vector field {udat, vdat, wdat} parametrically depending on coordinates {xdat, ydat, zdat}. The color of pipes and its radius are proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). Negative rad
switch to pipe radius inverse proportional to
.
- surf3a adat cdat ['sch'=''
num=5
]
Draws num
-th isosurfaces for 3d array adat at constatnt values of adat. Isosurface transparency is determined by values of cdat data array.
- surf3a xdat ydat zdat adat cdat ['sch'=''
num=5
]
Draws num
-th isosurfaces for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat. Isosurface transparency is determined by values of cdat data array.
- surf3a adat cdat
val
['sch'='']
Draws num
-th isosurfaces for 3d array adat at constatnt values of adat=val
. Isosurface transparency is determined by values of cdat data array.
- surf3a xdat ydat zdat adat cdat
val
['sch'='']
Draws num
-th isosurfaces for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat=val
. Isosurface transparency is determined by values of cdat data array.
- surf3c adat cdat ['sch'=''
num=5
]
Draws num
-th isosurfaces for 3d array adat at constatnt values of adat. Isosurface coloring is determined by values of cdat data array.
- surf3c xdat ydat zdat adat cdat ['sch'=''
num=5
]
Draws num
-th isosurfaces for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat. Isosurface coloring is determined by values of cdat data array.
- surf3c adat cdat
val
['sch'='']
Draws isosurface for 3d array adat at constatnt values of adat=val
. Isosurface coloring is determined by values of cdat data array.
- surf3c xdat ydat zdat adat cdat
val
['sch'='']
Draws isosurface for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat=val
. Isosurface coloring is determined by values of cdat data array.
- vect udat vdat wdat ['sch'='']
Draws vector field {udat, vdat, wdat}. The length of hachures is proportional to
.
- vect xdat ydat zdat udat vdat wdat ['sch'='']
Draws vector field {udat, vdat, wdat} parametrically depending on coordinates {xdat, ydat, zdat}. The length of hachures is proportional to
.
- vectc udat vdat wdat ['sch'='']
Draws vector field {udat, vdat, wdat}. The color of hachures is proportional to
and changes from colder (lower) at the start to warmer (higher) at the end. It allows one to determine the direction of the vector field.
- vectc xdat ydat zdat udat vdat wdat ['sch'='']
Draws vector field {udat, vdat, wdat} parametrically depending on coordinates {xdat, ydat, zdat}. The color of hachures is proportional to
and changes from colder (lower) at the start to warmer (higher) at the end. It allows one to determine the direction of the vector field.
10. Other plotting function
These plotting commands draw density plot or contour lines in x, y, or z plain. If dat is 3-dimensional data array then interpolation to a given sval
is performed. These functions are useful for creating projections of the 3D data array to the bounding box. Optional string parameter 'stl' sets the color scheme. Optional parameter val
sets the value of coordiante on the slice. Previous color scheme and axis origin are used by default. See also color and color schemes specification.
- contx dat ['sch'=''
val=nan num=7
]
Draws num
-th contour lines of data array dat at slice x = val
.
- conty dat ['sch'=''
val=nan num=7
]
Draws num
-th contour lines of data array dat at slice y = val
.
- contz dat ['sch'=''
val=nan num=7
]
Draws num
-th contour lines of data array dat at slice z = val
.
- contfx dat ['sch'=''
val=nan num=7
]
Draws num
-th solid contours of data array dat at slice x = val
.
- contfy dat ['sch'=''
val=nan num=7
]
Draws num
-th solid contours of data array dat at slice y = val
.
- contfz dat ['sch'=''
val=nan num=7
]
Draws num
-th solid contours of data array dat at slice z = val
.
- densx dat ['sch'=''
val=nan
]
Draws density plot of data array dat at slice x = val
.
- densy dat ['sch'=''
val=nan
]
Draws density plot of data array dat at slice y = val
.
- densz dat ['sch'=''
val=nan
]
Draws density plot of data array dat at slice z = val
.
11. Data creation and deleting
These commands create new variable with specified name. Note, that if a variable with the same name exists then it will be overwritten. The only exception is the command delete which deletes specified variable and makes its memory free.
- new dat [
numx=1 numy=1 numz=1
]
Creates new variable with name dat and array sizes numx, numy, numz
. Array elements are set to zero.
- var dat
num v1 v2
Creates new variable with name dat for one-dimensional array of size num
. Array elements are equidistantly distributed in range [v1, v2
].
- list dat
v1
…
Creates new variable with name dat and fills it by numeric values of command arguments v1
…Command can create one-dimensional and two-dimensional arrays with arbitrary values. For creating 2d array the user should use delimiter — which means that the following values lie in next row. Array sizes are [maximal of row sizes × number of rows]. For example, command list 1 | 2 3
creates the array [1 0; 2 3]
. Note, that the maximal number of arguments is 1000.
- list dat d1 …
Creates new variable with name dat and fills it by data values of arrays of command arguments d1
…Command can create two-dimensional or three-dimensional (if arrays in arguments are 2d arrays) arrays with arbitrary values. Minor dimensions of all arrays in arguments should be equal to dimensions of first array d1. In the opposite case the argument will be ignored. Note, that the maximal number of arguments is 1000.
- copy dat1 dat2
Creates new variable with name dat1 and fills it by data values of array dat1
.
- read dat 'fname'
Creates new variable with name dat and fills it by data from file with name 'fname'. The sizes of data in file are determined automatically.
- read dat 'fname'
numx
[numy=1 numz=1
]
Creates new variable with name dat and fills it by data from file with name 'fname'. The sizes of data in file are determined by values numx, numy, numz
.
- subdata res dat
kx ky kz
Makes array res as extracted sub-array data from the original dat array keeping fixed positive index. For example, subdata a b -1 2
extracts 2nd row, subdata a b 4 -1
extracts 4th column, subdata a b -1 -1 3
extracts 3d slice and so on.
- delete dat
Deletes variable dat and makes its memory free. Can be useful for huge data arrays.
12. New data extraction (forming)
In contrast to the previous group these commands write the result only in existing
variables.
- hist res dat
num v1 v2
Makes array res of num points as distribution (histogram) of dat data values in range [v1, v2
].
- hist res dat wdat
num v1 v2
Makes array res of num points as distribution (histogram) of dat data values in range [v1, v2
]. Data array wdat contains weights and must have the same dimensions as array dat.
- max res dat 'dir'
Makes array res as maximal values of dat along direction(s) 'dir'.
- min res dat 'dir'
Makes array res as minimal values of dat along direction(s) 'dir'.
- resize res dat
mx
[my=1 mz=1
]
Makes array res of sizes mx, my, mz
interpolation data of array dat.
- sum res dat 'dir'
Makes array res as summation of dat along direction(s) 'dir'.
13. Data handling
- chdir 'path'
Change current directory to 'path'.
- save dat 'fname'
Saves data array dat to text file with name 'fname'.
- modify dat 'eqs' [vdat wdat]
Fills the value of dat array according to the formula in string 'eqs'. Formula is an arbitrary expression depending on variables x, y, z, u, v, w. Coordinates x, y, z are supposed to be normalized in interval [0,1]. Variable u is the original value of the array (see also Sec. 18). If optional data vdat, wdat (must be the same size as dat) is specified then variables v and w denote its values else it are zero.
- modify dat 'eqs' [
val=0
]
Fills the value of dat array according to the formula in string 'eqs' but do it only for slices ≥val
. Formula is an arbitrary expression depending on variables x, y, z, u. Coordinates x, y, z are supposed to be normalized in interval [0,1]. Variable u is the original value of the array (see also Sec. 18).
- smooth dat
type
['dir'='xyz']
Smooths the data dat in specified direction(s) 'dir' by method type
. Now 4 methods are supported: 0 does nothing, 1 linear averaging by 3 points, 2 linear averaging by 5 points, 3 quadratic averaging by 5 points.
- crop dat
n1 n2
'dir'
Cuts off (crops) edges of data array dat with indexes n<n1
or >n2
along direction 'dir'.
- squeeze dat
rx
[ry=1 rz=1
]
Reduces the data size of array dat by excluding data elements which indexes are not divisible by rx, ry, rz
correspondingly.
- swap dat 'dir'
Swaps the left and right parts of the data dat in given direction 'dir' (useful for Fourier spectrum).
- transpose dat ['dir'='yxz']
Transposes (shifts order of) dimensions of the data dat. New order of dimensions is specified in string 'dir'. This may be useful for the reading of one-dimensional data.
- transform dat 'type' real imag
Do integral transformation of complex data real, imag on specified direction. Now only Fourier transformation is supported. The order of transformations is specified in string 'type': first character for x-dimension, second one for y-dimension, third one for z-dimension. The possible character are: 'f' is forward Fourier transformation, 'i' is inverse Fourier transformation, 'n' or ' ' is no transformation.
- fill dat
v1 v2
Equidistantly fills the data values of dat to range [x1, x2
].
- extend dat
dim1
[dim2=0
]
Increases the dimensions of the data dat by inserting new (|n1|+1)-th slices after (for n1
>0) or before (for n1
<0) the existing one. It is possible to insert 2 dimensions simultaneously for 1d data by using parameter n2
. Data to new slices is the copy from the existing one. For example, for n1>0 new array will be aijnew = aiold where j = 0…n1. Correspondingly, for n1<0 new array will be ajinew = aiold where j = 0…|n1|.
- norm dat
v1 v2
[sym=off
]
Normalizes the data values of dat to range [v1, v2
]. If flag sym=on
then symmetrical interval [-max(|v1|, |v2|
), max(|v1|, |v2|
)] is used.
- cumsum dat 'dir'
Cumulative summation of the data in given direction or directions.
- diff dat 'dir'
Differentiates the data in given direction or directions.
- diff2 dat 'dir'
Double-differentiates (like Laplace operator) the data in given direction.
- integrate dat 'dir'
Integrates (like cumulative summation) the data in given direction or directions.
- addto dat
val
Adds number to data.
- addto dat dat2
Adds data to data (cell-by-cell).
- subto dat
val
Subtracts number from data
- subto dat dat2
Subtracts data from data (cell-by-cell).
- multo dat
val
Multiplies data by number
- multo dat dat2
Multiplies data by data (cell-by-cell).
- divto dat
val
Divides data by number.
- divto dat dat2
Divides data by data (cell-by-cell).
14. Color specification
MGL script have the only way for color specification. It is a symbols (characters) wkrgbcymhRGBCYMHW each of them define unique color. Normally capital letter gives darker color than lowercase one. The full list of characters is: k – black, r – red, R – dark red, g – green, G – dark green, b – blue, B – dark blue, c – cyan, C – dark cyan, m – magenta, M – dark magenta, y – yellow, Y – dark yellow (gold), h – gray, H – dark gray, w – white,
W – bright gray, l – green-blue, L – dark green-blue, e – green-yellow, E – dark green-yellow, n – sky-blue, N – dark sky-blue, u – blue-violet, U – dark blue-violet, p – purple, P – dark purple, q – orange, Q – dark orange (brown).
[contents]
15. Line style specification
MGL script use strings for specifying the parameters of lines and marks. The string may contain specification for color (wkrgbcymhRGBCYMHW), dashing style (-|;:ji or space), width (0123456789) and marks (o+xsd.^v). If one of type of information is omitted then the previous values are used. If string is empty then solid line with next color from palette is used. By default palette contain following colors:
dark gray,
blue,
green,
red,
cyan,
magenta,
yellow,
gray,
blue-green,
sky-blue,
orange,
yellow-green,
blue-violet,
purple.
The color types are defined by symbols as described in Sec. 14.
Dashing styles has the following meaning: space – no line (usable for plotting only marks), – – solid line (■■■■■■■■■■■■■■■■), | – dashed line (■■■■■■■■□□□□□□□□), ; – small dashed line (■■■■□□□□■■■■□□□□), : – dotted line (■□□□■□□□■□□□■□□□), j – dash-dotted line (■■■■■■■□□□□■□□□□), i – small dash-dotted line (■■■□□■□□■■■□□■□□).
Marker types are: o – circle, + – cross, x – skew cross, s - square, d - rhomb (or diamond), . – point, ^ – triangle up, v – triangle down.
One may specify to draw special symbol (an arrow) at beginning and at the end of a line. It is possible if specification string contain one of following symbols: A – usual arrow, V – inner arrow, I – transverse hachures (or stop mark), K – arrow with hachures (or dimension mark), T – triangle, S – square, D – rhomb, O – circle, _ – nothing (it is default). At this there is a rule: first symbol specify the arrow at end of line, second symbol specify the arrow at beginning of line. For example, 'r-A' define red solid line with usual arrow at the end, 'b-A|' defien blue dash line with arrow at the end and with hachures at start, '-_O' define the line with current style and with circle at start. This styles are applicable during graphics plotting too (for example, plot).
contents
16. Color scheme specification
The color map scheme is used for coloring surfaces and other and is specified by the string. String may contain several characters which are color id (see Sec. 14) or character 'd' which denotes interpolation by 3d position instead of coloring by amplitude.
For coloring by amplitude (most common) the final color is linear interpolation of color array. The color array is constructed from string ids. The argument is the amplitude normalized between color range (see caxis, crange). For example, string containing 4 characters 'bcyr'
corresponds to colorbar from blue (lowest value) through cyan (next value) through yellow (next value) to red (highest value). String 'kw'
corresponds to colorbar from black (lowest value) to white (highest value). String 'm'
corresponds to simple magenta color.
There are several useful combination. String 'kw'
corresponds to simplest gray color scheme when higher values are brighter. String 'wk'
presents inverse gray color scheme when higher value is darker. Strings "kRryw"
, 'kGgw'
, 'kBbcw'
present the well-known "hot", "summer" and "winter" color schemes. Strings 'BbwrR'
and 'bBkRr'
allow to view bicolor figure on white or black background when negative values are blue and positive values are red. String 'BbcyrR'
gives color scheme similar to well-known "jet" color scheme.
For coloring by coordinate the final color is determined by position of point in 3d space and is calculated by formula c=x*c[1] + y*c[2] + z*c[3]. Herec[1], c[2], c[3] are the first three elements of color array; x, y, z are normalized coordinates of the point. This type of coloring is useful for isosurface plot when color may show the exact position of peace of surface. For example, try surf3 a 'bgrd'
for some tensor data a.
[contents]
17. Text and font specification
MGL script use strings for specifying the font type and aligning. The string can be any combination of characters: rgbisLCR. The font types are: s – script font/style, r – roman font, g – gothic font, i – italic style, b – bold style. By default roman simplex font (that is '') is used. The align types are: L – align left (default), C – align center, R – align right.
Parsing of the string to special (TeX-like) commands will be done always. There are commands for the font style changing inside the string (for example, use \b for bold font): a – overlined, b – bold, g – gothic, i – italic, r – roman (throw any other attributes), s – script, u – underlined, . – centered. The lower and upper indexes are specified by '_' and '^' symbols. The braces {} save/restore font state. For example, string 'sin(x^2)'
will lift up the last bracket ')'. Correct version is 'sin({x^2})'
or 'sin( x^2 )'
. For drawing square root of some expression one may use '\sqrt{\a x^2 + y^2}'
.
The abbreviations of Greek letters are: α – \alpha, β – \beta, γ – \gamma, δ – \delta, ε – \epsilon, η – \eta, ι – \iota, χ – \chi, κ – \kappa, λ – \lambda, μ – \mu, ν – \nu, o – \o, ω – \omega, ϕ – \phi, π – \pi, ψ – \psi, ρ – \rho, σ – \sigma, θ – \theta, τ – \tau, υ – \upsilon, ξ – \xi, ζ – \zeta, ς – \varsigma, ɛ – \varepsilon, ϑ – \vartheta, φ – \varphi, ϰ – \varkappa; A – \Alpha, B – \Beta, Γ – \Gamma, Δ – \Delta, E – \Epsilon, H – \Eta, I – \Iota, C – \Chi, K – \Kappa, Λ – \Lambda, M – \Mu, N – \Nu, O – \O, Ω – \Omega, Φ – \Phi, Π – \Pi, Ψ – \Psi, R – \Rho, Σ – \Sigma, Θ – \Theta, T – \Tau, Υ – \Upsilon, Ξ – \Xi, Z – \Zeta.
The full list of special TeX symbols are: ∠ – \angle,
– \aleph, ⋅ – \cdot, ♣ – \clubsuit, ✓ – \checkmark, ∪ – \cup, ∩ – \cap, ♢ – \diamondsuit, ◇ – \diamond,
– \div,
↓ – \downarrow, † – \dag, ‡ – \ddag, ≡ – \equiv, ∃ – \exists, ⌢ – \frown, ♭ – \flat, ≥ – \ge, ≥ – \geq, ≧ – \geqq, ← – \gets, ♡ – \heartsuit, ∞ – \infty,
– \in, ∫ – \int, \Int, ℑ – \Im, ♢ – \lozenge, ⟨ – \langle, ≤ – \le, ≤ – \leq, ≦ – \leqq, ← – \leftarrow, ∓ – \mp, ∇ – \nabla, ≠ – \ne, ≠ – \neq, ♮ – \natural, ∮ – \oint, ⊙ – \odot, ⊕ – \oplus, ∂ – \partial, ∥ – \parallel, ⊥ –\perp, ± – \pm, ∝ – \propto, ∏ – \prod, ℜ – \Re, → – \rightarrow, ⟩ – \rangle, ♠ – \spadesuit, ~ – \sim, ⌣ – \smile, ⊂ – \subset, ⊃ – \supset,
– \sqrt, § – \S, √ – \surd, ♯ – \sharp, ∑ – \sum, × – \times, → – \to, ∴ – \therefore, ↑ – \uparrow, ℘ – \wp.
[contents]
18. Formulas and functions
Formulas in MGL scripts is string with functions, operators, parentheses, variables, numbers and so on. There is no difference between lower or upper case in formulas. There are a lot of functions and operators available. The operators are: + – addition, – – subtraction, * – multiplication, / – division, ^ – integer power. Also there are logical "operators": < – true if x<y, > – true if x>y, = – true if x≡y, & – true if x and y both nonzero, | – true if x or y nonzero. These logical operators have lowest priority and return 1 if true or 0 if false.
The basic functions are: sqrt(x) – square root of x, pow(x,y) power x in y, ln(x) – natural logarithm of x, lg(x) – decimal logarithm of x, log(a,x) – logarithm base a of x, abs(x) – absolute value of x,sign(x) – sign of x, mod(x,y) – x modulo y, step(x) – step function, rnd – random number, pi – number π = 3.1415926…
Trigonometric functions are: sin(x), cos(x), tan(x) (or tg(x)). Inverse trigonometric functions are: asin(x), acos(x), atan(x). Hyperbolic functions are: sinh(x) (or sh(x)), cosh(x) (or ch(x)), tanh(x) (or th(x)). Inverse hyperbolic functions are: asinh(x), acosh(x), atanh(x).
There are a set of special functions: gamma(x) – Gamma function Γ(x) = ∫0∞ tx-1 exp(-t) dt, psi(x) – digamma function ψ(x) = Γ′(x)/Γ(x) for x≠0, ai(x) – Airy function Ai(x), bi(x) – Airy function Bi(x), cl(x) – Clausen function, li2(x) (or dilog(x)) – dilogarithm Li2(x) = -ℜ∫0xds log(1-s)/s, sinc(x) – compute sinc(x) = sin(πx)/(πx) for any value of x, zeta(x) – Riemann zeta function ζ(s) = ∑k=1∞k-s for arbitrary s≠1, eta(x) – eta function η(s) = (1 - 21-s)ζ(s) for arbitrary s, lp(l,x) – Legendre polynomial Pl(x), (|x|≤1, l≥0), w0(x) – principal branch of the Lambert W function, w1(x) – principal branch of the Lambert W function. Function W(x) is defined to be solution of the equation: W exp(W) = x.
The exponent integrals are: ci(x) – Cosine integral Ci(x) = ∫0xdt cos(t)/t, si(x) – Sine integral Si(x) = ∫0xdt sin(t)/t, erf(x) – error function erf(x) = (2/
π) ∫0xdt exp(-t2) , ei(x) – exponential integral Ei(x) = -PV(∫-x∞dt exp(-t)/t) (where PV denotes the principal value of the integral), e1(x) – exponential integral E1(x) = ℜ∫1∞dt exp(-xt)/t, e2(x) – exponential integral E2(x) = ℜ∫1∞dt exp(-xt)/t2, ei3(x) – exponential integral Ei3(x) = ∫0xdt exp(-t3) for x≥0.
Bessel functions are: j(nu,x) – regular cylindrical Bessel function of fractional order nu, y(nu,x) – irregular cylindrical Bessel function of fractional order nu, i(nu,x) – regular modified Bessel function of fractional order nu, k(nu,x) – irregular modified Bessel function of fractional order nu.
Elliptic integrals are: ee(k) – complete elliptic integral is denoted by E(k) = E(π/2,k), ek(k) – complete elliptic integral is denoted by K(k) = F(π/2,k), e(phi,k) – elliptic integral E(φ,k) = ∫0φdt
(1 - k2sin2(t)), f(phi,k) – elliptic integral F(φ,k) = ∫0φdt 1/
(1 - k2sin2(t))
Jacobi elliptic functions are: sn(u,m), cn(u,m), dn(u,m), sc(u,m), sd(u,m), ns(u,m), cs(u,m), cd(u,m), nc(u,m), ds(u,m), dc(u,m), nd(u,m).
[contents]
19. Command options
Command options allow the easy setup of the plot by changing of global settings only for this plot. Options are specified at the end of string. Each option is separated from the previous text by symbol ';
'. Options work so that them remember the current settings, change settings as it being set in the option, execute command and return the original settings back. So, the options usage for data handling commands or for graphics setup commands is useless.
The most useful options are xrange, yrange, zrange. They sets the boundaries for data change. This boundaries are used for automatically filled variables. So, these options allow one to change the position of some plots. For example, in command plot y; xrange 0.1 0.9
the x coordinate will be equidistantly distributed in range 0.1 ... 0.9.
The full list of options are:
- alpha
val
Sets alpha value (transparency) of the plot. The value should be in range [0, 1].
- alphadef
val
Sets alpha value (transparency) of the plot. The value should be in range [0, 1].
- ambient
val
Sets brightness of ambient light for the plot. The value should be in range [0, 1].
- crange
val1 val2
Sets boundaries of color change for the plot.
- cut
val
Sets whether to cut or to project the plot points lying outside the bounding box.
- fontsize
val
Sets the size of text.
- meshnum
val
Work like meshnum command.
- xrange
val1 val2
Sets boundaries of x coordinate change for the plot.
- yrange
val1 val2
Sets boundaries of y coordinate change for the plot.
- zrange
val1 val2
Sets boundaries of z coordinate change for the plot.
[contents]
20. Suffixes for variable
Suffixes can get some numerical value (like its size, maximal or minimal value, the sum of elements and so on) of the data array in variable and use it later as usual number in command arguments. The suffixes start from point '.' right after (without spaces) variable name or its subarray. For example, a.nx
give the x-size of data a b(1).max
give maximal value of second row of variable b c(:,0).sum
give sum of element in first column of c
and so on.
The full list of suffixes are:
- nx, ny, nz
Give the data size in x-, y-, z-direction correspondingly.
- max
Give maximal value of the data.
- min
Give minimal value of the data.
- mx, my, mz
Give x-, y-, z-position of data maximum.
- ax, ay, az, aa
Give x-, y-, z-position of data mass center or average data value.
- wx, wy, wz, wa
Give width in x-, y-, z-direction or data dispersion value.
- sx, sy, sz, sa
Give skewness in x-, y-, z-direction or data skewness value.
- kx, ky, kz, ka
Give kurtosis in x-, y-, z-direction or data kurtosis value.
- sum
Give sum of data values.
- a
Give first value of data array.
- fst
Give first nonzero value of data array.
- lst
Give last nonzero value of data array.
[contents]