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


5.10 Legend

These functions draw legend to the graph (useful for 1D plotting). Legend entry is a pair of strings: one for style of the line, another one with description text (with included TeX parsing). The arrays of strings may be used directly or by accumulating first to the internal arrays (by function addlegend) and further plotting it. The position of the legend can be selected automatic or manually (even out of bounding box). Parameters fnt and size specify the font style and size (see Font settings). Option value set the relative width of the line sample and the text indent. If line style string for entry is empty then the corresponding text is printed without indent. Parameter fnt may contain:

See Legend sample, for sample code and picture.

MGL command: legend [pos=3 'fnt'='#']
Method on mglGraph: void Legend (int pos=0x3, const char *fnt="#", const char *opt="")
C function: void mgl_legend (HMGL gr, int pos, const char *fnt, const char *opt)

Draws legend of accumulated legend entries 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). Option value set the space between line samples and text (default is 0.1).

MGL command: legend x y ['fnt'='#']
Method on mglGraph: void Legend (mreal x, mreal y, const char *fnt="#", const char *opt="")
C function: void mgl_legend_pos (HMGL gr, mreal x, mreal y, const char *fnt, const char *opt)

Draws legend of accumulated legend entries by font fnt with size. Position of legend is determined by parameter x, y which supposed to be normalized to interval [0,1]. Option value set the space between line samples and text (default is 0.1).

MGL command: addlegend 'text' 'stl'
Method on mglGraph: void AddLegend (const char *text, const char *style)
Method on mglGraph: void AddLegend (const wchar_t *text, const char *style)
C function: void mgl_add_legend (HMGL gr, const char *text, const char *style)
C function: void mgl_add_legendw (HMGL gr, const wchar_t *text, const char *style)

Adds string text to internal legend accumulator. The style of described line and mark is specified in string style (see Line styles).

MGL command: clearlegend
Method on mglGraph: void ClearLegend ()
C function: void mgl_clear_legend (HMGL gr)

Clears saved legend strings.

MGL command: legendmarks val
Method on mglGraph: void SetLegendMarks (int num)
C function: void mgl_set_legend_marks (HMGL gr, int num)

Set the number of marks in the legend. By default 1 mark is used.





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