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

4.3 Axis settings

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


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

4.3.1 Ranges (bounding box)

MGL command: xrange v1 v2
MGL command: yrange v1 v2
MGL command: zrange v1 v2
MGL command: crange v1 v2
Method on mglGraph: void SetRange (char dir, float v1, float v2)
C function: void mgl_set_range_val (HMGL gr, char dir, float v1, float v2)

Sets the range for ‘x’-,‘y’-,‘z’- coordinate or coloring (‘c’). See also ranges.

MGL command: xrange dat [add=off]
MGL command: yrange dat [add=off]
MGL command: zrange dat [add=off]
MGL command: crange dat [add=off]
Method on mglGraph: void SetRange (char dir, const mglData &dat, bool add=false)
C function: void mgl_set_range_dat (HMGL gr, char dir, const HCDT a, int add)

Sets the range for ‘x’-,‘y’-,‘z’- coordinate or coloring (‘c’) as minimal and maximal values of data dat. Parameter add=on shows that the new range will be joined to existed one (not replace it).

MGL command: ranges x1 x2 y1 y2 [z1=0 z2=0]
Method on mglGraph: void SetRanges (mglPoint p1, mglPoint p2)
Method on mglGraph: void SetRanges (float x1, float x2, float y1, float y2, float z1=0, float z2=0)
C function: void mgl_set_ranges (HMGL gr, float x1, float x2, float y1, float y2, float z1, float z2)

Sets the ranges of coordinates. If minimal and maximal values of the coordinate are the same then they are ignored. Also it sets the range for coloring (analogous to crange z1 z2). This is default color range for 2d plots. Initial ranges are [-1, 1].

Method on mglGraph: void SetRanges (const mglData &xx, const mglData &yy)
Method on mglGraph: void SetRanges (const mglData &xx, const mglData &yy, const mglData &zz)
Method on mglGraph: void SetRanges (const mglData &xx, const mglData &yy, const mglData &zz, const mglData &cc)

Sets the ranges of x-,y-,z-coordinates and coloring as minimal and maximal values of data xx, yy, zz, cc correspondingly.

MGL command: origin x0 y0 [z0=nan]
Method on mglGraph: void SetOrigin (mglPoint p0)
Method on mglGraph: void SetOrigin (float x0, float y0, float z0=NAN)
C function: void mgl_set_origin (HMGL gr, float x0, float y0, float z0)

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


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

4.3.2 Curved coordinates

MGL command: axis 'fx' 'fy' ['fz'='' 'fa'='']
Method on mglGraph: void SetFunc (const char *EqX, const char *EqY, const char *EqZ="", const char *EqA="")
C function: void mgl_set_func (HMGL gr, const char *EqX, const char *EqY, const char *EqZ, const char *EqA)

Sets transformation formulas for curvilinear coordinate. Each string should contain mathematical expression for real coordinate depending on internal coordinates ‘x’, ‘y’, ‘z’ and ‘a’ or ‘c’ for colorbar. For example, the cylindrical coordinates are introduced as SetFunc("x*cos(y)", "x*sin(y)", "z");. For removing of formulas the corresponding parameter should be empty or NULL. Using transformation formulas will slightly slowing the program. Parameter EqA set the similar transformation formula for color scheme. See section Textual formulas.

MGL command: axis how
Method on mglGraph: void SetCoor (int how)
C function: void mgl_set_coor (HMGL gr, int how)

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

MGL command: ternary val
Method on mglGraph: void Ternary (int tern)
C function: void mgl_set_ternary (HMGL gr, int tern)

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


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

4.3.3 Ticks

MGL command: adjust ['dir'='xyzc']
Method on mglGraph: void Adjust (const char *dir="xyzc")
C function: void mgl_adjust_ticks (HMGL gr, const char *dir)

Set the ticks step, number of sub-ticks and initial ticks position to be the most human readable for the axis along direction(s) dir. Also set SetTuneTicks(true). Usually you don’t need to call this function except the case of returning to default settings.

MGL command: xtick val [sub=0 org=nan]
MGL command: ytick val [sub=0 org=nan]
MGL command: ztick val [sub=0 org=nan]
MGL command: ctick val [sub=0 org=nan]
Method on mglGraph: void SetTicks (char dir, float d=0, int ns=0, float org=NAN)
C function: void mgl_set_ticks_dir (HMGL gr, char dir, float d, int ns, float org)
C function: void mgl_set_ticks (HMGL gr, int nx, int ny, int nz)

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

MGL command: xtick val1 'lbl1' [val2 'lbl2' ...]
MGL command: ytick val1 'lbl1' [val2 'lbl2' ...]
MGL command: ztick val1 'lbl1' [val2 'lbl2' ...]
Method on mglGraph: void SetTicksVal (char dir, const char *lbl, bool add=false)
Method on mglGraph: void SetTicksVal (char dir, const wchar_t *lbl, bool add=false)
Method on mglGraph: void SetTicksVal (char dir, const mglData &val, const char *lbl, bool add=false)
Method on mglGraph: void SetTicksVal (char dir, const mglData &val, const wchar_t *lbl, bool add=false)
C function: void mgl_set_ticks_str (HMGL gr, char dir, const char *lbl, bool add)
C function: void mgl_set_ticks_wcs (HMGL gr, char dir, const wchar_t *lbl, bool add)
C function: void mgl_set_ticks_val (HMGL gr, char dir, HCDT val, const char *lbl, bool add)
C function: void mgl_set_ticks_valw (HMGL gr, char dir, HCDT val, const wchar_t *lbl, bool add)

Set the manual positions val and its labels lbl for ticks along axis dir. If array val is absent then values equidistantly distributed in interval [Min.x, Max.x] are used. Labels are separated by ‘\n’ symbol. Use SetTicks() to restore automatic ticks.

MGL command: xtick 'templ'
MGL command: ytick 'templ'
MGL command: ztick 'templ'
MGL command: ctick 'templ'
Method on mglGraph: void SetTickTempl (char dir, const char *templ)
Method on mglGraph: void SetTickTempl (char dir, const wchar_t *templ)
C function: void mgl_set_tick_templ (HMGL gr, const char *templ)
C function: void mgl_set_tick_templw (HMGL gr, const wchar_t *templ)

Set template templ for x-,y-,z-axis ticks or colorbar ticks. It may contain TeX symbols also. If templ="" then default template is used (in simplest case it is ‘%.2g’). Setting on template switch off automatic ticks tuning.

MGL command: ticktime 'dir' [dv 'tmpl']
Method on mglGraph: void SetTicksTime (char dir, float val, const char *templ)
C function: void mgl_set_ticks_time (HMGL gr, float val, const char *templ)

Set time labels with step val and template templ for x-,y-,z-axis ticks or colorbar ticks. It may contain TeX symbols also. The format of template templ is the same as described in http://www.manpagez.com/man/3/strftime/. Most common variants are ‘%X’ for national representation of time, ‘%x’ for national representation of date, ‘%Y’ for year with century. If val=0 and/or templ="" then automatic tick step and/or template will be selected.

MGL command: tuneticks val [pos=1.15]
Method on mglGraph: void SetTuneTicks (int tune, float pos=1.15)
C function: void mgl_tune_ticks (HMGL gr, int tune, float pos)

Switch on/off ticks enhancing by factoring common multiplier (for small, like from 0.001 to 0.002, or large, like from 1000 to 2000, coordinate values – enabled if tune&1 is nonzero) or common component (for narrow range, like from 0.999 to 1.000 – enabled if tune&2 is nonzero). Also set the position pos of common multiplier/component on the axis: =0 at minimal axis value, =1 at maximal axis value. Default value is 1.15.

Method on mglGraph: void SetTickRotate (bool val)
C function: void mgl_set_tick_rotate (HMGL gr, bool val)

Enable/disable ticks rotation if there are too many ticks or ticks labels are too long.

Method on mglGraph: void SetTickSkip (bool val)
C function: void mgl_set_tick_skip (HMGL gr, bool val)

Enable/disable ticks skipping if there are too many ticks or ticks labels are too long.

MGL command: ticklen val [stt=1]
Method on mglGraph: void SetTickLen (float val, float stt=1)
C function: void mgl_set_tick_len (HMGL gr, float val, float stt)

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

MGL command: axisstl 'stl' ['tck'='' 'sub'='']
Method on mglGraph: void SetAxisStl (const char *stl="k", const char *tck=0, const char *sub=0)
C function: void mgl_set_axis_stl (HMGL gr, const char *stl, const char *tck, const char *sub)

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


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Autobuild on July 16, 2012 using texi2html 1.82.