Next: , Previous: , Up: MathGL core   [Contents][Index]


5.4 Subplots and rotation

These functions control how and where further plotting will be placed. There is a certain calling order of these functions for the better plot appearance. First one should be subplot, multiplot or inplot for specifying the place. Second one can be title for adding title for the subplot. After it a rotate, shear and aspect. And finally any other plotting functions may be called. Alternatively you can use columnplot, gridplot, stickplot, shearplot or relative inplot for positioning plots in the column (or grid, or stick) one by another without gap between plot axis (bounding boxes). See Subplots, for sample code and picture.

MGL command: subplot nx ny m ['stl'='<>_^' dx=0 dy=0]
Method on mglGraph: void SubPlot (int nx, int ny, int m, const char *stl="<>_^", mreal dx=0, mreal dy=0)
C function: void mgl_subplot (HMGL gr, int nx, int ny, int m, const char *stl)
C function: void mgl_subplot_d (HMGL gr, int nx, int ny, int m, const char *stl, mreal dx, mreal dy)

Puts further plotting in a m-th cell of nx*ny grid of the whole frame area. The position of the cell can be shifted from its default position by relative size dx, dy. This function set off any aspects or rotations. So it should be used first for creating the subplot. Extra space will be reserved for axis/colorbar if stl contain:

From the aesthetical point of view it is not recommended to use this function with different matrices in the same frame. Note, colorbar can be invisible (be out of image borders) if you set empty style ‘’.

MGL command: multiplot nx ny m dx dy ['style'='<>_^' sx sy]
Method on mglGraph: void MultiPlot (int nx, int ny, int m, int dx, int dy, const char *stl="<>_^")
C function: void mgl_multiplot (HMGL gr, int nx, int ny, int m, int dx, int dy, const char *stl)

Puts further plotting in a rectangle of dx*dy cells starting from m-th cell of nx*ny grid of the whole frame area. The position of the rectangular area can be shifted from its default position by relative size sx, sy. This function set off any aspects or rotations. So it should be used first for creating subplot. Extra space will be reserved for axis/colorbar if stl contain:

MGL command: inplot x1 x2 y1 y2 [rel=on]
Method on mglGraph: void InPlot (mreal x1, mreal x2, mreal y1, mreal y2, bool rel=true)
C function: void mgl_inplot (HMGL gr, mreal x1, mreal x2, mreal y1, mreal y2)
C function: void mgl_relplot (HMGL gr, mreal x1, mreal x2, mreal y1, mreal y2)

Puts further plotting in some region of the whole frame surface. This function allows one to create a plot in arbitrary place of the screen. The position is defined by rectangular coordinates [x1, x2]*[y1, y2]. The coordinates x1, x2, y1, y2 are normalized to interval [0, 1]. If parameter rel=true then the relative position to current subplot (or inplot with rel=false) is used. This function set off any aspects or rotations. So it should be used first for creating subplot.

MGL command: columnplot num ind [d=0]
Method on mglGraph: void ColumnPlot (int num, int ind, mreal d=0)
C function: void mgl_columnplot (HMGL gr, int num, int ind)
C function: void mgl_columnplot_d (HMGL gr, int num, int ind, mreal d)

Puts further plotting in ind-th cell of column with num cells. The position is relative to previous subplot (or inplot with rel=false). Parameter d set extra gap between cells.

MGL command: gridplot nx ny ind [d=0]
Method on mglGraph: void GridPlot (int nx, int ny, int ind, mreal d=0)
C function: void mgl_gridplot (HMGL gr, int nx, int ny, int ind)
C function: void mgl_gridplot_d (HMGL gr, int nx, int ny, int ind, mreal d)

Puts further plotting in ind-th cell of nx*ny grid. The position is relative to previous subplot (or inplot with rel=false). Parameter d set extra gap between cells.

MGL command: stickplot num ind tet phi
Method on mglGraph: void StickPlot (int num, int ind, mreal tet, mreal phi)
C function: void mgl_stickplot (HMGL gr, int num, int ind, mreal tet, mreal phi)

Puts further plotting in ind-th cell of stick with num cells. At this, stick is rotated on angles tet, phi. The position is relative to previous subplot (or inplot with rel=false).

MGL command: shearplot num ind sx sy [xd yd]
Method on mglGraph: void ShearPlot (int num, int ind, mreal sx, mreal sy, mreal xd=1, mreal yd=0)
C function: void mgl_shearplot (HMGL gr, int num, int ind, mreal sx, mreal sy, mreal xd, mreal yd)

Puts further plotting in ind-th cell of stick with num cells. At this, cell is sheared on values sx, sy. Stick direction is specified be xd and yd. The position is relative to previous subplot (or inplot with rel=false).

MGL command: title 'title' ['stl'='' size=-2]
Method on mglGraph: void Title (const char *txt, const char *stl="", mreal size=-2)
Method on mglGraph: void Title (const wchar_t *txt, const char *stl="", mreal size=-2)
C function: void mgl_title (HMGL gr, const char *txt, const char *stl, mreal size)
C function: void mgl_titlew (HMGL gr, const wchar_t *txt, const char *stl, mreal size)

Add text title for current subplot/inplot. Parameter stl can contain:

Parameter size set font size. This function set off any aspects or rotations. So it should be used just after creating subplot.

MGL command: rotate tetx tetz [tety=0]
Method on mglGraph: void Rotate (mreal TetX, mreal TetZ, mreal TetY=0)
C function: void mgl_rotate (HMGL gr, mreal TetX, mreal TetZ, mreal TetY)

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

MGL command: rotate tet x y z
Method on mglGraph: void RotateN (mreal Tet, mreal x, mreal y, mreal z)
C function: void mgl_rotate_vector (HMGL gr, mreal Tet, mreal x, mreal y, mreal z)

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

MGL command: shear sx sy
Method on mglGraph: void Shear (mreal sx, mreal sy)
C function: void mgl_shear (HMGL gr, mreal sx, mreal sy)

Shears a further plotting on values sx, sy.

MGL command: aspect ax ay [az=1]
Method on mglGraph: void Aspect (mreal Ax, mreal Ay, mreal Az=1)
C function: void mgl_aspect (HMGL gr, mreal Ax, mreal Ay, mreal Az)

Defines aspect ratio for the plot. The viewable axes will be related one to another as the ratio Ax:Ay:Az. For the best effect it should be used after rotate function. If Ax is NAN then function try to select optimal aspect ratio to keep equal ranges for x-y axis. At this, Ay will specify proportionality factor, or set to use automatic one if Ay=NAN.

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

Push transformation matrix into stack. Later you can restore its current state by Pop() function.

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

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

Method on mglGraph: void SetPlotFactor (mreal val)
C function: void mgl_set_plotfactor (HMGL gr, mreal val)

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

There are 3 functions View(), Zoom() and Perspective() which transform whole image. I.e. they act as secondary transformation matrix. They were introduced for rotating/zooming the whole plot by mouse. It is not recommended to call them for picture drawing.

MGL command: perspective val
Method on mglGraph: void Perspective (mreal a)
C function: void mgl_perspective (HMGL gr, mreal a)

Add (switch on) the perspective to plot. The parameter a = Depth/(Depth+dz) \in [0,1). By default (a=0) the perspective is off.

MGL command: view tetx tetz [tety=0]
Method on mglGraph: void View (mreal TetX, mreal TetZ, mreal TetY=0)
C function: void mgl_view (HMGL gr, mreal TetX, mreal TetZ, mreal TetY)

Rotates a further plotting relative to each axis {x, z, y} consecutively on angles TetX, TetZ, TetY. Rotation is done independently on rotate. Attention! this settings can not be overwritten by DefaultPlotParam(). Use Zoom(0,0,1,1) to return default view.

MGL command: zoom x1 y1 x2 y2
Method on mglGraph (C++, Python): void Zoom (mreal x1, mreal y1, mreal x2, mreal y2)
C function: void mgl_set_zoom (HMGL gr, mreal x1, mreal y1, mreal x2, mreal y2)

The function changes the scale of graphics that correspond to zoom in/out of the picture. After function call the current plot will be cleared and further the picture will contain plotting from its part [x1,x2]*[y1,y2]. Here picture coordinates x1, x2, y1, y2 changes from 0 to 1. Attention! this settings can not be overwritten by any other functions, including DefaultPlotParam(). Use Zoom(0,0,1,1) to return default view.





Next: , Previous: , Up: MathGL core   [Contents][Index]