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. Command options).
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 string, a variable name or a number.
').') 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. Also you can extract a part of array from m-th to n-th element by code a(m:n,:,:) or just a(m:n).##) then it is possible to use any column combinations defined by formulas, like a('n*w^2/exp(t)').sqrt(dat(:,5)+1) will produce temporary variable with data values equal to tmp[i,j] = sqrt(dat[i,5,j]+1). Such variables can not be used as 1st argument for commands which create (return) the data (like new, read, hist and so on).nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1 are treated as number if they were not redefined by user. Variables with suffixes are treated as numbers. Also results of formulas with sizes 1x1x1 are treated as number (for example, pi/dat.nx).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]
val=on] off. Use command transparent off in particular plot to disable its transparency. val val valval [dist=0.25] val for the picture. If val=0 then fog is absent. Fog will start from relative distance dist from the leading edge.val=6]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. Text and font specification. val val=on]num xpos ypos zpos ['col'='w' br=0.5 ]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. num val val.val valval valval=-1 then plot autsizing will be switched on. See also zoom.val on. w h val val [stt=1] stt>0 set relative length of subticks which is in sqrt(1+stt) times smaller.'k' or 'w' depending on transparency type). If 'sub'='' then ticks style is used (i.e. 'sub'='stl').val on.val0.x1 y1 x2 y2ax ay [az=1] ax:ay:az. For the best effect it should be used after rotate command. num ind ind-th cell of column with num cells. The position is relative to previous subplot call (or inplot with rel=off).x1 x2 y1 y2 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. valtetz tetx [tety=0] tetz, tetx, tety. tet x y z x,y,z} on angle tet. w h pos [dx=0 dy=0] pos-th cell of w*h grid of the whole frame area. Optional paramters dx, dy add additional shifting of plotting (in units relative to subplot sizes). 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]
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.
x1 y1 x2 y2x1 y1 z1 x2 y2 z2z1 z2). Initial ranges are [-1, 1].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. Formulas.howhow define the coordinates: 0 -- Cartesian coordinates (no transformation); 1 -- Polar coordiantes {xn=x*cos(y), yn=x*sin(y), zn=z}; 2 -- Spherical coordinates {xn=x*sin(y)*cos(z), yn=x*sin(y)*sin(z), zn=x*cos(y)}; 3 -- Parabolic coordinates {xn=x*y, yn=(x2-y2)/2, zn=z}; 4 -- Paraboloidal coordinates {xn=(x2-y2)*cos(z)/2, yn=(x2-y2)*sin(z)/2, z_n=x*y}; 5 -- Oblate coordinates {xn=cosh(x)*cos(y)*cos(z), yn=cosh(x)*cos(y)*sin(z), zn=sinh(x)*sin(y)}; 6 -- Prolate coordinates {xn=sinh(x)*sin(y)*cos(z), yn=sinh(x)*sin(y)*sin(z), zn=cosh(x)*cos(y)}; 7 -- Elliptic coordinates {xn=cosh(x)*cos(y), yn=sinh(x)*sin(y), zn=z}; 8 -- Toroidal coordinates @math{xn=sinh(x)*cos(z)/(cosh(x)-cos(y)), yn=sinh(x)*sin(z)/(cosh(x)-cos(y)), zn=sin(y)/(cosh(x)-cos(y))}; 9 -- Bispherical coordinates {xn=sin(y)*cos(z)/(cosh(x)-cos(y)), yn=sin(y)*sin(z)/(cosh(x)-cos(y)), zn=sinh(x)/(cosh(x)-cos(y))}; 10 -- Bipolar coordinates {xn=sinh(x)/(cosh(x)-cos(y)), yn=sin(y)/(cosh(x)-cos(y)), zn=z}.adjust=off] adjust=on.c1 c2 pos=0] pos=0] contd command. Parameter pos specifies the position of colorbar: 0 - at right (default), 1 - at left, 2 - at top, 3 - at bottom. add=off frac=0] add=on shows that the new range will be joined to existed one (but will not replace it). Parameter fact add additional range increase on value (Max-Min)*fact. See also caxis.c1 c2[c1, c2]. The same as caxis.val on then points are excluded from the plot (it is default) otherwise the points are projected to edges of the bounding box. x1 y1 z1 x2 y2 z2x0 y0 [z0=nan] x0, y0, z0}. If one of values is nan then MathGL library try to select optimal axis position.pos=1 shift=0]pos=1 shift=0]pos=1 shift=0]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. Parameter shift specify additional shifting of the label. See also text. For more detail see Sec. Text and font specification. add=off frac=0] add=off frac=0] add=off frac=0] add=on shows that the new range will be joined to existed one (nut will not replace it). Parameter fact add additional range increase on value (Max-Min)*fact. See also axis.v1 v2v1 v2v1 v2[v1, v2]. See also axis.dx [sx=0 tx=nan] dx [sx=0 tx=nan] dx [sx=0 tx=nan] dx>0) or it's number (if dx<0). Zero value dx=0 sets logarithmic ticks. Parameter sx sets the number of subticks. Parameter tx set the starting points for ticks (if not nan).val1 'lbl1' [val2 'lbl2' ...] val1 'lbl1' [val2 'lbl2' ...] val1 'lbl1' [val2 'lbl2' ...] val1, val2, ... and labels 'lbl1', 'lbl2', ... for ticks along x-, y-, z-axis. Labels may contain TeX symbols also. x y ['col'='r']x y z ['col'='r']x y z} with color 'col'. x1 y1 z1 x2 y2 z2 r1 [r2=-1 'stl'='' edge=off]x1, y1, z1} with radius r1 to point {x2, y2, z2} with radius r2, using line style 'stl'. If radius r2<0 then the radius r1 is used (r2=r1). Flag edge set to draw or not the edges of the cone.x1 y1 dx1 dy1 x2 y2 dx2 dy2 ['stl'=''] x1 y1 z1 dx1 dy1 dz1 x2 y2 z2 dx2 dy2 dz2 ['stl'=''] 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. x0 y0 z0 dx dy dz r ['col'='' sh=1 asp=1]x0 y0 dx dy r ['col'='' sh=1 asp=1]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.x0 y0 z0 wy wz ['stl'='' d1=0 d2=0]x0 y0 z0 wx wz ['stl'='' d1=0 d2=0]x0 y0 z0 wx wy ['stl'='' d1=0 d2=0]x0, y0, z0 with widths wx, wy, wz along corresponding directions. At this colors, specified by 'stl', can be the same for all vertexes or different if all 4 colors are specified for each vertex. Parameters d1,d2≠0 set additional shift of the last vertex. See also rect.x y 'fname' [n=0 'fnt'='' size=-1.4]x y z 'fname' [n=0 'fnt'='' size=-1.4]n-th line of the file 'fname' at position {x y z} by font 'fnt' with size. By default font parameters from font command are used. For more details see Sec. Text and font specification.zval=nan num=100]zval for x distributed in xrange. You do not need to create the data arrays to plot it. The parameter num set the minimal number of points along coordinate(s) for plots. See also plot.num=100]num set the minimal number of points along coordinate(s) for plots.num=100]num set the minimal number of points along coordinate(s) for plots. See also surf.num=100]num set the minimal number of points along coordinate(s) for plots. See also surf.pos=3 'fnt'='rL' size=-1 llen=0.1]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). Parameter llen set the relative width of the line sample and the text indent. x y ['fnt'='rL' size=-1 llen=0.1]size. Parameters x, y sets the position of the legend. Parameter llen set the relative width of the line sample and the text indent. x1 y1 x2 y2 ['stl'='']x1 y1 z1 x2 y2 z2 ['stl'='']x1, y1, z1} to {x2, y2, z2}, using line style 'stl'.x1 y1 x2 y2 ['stl'='']x1 y1 z1 x2 y2 z2 ['stl'='']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.x0 y0 r ['col'='']x0 y0 z0 r ['col'='']r and center at point {x0, y0, z0} using color 'col'. x y 'txt' ['fnt'='' size=-1.4]x y z 'txt' ['fnt'='' size=-1.4]x y z} by font 'fnt' with size. By default font parameters from font command are used. For more details see Sec. Text and font specification.x y dx dy 'txt' [size=-1.4]x y z dx dy dz 'txt' [size=-1.4]x y z} along direction {size. By default font parameters from font command are used. For more details see Sec. Text and font specification.size=-2]size. By default font parameters from font command are used. For more details see Sec. Text and font specification.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. If array xdat is not specified then its an automatic array is used with values equidistantly distributed along x. Also the zval (the default is at the bottom of the bounding box) is used instead zdat if last is not specified.
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.
zval=nan] zval=nan]zval=nan above=off] zval=nan above=off]zval (the default is at the bottom of the bounding box). Bars are drawn side-by-side (if above = off) or one above another (if above = on). Marks at data points are not drawn. zval=nan above=off] zval=nan above=off]above=off]above = off) or one above another (if above = on). Marks at data points are not drawn. zval=nan]zval=nan]zval (the default is at the bottom of the bounding box). All dimensions of arrays yerr and ydat must be equal. See also plot.zval=nan]zval (the default is at bottom of bounding box). All dimensions of arrays xerr, yerr and xdat, ydat must be equal. zval=nan] zval=nan] zval=nan] zval=nan]inside=off] inside=off] inside=off set to fill are with y1<y<y2 else the area with y2<y<y1 will be also filled. zval=nan] zval=nan]zval=nan] zval=nan]zval=nan] zval=nan]sise=-1 zval=nan]sise=-1 zval=nan]sise=-1]zval=nan] zval=nan] zval=nan] zval=nan] zval=nan] rval ['stl'='' zval=nan] rval ['stl'='' zval=nan] rval ['stl'=''] rval along the curve between points {xdat, ydat, zdat}.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 arrays xdat, ydat are not specified then its an automatic arrays are used with values equidistantly distributed along x and y. 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.
num=3] num=3]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. num=7 zval=nan]num=7 zval=nan]num-th contour lines 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.zval=nan]zval=nan]num=7 zval=nan]num=7 zval=nan]num-th solid contours for the surface specified parametrically {xdat, ydat, zdat} at plane z = zval (or at contour level if zval=nan) with manual colors. Contours are plotted at constant zdat with color sch[i%strlen(sch)] (where i=0...num-1).zval=nan]zval=nan]sch[i%strlen(sch)]).num=7 zval=nan]num=7 zval=nan]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.zval=nan]zval=nan]zval=nan] zval=nan]zval. zval. The number of lines depends on command meshnum. 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. If arrays xdat, ydat, zdat are not specified then its an automatic arrays are used with values equidistantly distributed along x, y and z.
Optional string parameter 'stl' sets the color scheme. Previous color scheme is used by default. See also color and color schemes specification.
r ['sch'='' flag=0 num=3] num-th isosurfaces for 3d array adat at constatnt values of adat. This is special kind of plot for adat specified in accompanied coordinates along curve tr with orts g1, g2 and with transverse scale r. Variable flag is bitwise flag: 0x1 - draw in accompanied (not laboratory) coordinates; 0x2 - draw projection to ρ×z plane; 0x4 - draw normalized in each slice field. The x-size of data arrays tr, g1, g2 must be nx≥3. The y-size of data arrays tr, g1, g2 and z-size of the data array adat must be equal. val=-1 'sch'='' num=7]val=-1 'sch'='' num=7]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. val=-1 'sch'='']val=-1 'sch'='']num=7] num=7]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. val=-1 'sch'='' num=7]val=-1 'sch'='' num=7]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. val=-1 'sch'='']val=-1 'sch'='']num=7] num=7]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).val=-1 'sch'='']val=-1 'sch'='']sval in 'dir' direction. val=-1 'sch'='']val=-1 'sch'='']sval in 'dir' direction. The number of lines depends on command meshnum. num=5] num=5]num-th isosurfaces for 3d array adat parametrically depending on coordinates {xdat, ydat, zdat} at constatnt values of adat.val ['sch'=''] val ['sch'='']val (i.e. isosurface are drawn for adat=val). See also cloud, surf3c, surf3a.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 and so on) must be equal. If arrays xdat, ydat, zdat are not specified then its an automatic arrays are used with values equidistantly distributed along x, y and z.
Optional string parameter 'stl' sets the color scheme. Previous color scheme is used by default. See also color and color schemes specification.
Commands for general dual arrays:
pnts=on]pnts=on]pnts=off then face is drawn otherwise the color ball at matrix knots are drawn.dn ['sch'='']dn ['sch'='']dn points.num=5]num=5]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. val ['sch'='']val ['sch'='']val (i.e. isosurface are drawn for adat=val). num=5]num=5]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. val ['sch'='']val ['sch'='']val (i.e. isosurface are drawn for adat=val). val=nan]val=nan]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.num=5 val=nan]num=5 val=nan]zval. The color of lines is proportional to
. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). x0 y0 udat vdat ['sch'='' zval=nan]x0 y0 xdat ydat udat vdat ['sch'='' zval=nan]x0, y0} 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). num=3]num=3]
. x0 y0 z0 udat vdat wdat ['sch'='']x0 y0 z0 xdat ydat zdat udat vdat wdat ['sch'='']x0, y0, z0}. Arrays {udat, vdat, wdat} must be 3-ranged tensors with equal sizes and the color of lines is proportional to
. rad=0.05 num=5 val=nan]rad=0.05 num=5 val=nan]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
. rad=0.05 num=3]rad=0.05 num=3]
.zval=nan len=0]len=0]
. val=nan]val=nan]zval. The length and color of arrows are proportional to
.
. val=nan]val=nan]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.
. val=nan]val=nan]zval. The length of hachures is proportional to
.
. 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.
val=nan num=7] val=nan num=7] val=nan num=7] num-th contour lines of data array dat at slice x,y,z = val. val=nan num=7] val=nan num=7] val=nan num=7] num-th solid contours of data array dat at slice x,y,z = val.val=nan] val=nan] val=nan] val.val=nan] valval is nonzero.valval is nonzero.v1 v2 [dv=1]v1 to v2 with the step dv.valonce on and once off will be executed only once. Useful for large data manipulation in programs like UDAV.solid=off]solid=on. If 'fname'='' then the file frameNNNN.jpg is used, where NNNN is current frame id.numx=1 numy=1 numz=1]numx, numy, numz. Array elements are set to zero. num v1 [v2=nan] num. Array elements are equidistantly distributed in range [v1, v2]. If v2=nan then v2=v1 is used. v1 … 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. 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. on_axis=on]valon_axis=on) or in modify command (for on_axis=off).v1=0 v2=0] v1, v2]. Maximal and minimal values will be used if v1=v2.v1=0 v2=1] v1, v2].numx [numy=1 numz=1] numx, numy, numz.slice=off] slice=off or as slice-by-slice if slice=on.v1 v2 [step=1 slice=off] sprintf(fname,templ,val), where val changes from v1 to v2 with step step. The data load one-by-one in the same slice if slice=off or as slice-by-slice if as slice=on.dim=2]dim parameter. The sizes of data specified at beginning of the file (first dim numbers). mx [my=1 mz=1] norm=on]norm=on]norm=on]norm=on then coordinates from idat, jdat, kdat are supposed to be normalized in range [0,1] otherwise in range [0,nx], [0,ny], [0,nz] correspondingly. num v1 v2 [nsub=0] num v1 v2 [nsub=0] v1, v2]. Data array wdat contains weights (all weight is 1 if wdat is not specified) and must have the same dimensions as array dat. Parameter nsub define the number of additional interpolated points (for smoothness of histogram).mx [my=1 mz=1] mx, my, mz with interpolated data of array dat. kx [ky=: kz=:] 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.dn ['dir'='x']dn. For example if 'dir'='x', result will have size {int(nx/dn), dn, ny} and it will contain res[i,j,k]=|∑d=0...dn exp(I*j*d) * (real[i*dn+d,k]+I*imag[i*dn+d,k])| / dn.dz=0.1 k0=100]k0*ham(p,q,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators. Parameters ini_re, ini_im specify real and imaginary part of initial field distribution. Coordinates of the equation (and the solution) are supposed to be in the bounding box. Note, that really this ranges are increased by factor 3/2 for purpose of reducing reflection from boundaries. Parameter dz set the step along evolutionary coordinate z. At this moment, simplified form of function ham is supported – all "mixed" terms (like 'x*p'->x*d/dx) are excluded. For example, in 2D case this function is effectively 'ham' = 'f(p,z) + g(x,z,u)'. However commutable combinations (like 'x*q'->x*d/dy) are allowed. Here variable 'u' is used for field amplitude |u|. This allow one solve nonlinear problems – for example, for nonlinear Shrodinger equation you may set 'ham'='p^2+q^2-u^2'. You may specify imaginary part for wave absorption, like 'ham'='p^2+i*x*(x>0)', but only if dependence on variable 'i' is linear (i.e. 'ham'='sth*(hre+i*him)').r=1 k0=100 xx=0 yy=0]x0 y0 z0 p0 q0 v0 [dt=0.1 tmax=10]x0, y0, z0, p0, q0, v0}. Parameters dt and tmax specify the integration step and maximal time for ray tracing. Result res is array of 7 columns {x,y,z,p,q,v,t} with dimensions 7×int(tmax/dt+1).detail=off] detail=off). v1 v2 ['dir'='x'] x1, x2] along direction 'dir'. val=0]val. Formula is an arbitrary expression depending on variables 'x', 'y', 'z', 'u'. Coordinates 'x', 'y', 'z' are data indexes normalized in interval [0,1]. Variable 'u' is the original value of the array (see also Sec. Formulas).val [i=: j=: k=:]val. Negative indexes i, j, k = : set the value val to whole range in corresponding direction(s). For example, put a val : 0 : sets a[i,0,j]=val for i=0...(a.nx-1), j=0...(a.nz-1). [i=: j=: k=:]i, j, k = : set the range in corresponding direction(s). At this minor dimensions of array v should be large than corresponding dimensions of array a. For example, put a v : 0 : sets a[i,0,j]=v.ny>nz ? v[i,j] : v[i], where i=0...(a.nx-1), j=0...(a.nz-1) and condition v.nx>=a.nx is true.
n1 n2 'dir' n1 or >n2 along direction 'dir'. dim1 [dim2=0] n1>0) or before (for n1<0) the existing one. The nember of slices will be |n1|. It is possible to extend 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|. mx [my=0 mz=0] my or mz are zero then it will be selected for optimal filling of data array. For example, if my=0 then ny wil be equal to nx*ny*nz/mx and mz will be 1. rx [ry=1 rz=1] rx, ry, rz correspondingly. diff a x y and usual derivative along 'y' will be diff a y x.v1 v2 [sym=off dim=0] v1, v2]. If flag sym=on then symmetrical interval [-max(|v1|, |v2|), max(|v1|, |v2|)] is used. The changes will be applied only for slices >dim.v1 v2 ['dir'='z' keep=on sym=off] v1, v2]. If flag sym=on then symmetrical interval [-max(|v1|, |v2|), max(|v1|, |v2|)] is used. If keep=on then maximal value of k-th slice will be limited by sqrt(Σ aij(k)/Σ aij(0)).da=2*pi] da in given direction 'dir'. type ['dir'='xyz']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. val val val val x y ['pre'='' 'fnt'='' size=-1]x y z ['pre'='' 'fnt'='' size=-1]x, y, z} by font 'fnt' with size. String 'pre' sets the prefix which will be printed before formula. By default font parameters from font command are used. For more details see Sec. Text and font specification. [contents]
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. If string contain # symbol then solid markers are used.
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-AI' 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 also for any other plots (for example, plot).
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. If color scheme specification contain symbol '|' then the colors are used as is (without interpolation) else the intermediate colors are found as result of linear interpolation (this is default).
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.
| kw | ![]() |
wk | ![]() |
kHCcw | ![]() |
| kRryw | ![]() |
kGgew | ![]() |
kBbcw | ![]() |
| BbwrR | ![]() |
BbwgG | ![]() |
GgwmM | ![]() |
| bcwyr | ![]() |
QqwcC | ![]() |
CcwyY | ![]() |
| BbcyrR | ![]() |
BbcwyrR | ![]() |
bwr | ![]() |
| BbcyrR| | ![]() |
bcyr | ![]() |
bgr | ![]() |
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]
Text style is specified by the string which may contain several characters of font (ribwou) and/or align (LRC) specifications. The string also may contatin the color id characters wkrgbcymhRGBCYMHW (see Sec. 14) after the symbol :. For example, 'biC:b' sets the bold italic font style with aligning at the center and with blue color.
The font types are: r – roman font, i – italic style, b – bold style. By default roman roman font is used. The align types are: L – align left (default), C – align center, R – align right. Additional font effects are: w – wired, o – overlined, u – underlined. Also a parsing of the LaTeX-like syntax is provided.
The font size can be defined explicitly (if size>0) or relatively the base font size as |size|*fontsize (if size<0). The value size=0 specifies that the string will not be printed. The base font size is measured in internal "MathGL" units.
Parsing of the string to special (TeX-like) commands is switched on by default. There are commands for the font style changing inside the string:\a or \overline – overlined, \b or \textbf – bold, \i or \textit – italic, \r or \textrm – roman (throw any other attributes), \u or \underline – underlined, \w or \wire – wired, \big – bigger size, @ – smaller size. The lower and upper indexes are specified by '_' and '^' symbols. At this the changed font style is applied only on next symbol or symbols in braces {}. The text in braces {} are treated as single symbol that allow one to print the index of index. For example, compare the strings 'sin (x^{2^3})' and 'sin (x^2^3)'. You may also change text color inside string by command #? or by \color? where '?' is symbolic id of the color. For example, words 'Blue' and 'red' will be colored in the string '#b{Blue} and \colorr{red} text' and this string will be printed as "Blue and red text".
TeX parser recognize most of commands for special TeX or AMSTeX symbols (see below), the commands for font style changing (\textrm, \textbf, \textit, \overline, \underline), accents (\hat, \tilde, \dot, \ddot, \acute, \check, \grave, \bar, \breve), roots (\sqrt, \sqrt3, \sqrt4), fractions (\frac) and "stacked" text (\overset, \underset, \stack, \stackr, \stackl). The full list contain approximately 2000 commands. Note that first space symbol after the command is ignored, but second one is printed as normal symbol (space). For example, the following strings produce the same result: '\tilde{a}'; '\tilde a'; '\tilde{}a'.
There are some differences from LaTeX standard parsing:
'x^2^3') are not ignored but printed one-by-one.'x_2^3') are printed one-by-one. Use command \stackl for printing aligned indexes (like, 'x\stackl{3}{2}' or 'x\stackl 32').The Greek letters are recognizable special symbols: α – \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 small part of most common 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]
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]
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:
valvalval val1 val2 val val val val val1 val2 val1 val2 val1 val2 [contents]
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.
[contents]