5.9 Axis and Colorbar

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

MGL command: axis ['dir'='xyz' 'stl'='']
Method on mglGraph: void Axis (const char *dir="xyz", const char *stl="", const char *opt="")
C function: void mgl_axis (HMGL gr, const char *dir, const char *stl, const char *opt)

Draws axes with ticks (see Axis settings). Parameter dir may contain:

  • xyz’ for drawing axis in corresponding direction;
  • XYZ’ for drawing axis in corresponding direction but with inverted positions of labels;
  • ~’ or ‘_’ for disabling tick labels;
  • U’ for disabling rotation of tick labels;
  • ^’ for inverting default axis origin;
  • !’ for disabling ticks tuning (see tuneticks);
  • AKDTVISO’ for drawing arrow at the end of axis;
  • a’ for forced adjusting of axis ticks;
  • :’ for drawing lines through point (0,0,0);
  • f’ for printing ticks labels in fixed format;
  • E’ for using ‘E’ instead of ‘e’ in ticks labels;
  • F’ for printing ticks labels in LaTeX format;
  • +’ for printing ‘+’ for positive ticks;
  • -’ for printing usual ‘-’ in ticks labels;
  • 0123456789’ for precision at printing ticks labels.

Styles of ticks and axis can be overrided by using stl string. Option value set the manual rotation angle for the ticks. See Axis and ticks, for sample code and picture.

MGL command: colorbar ['sch'='']
Method on mglGraph: void Colorbar (const char *sch="", const char *opt="")
C function: void mgl_colorbar (HMGL gr, const char *sch, const char *opt)

Draws colorbar. Parameter sch may contain:

  • color scheme (see Color scheme);
  • <>^_’ for positioning at left, at right, at top or at bottom correspondingly;
  • I’ for positioning near bounding (by default, is positioned at edges of subplot);
  • A’ for using absolute coordinates;
  • ~’ for disabling tick labels.
  • !’ for disabling ticks tuning (see tuneticks);
  • f’ for printing ticks labels in fixed format;
  • E’ for using ‘E’ instead of ‘e’ in ticks labels;
  • F’ for printing ticks labels in LaTeX format;
  • +’ for printing ‘+’ for positive ticks;
  • -’ for printing usual ‘-’ in ticks labels;
  • 0123456789’ for precision at printing ticks labels.

See Colorbars, for sample code and picture.

MGL command: colorbar vdat ['sch'='']
Method on mglGraph: void Colorbar (const mglDataA &v, const char *sch="", const char *opt="")
C function: void mgl_colorbar_val (HMGL gr, HCDT v, const char *sch, const char *opt)

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

MGL command: colorbar 'sch' x y [w=1 h=1]
Method on mglGraph: void Colorbar (const char *sch, mreal x, mreal y, mreal w=1, mreal h=1, const char *opt="")
C function: void mgl_colorbar_ext (HMGL gr, const char *sch, mreal x, mreal y, mreal w, mreal h, const char *opt)

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

MGL command: colorbar vdat 'sch' x y [w=1 h=1]
Method on mglGraph: void Colorbar (const mglDataA &v, const char *sch, mreal x, mreal y, mreal w=1, mreal h=1, const char *opt="")
C function: void mgl_colorbar_val_ext (HMGL gr, HCDT v, const char *sch, mreal x, mreal y, mreal w, mreal h, const char *opt)

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

MGL command: grid ['dir'='xyz' 'pen'='B']
Method on mglGraph: void Grid (const char *dir="xyz", const char *pen="B", const char *opt="")
C function: void mgl_axis_grid (HMGL gr, const char *dir, const char *pen, const char *opt)

Draws grid lines perpendicular to direction determined by string parameter dir. If dir contain ‘!’ then grid lines will be drawn at coordinates of subticks also. The step of grid lines is the same as tick step for axis. The style of lines is determined by pen parameter (default value is dark blue solid line ‘B-’).

MGL command: box ['stl'='k' ticks=on]
Method on mglGraph: void Box (const char *col="", bool ticks=true)
C function: void mgl_box (HMGL gr)
C function: void mgl_box_str (HMGL gr, const char *col, int ticks)

Draws bounding box outside the plotting volume with color col. If col contain ‘@’ then filled faces are drawn. At this first color is used for faces (default is light yellow), last one for edges. See Bounding box, for sample code and picture.

MGL command: xlabel 'text' [pos=1]
MGL command: ylabel 'text' [pos=1]
MGL command: zlabel 'text' [pos=1]
MGL command: tlabel 'text' [pos=1]
MGL command: clabel 'text' [pos=1]
Method on mglGraph: void Label (char dir, const char *text, mreal pos=1, const char *opt="")
Method on mglGraph: void Label (char dir, const wchar_t *text, mreal pos=1, const char *opt="")
C function: void mgl_label (HMGL gr, char dir, const char *text, mreal pos, const char *opt)
C function: void mgl_labelw (HMGL gr, char dir, const wchar_t *text, mreal pos, const char *opt)

Prints the label text for axis dir=‘x’,‘y’,‘z’,‘t’,‘c’, where ‘t’ is “ternary” axis t=1-x-y; ‘c’ is color axis (should be called after colorbar). 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. Option value set additional shifting of the label. See Text printing.