GR Reference

Defines

DLLEXPORT
GR_TARGET_JUPYTER
GR_TARGET_SOCKET

Typedefs

typedef struct _gr_meta_args_t gr_meta_args_t

Functions

void gr_opengks(void)
void gr_closegks(void)
void gr_inqdspsize(double *, double *, int *, int *)
void gr_openws(int workstation_id, char *connection, int type)

Open a graphical workstation.

Available workstation types:

Type Description
5 Workstation Independent Segment Storage
7, 8 Computer Graphics Metafile (CGM binary, clear text)
41 Windows GDI
51 Mac Quickdraw
61 - 64 PostScript (b/w, color)
101, 102 Portable Document Format (plain, compressed)
210 - 213 X Windows
214 Sun Raster file (RF)
215, 218 Graphics Interchange Format (GIF87, GIF89)
216 Motif User Interface Language (UIL)
320 Windows Bitmap (BMP)
321 JPEG image file
322 Portable Network Graphics file (PNG)
323 Tagged Image File Format (TIFF)
370 Xfig vector graphics file
371 Gtk
380 wxWidgets
381 Qt4
382 Scaleable Vector Graphics (SVG)
390 Windows Metafile
400 Quartz
410 Socket driver
415 0MQ driver
420 OpenGL
430 HTML5 Canvas
Parameters
  • workstation_id: a workstation identifier
  • connection: a connection identifier
  • type: the desired workstation type

void gr_closews(int workstation_id)

Close the specified workstation.

Parameters
  • workstation_id: a workstation identifier

void gr_activatews(int workstation_id)

Activate the specified workstation.

Parameters
  • workstation_id: a workstation identifier

void gr_deactivatews(int workstation_id)

Deactivate the specified workstation.

Parameters
  • workstation_id: a workstation identifier

void gr_clearws(void)
void gr_updatews(void)
void gr_polyline(int n, double *x, double *y)

Draw a polyline using the current line attributes, starting from the first data point and ending at the last data point.

The values for x and y are in world coordinates. The attributes that control the appearance of a polyline are linetype, linewidth and color index.

Parameters
  • n: The number of points
  • x: A pointer to the X coordinates
  • y: A pointer to the Y coordinates

void gr_polymarker(int n, double *x, double *y)

Draw marker symbols centered at the given data points.

The values for x and y are in world coordinates. The attributes that control the appearance of a polymarker are marker type, marker size scale factor and color index.

Parameters
  • n: The number of points
  • x: A pointer to the X coordinates
  • y: A pointer to the Y coordinates

void gr_text(double x, double y, char *string)

Draw a text at position x, y using the current text attributes.

The values for x and y are in normalized device coordinates. The attributes that control the appearance of text are text font and precision, character expansion factor, character spacing, text color index, character height, character up vector, text path and text alignment.

Parameters
  • x: The X coordinate of the starting position of the text string
  • y: The Y coordinate of the starting position of the text string
  • string: The text to be drawn

void gr_inqtext(double, double, char *, double *, double *)
void gr_fillarea(int n, double *x, double *y)

Allows you to specify a polygonal shape of an area to be filled.

The attributes that control the appearance of fill areas are fill area interior style, fill area style index and fill area color index.

Parameters
  • n: The number of points
  • x: A pointer to the X coordinates
  • y: A pointer to the Y coordinates

void gr_cellarray(double xmin, double xmax, double ymin, double ymax, int dimx, int dimy, int scol, int srow, int ncol, int nrow, int *color)

Display rasterlike images in a device-independent manner. The cell array function partitions a rectangle given by two corner points into DIMX X DIMY cells, each of them colored individually by the corresponding color index of the given cell array.

The values for xmin, xmax, ymin and ymax are in world coordinates.

Parameters
  • xmin: X coordinate of the lower left point of the rectangle
  • ymin: Y coordinate of the lower left point of the rectangle
  • xmax: X coordinate of the upper right point of the rectangle
  • ymax: Y coordinate of the upper right point of the rectangle
  • dimx: X dimension of the color index array
  • dimy: Y dimension of the color index array
  • scol: number of leading columns in the color index array
  • srow: number of leading rows in the color index array
  • ncol: total number of columns in the color index array
  • nrow: total number of rows in the color index array
  • color: color index array

void gr_gdp(int, double *, double *, int, int, int *)
void gr_spline(int n, double *px, double *py, int m, int method)

Generate a cubic spline-fit, starting from the first data point and ending at the last data point.

The values for x and y are in world coordinates. The attributes that control the appearance of a spline-fit are linetype, linewidth and color index.

Parameters
  • n: The number of points
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • m: The number of points in the polygon to be drawn (m > n)
  • method: The smoothing method

If method is > 0, then a generalized cross-validated smoothing spline is calculated. If method is 0, then an interpolating natural cubic spline is calculated. If method is < -1, then a cubic B-spline is calculated.

void gr_gridit(int, double *, double *, double *, int, int, double *, double *, double *)
void gr_setlinetype(int type)

Specify the line style for polylines.

The available line types are:

LINETYPE_SOLID 1 Solid line
LINETYPE_DASHED 2 Dashed line
LINETYPE_DOTTED 3 Dotted line
LINETYPE_DASHED_DOTTED 4 Dashed-dotted line
LINETYPE_DASH_2_DOT -1 Sequence of one dash followed by two dots
LINETYPE_DASH_3_DOT -2 Sequence of one dash followed by three dots
LINETYPE_LONG_DASH -3 Sequence of long dashes
LINETYPE_LONG_SHORT_DASH -4 Sequence of a long dash followed by a short dash
LINETYPE_SPACED_DASH -5 Sequence of dashes double spaced
LINETYPE_SPACED_DOT -6 Sequence of dots double spaced
LINETYPE_DOUBLE_DOT -7 Sequence of pairs of dots
LINETYPE_TRIPLE_DOT -8 Sequence of groups of three dots
Parameters
  • type: The polyline line style

void gr_inqlinetype(int *)
void gr_setlinewidth(double width)

Define the line width of subsequent polyline output primitives.

The line width is calculated as the nominal line width generated on the workstation multiplied by the line width scale factor. This value is mapped by the workstation to the nearest available line width. The default line width is 1.0, or 1 times the line width generated on the graphics device.

Parameters
  • width: The polyline line width scale factor

void gr_inqlinewidth(double *)
void gr_setlinecolorind(int color)

Define the color of subsequent polyline output primitives.

Parameters
  • color: The polyline color index (COLOR < 1256)

void gr_inqlinecolorind(int *)
void gr_setmarkertype(int type)

Specifiy the marker type for polymarkers.

The available marker types are:

MARKERTYPE_DOT 1 Smallest displayable dot
MARKERTYPE_PLUS 2 Plus sign
MARKERTYPE_ASTERISK 3 Asterisk
MARKERTYPE_CIRCLE 4 Hollow circle
MARKERTYPE_DIAGONAL_CROSS 5 Diagonal cross
MARKERTYPE_SOLID_CIRCLE -1 Filled circle
MARKERTYPE_TRIANGLE_UP -2 Hollow triangle pointing upward
MARKERTYPE_SOLID_TRI_UP -3 Filled triangle pointing upward
MARKERTYPE_TRIANGLE_DOWN -4 Hollow triangle pointing downward
MARKERTYPE_SOLID_TRI_DOWN -5 Filled triangle pointing downward
MARKERTYPE_SQUARE -6 Hollow square
MARKERTYPE_SOLID_SQUARE -7 Filled square
MARKERTYPE_BOWTIE -8 Hollow bowtie
MARKERTYPE_SOLID_BOWTIE -9 Filled bowtie
MARKERTYPE_HGLASS -10 Hollow hourglass
MARKERTYPE_SOLID_HGLASS -11 Filled hourglass
MARKERTYPE_DIAMOND -12 Hollow diamond
MARKERTYPE_SOLID_DIAMOND -13 Filled Diamond
MARKERTYPE_STAR -14 Hollow star
MARKERTYPE_SOLID_STAR -15 Filled Star
MARKERTYPE_TRI_UP_DOWN -16 Hollow triangles pointing up and down overlaid
MARKERTYPE_SOLID_TRI_RIGHT -17 Filled triangle point right
MARKERTYPE_SOLID_TRI_LEFT -18 Filled triangle pointing left
MARKERTYPE_HOLLOW PLUS -19 Hollow plus sign
MARKERTYPE_SOLID PLUS -20 Solid plus sign
MARKERTYPE_PENTAGON -21 Pentagon
MARKERTYPE_HEXAGON -22 Hexagon
MARKERTYPE_HEPTAGON -23 Heptagon
MARKERTYPE_OCTAGON -24 Octagon
MARKERTYPE_STAR_4 -25 4-pointed star
MARKERTYPE_STAR_5 -26 5-pointed star (pentagram)
MARKERTYPE_STAR_6 -27 6-pointed star (hexagram)
MARKERTYPE_STAR_7 -28 7-pointed star (heptagram)
MARKERTYPE_STAR_8 -29 8-pointed star (octagram)
MARKERTYPE_VLINE -30 verical line
MARKERTYPE_HLINE -31 horizontal line
MARKERTYPE_OMARK -32 o-mark
Parameters
  • type: The polymarker marker type

Polymarkers appear centered over their specified coordinates.

void gr_inqmarkertype(int *)
void gr_setmarkersize(double size)

Specify the marker size for polymarkers.

The polymarker size is calculated as the nominal size generated on the graphics device multiplied by the marker size scale factor.

Parameters
  • size: Scale factor applied to the nominal marker size

void gr_setmarkercolorind(int color)

Define the color of subsequent polymarker output primitives.

Parameters
  • color: The polymarker color index (COLOR < 1256)

void gr_inqmarkercolorind(int *)
void gr_settextfontprec(int font, int precision)

Specify the text font and precision for subsequent text output primitives.

The available text fonts are:

FONT_TIMES_ROMAN 101
FONT_TIMES_ITALIC 102
FONT_TIMES_BOLD 103
FONT_TIMES_BOLDITALIC 104
FONT_HELVETICA 105
FONT_HELVETICA_OBLIQUE 106
FONT_HELVETICA_BOLD 107
FONT_HELVETICA_BOLDOBLIQUE 108
FONT_COURIER 109
FONT_COURIER_OBLIQUE 110
FONT_COURIER_BOLD 111
FONT_COURIER_BOLDOBLIQUE 112
FONT_SYMBOL 113
FONT_BOOKMAN_LIGHT 114
FONT_BOOKMAN_LIGHTITALIC 115
FONT_BOOKMAN_DEMI 116
FONT_BOOKMAN_DEMIITALIC 117
FONT_NEWCENTURYSCHLBK_ROMAN 118
FONT_NEWCENTURYSCHLBK_ITALIC 119
FONT_NEWCENTURYSCHLBK_BOLD 120
FONT_NEWCENTURYSCHLBK_BOLDITALIC 121
FONT_AVANTGARDE_BOOK 122
FONT_AVANTGARDE_BOOKOBLIQUE 123
FONT_AVANTGARDE_DEMI 124
FONT_AVANTGARDE_DEMIOBLIQUE 125
FONT_PALATINO_ROMAN 126
FONT_PALATINO_ITALIC 127
FONT_PALATINO_BOLD 128
FONT_PALATINO_BOLDITALIC 129
FONT_ZAPFCHANCERY_MEDIUMITALIC 130
FONT_ZAPFDINGBATS 131

The available text precisions are:

TEXT_PRECISION_STRING 0 String precision (higher quality)
TEXT_PRECISION_CHAR 1 Character precision (medium quality)
TEXT_PRECISION_STROKE 2 Stroke precision (lower quality)
Parameters
  • font: Text font (see tables)
  • precision: Text precision (see table below)

The appearance of a font depends on the text precision value specified. STRING, CHARACTER or STROKE precision allows for a greater or lesser realization of the text primitives, for efficiency. STRING is the default precision for GR and produces the highest quality output.

void gr_setcharexpan(double factor)

Set the current character expansion factor (width to height ratio).

This function defines the width of subsequent text output primitives. The expansion factor alters the width of the generated characters, but not their height. The default text expansion factor is 1, or one times the normal width-to-height ratio of the text.

Parameters
  • factor: Text expansion factor applied to the nominal text width-to-height ratio

void gr_setcharspace(double)
void gr_settextcolorind(int color)

Set the current text color index.

This function defines the color of subsequent text output primitives. GR uses the default foreground color (black=1) for the default text color index.

Parameters
  • color: The text color index (COLOR < 1256)

void gr_setcharheight(double height)

Set the current character height.

This function defines the height of subsequent text output primitives. Text height is defined as a percentage of the default window. GR uses the default text height of 0.027 (2.7% of the height of the default window).

Parameters
  • height: Text height value

void gr_setcharup(double ux, double uy)

Set the current character text angle up vector.

This function defines the vertical rotation of subsequent text output primitives. The text up vector is initially set to (0, 1), horizontal to the baseline.

Parameters
  • ux: X coordinate of the text up vector
  • uy: Y coordinate of the text up vector

void gr_settextpath(int path)

Define the current direction in which subsequent text will be drawn.

TEXT_PATH_RIGHT 0 left-to-right
TEXT_PATH_LEFT 1 right-to-left
TEXT_PATH_UP 2 downside-up
TEXT_PATH_DOWN 3 upside-down
Parameters
  • path: Text path (see table)

void gr_settextalign(int horizontal, int vertical)

Set the current horizontal and vertical alignment for text.

TEXT_HALIGN_NORMAL 0  
TEXT_HALIGN_LEFT 1 Left justify
TEXT_HALIGN_CENTER 2 Center justify
TEXT_HALIGN_RIGHT 3 Right justify
TEXT_VALIGN_NORMAL 0  
TEXT_VALIGN_TOP 1 Align with the top of the characters
TEXT_VALIGN_CAP 2 Aligned with the cap of the characters
TEXT_VALIGN_HALF 3 Aligned with the half line of the characters
TEXT_VALIGN_BASE 4 Aligned with the base line of the characters
TEXT_VALIGN_BOTTOM 5 Aligned with the bottom line of the characters
Parameters
  • horizontal: Horizontal text alignment (see the table)
  • vertical: Vertical text alignment (see the table)

This function specifies how the characters in a text primitive will be aligned in horizontal and vertical space. The default text alignment indicates horizontal left alignment and vertical baseline alignment.

void gr_setfillintstyle(int style)

Set the fill area interior style to be used for fill areas.

HOLLOW 0 No filling. Just draw the bounding polyline
SOLID 1 Fill the interior of the polygon using the fill color index
PATTERN 2 Fill the interior of the polygon using the style index as a pattern index
HATCH 3 Fill the interior of the polygon using the style index as a cross-hatched style
Parameters
  • style: The style of fill to be used

This function defines the interior style for subsequent fill area output primitives. The default interior style is HOLLOW.

void gr_setfillstyle(int index)

Set the fill area interior style to be used for fill areas.

This function specifies an index when PATTERN fill or HATCH fill is requested by the gr_setfillintstyle function. If the interior style is set to PATTERN, the fill style index points to a device-independent pattern table. If interior style is set to HATCH the fill style index indicates different hatch styles. If HOLLOW or SOLID is specified for the interior style, the fill style index is unused.

Parameters
  • index: The fill style index to be used

void gr_setfillcolorind(int color)

Sets the current fill area color index.

This function defines the color of subsequent fill area output primitives. GR uses the default foreground color (black=1) for the default fill area color index.

Parameters
  • color: The fill area color index (COLOR < 1256)

void gr_setcolorrep(int index, double red, double green, double blue)

Redefine an existing color index representation by specifying an RGB color triplet.

Parameters
  • index: Color index in the range 0 to 1256
  • red: Red intensity in the range 0.0 to 1.0
  • green: Green intensity in the range 0.0 to 1.0
  • blue: Blue intensity in the range 0.0 to 1.0

void gr_setwindow(double xmin, double xmax, double ymin, double ymax)

Establishes a window, or rectangular subspace, of world coordinates to be plotted. If you desire log scaling or mirror-imaging of axes, use the gr_setscale function.

This function defines the rectangular portion of the World Coordinate space (WC) to be associated with the specified normalization transformation. The WC window and the Normalized Device Coordinates (NDC) viewport define the normalization transformation through which all output primitives are mapped. The WC window is mapped onto the rectangular NDC viewport which is, in turn, mapped onto the display surface of the open and active workstation, in device coordinates. By default, GR uses the range [0,1] x [0,1], in world coordinates, as the normalization transformation window.

Parameters
  • xmin: The left horizontal coordinate of the window (xmin < xmax).
  • xmax: The right horizontal coordinate of the window (xmin < xmax).
  • ymin: The bottom vertical coordinate of the window (ymin < ymax).
  • ymax: The top vertical coordinate of the window (ymin < ymax).

void gr_inqwindow(double *, double *, double *, double *)
void gr_setviewport(double xmin, double xmax, double ymin, double ymax)

Establishes a rectangular subspace of normalized device coordinates.

This function defines the rectangular portion of the Normalized Device Coordinate (NDC) space to be associated with the specified normalization transformation. The NDC viewport and World Coordinate (WC) window define the normalization transformation through which all output primitives pass. The WC window is mapped onto the rectangular NDC viewport which is, in turn, mapped onto the display surface of the open and active workstation, in device coordinates.

Parameters
  • xmin: The left horizontal coordinate of the viewport (0 <= xmin < xmax).
  • xmax: The right horizontal coordinate of the viewport (xmin < xmax <= 1).
  • ymin: The bottom vertical coordinate of the viewport (0 <= ymin < ymax).
  • ymax: The top vertical coordinate of the viewport (ymin < ymax <= 1).

void gr_inqviewport(double *, double *, double *, double *)
void gr_selntran(int transform)

Select a predefined transformation from world coordinates to normalized device coordinates.

0 Selects the identity transformation in which both the window and viewport have the range of 0 to 1
>= 1 Selects a normalization transformation as defined by setwindow and setviewport
Parameters
  • transform: A normalization transformation number.

void gr_setclip(int indicator)

Set the clipping indicator.

0 Clipping is off. Data outside of the window will be drawn.
1 Clipping is on. Data outside of the window will not be drawn.
Parameters
  • indicator: An indicator specifying whether clipping is on or off.

This function enables or disables clipping of the image drawn in the current window. Clipping is defined as the removal of those portions of the graph that lie outside of the defined viewport. If clipping is on, GR does not draw generated output primitives past the viewport boundaries. If clipping is off, primitives may exceed the viewport boundaries, and they will be drawn to the edge of the workstation window. By default, clipping is on.

void gr_setwswindow(double xmin, double xmax, double ymin, double ymax)

Set the area of the NDC viewport that is to be drawn in the workstation window.

This function defines the rectangular area of the Normalized Device Coordinate space to be output to the device. By default, the workstation transformation will map the range [0,1] x [0,1] in NDC onto the largest square on the workstation’s display surface. The aspect ratio of the workstation window is maintained at 1 to 1.

Parameters
  • xmin: The left horizontal coordinate of the workstation window (0 <= xmin < xmax).
  • xmax: The right horizontal coordinate of the workstation window (xmin < xmax <= 1).
  • ymin: The bottom vertical coordinate of the workstation window (0 <= ymin < ymax).
  • ymax: The top vertical coordinate of the workstation window (ymin < ymax <= 1).

void gr_setwsviewport(double xmin, double xmax, double ymin, double ymax)

Define the size of the workstation graphics window in meters.

This function places a workstation window on the display of the specified size in meters. This command allows the workstation window to be accurately sized for a display or hardcopy device, and is often useful for sizing graphs for desktop publishing applications.

Parameters
  • xmin: The left horizontal coordinate of the workstation window.
  • xmax: The right horizontal coordinate of the workstation window.
  • ymin: The bottom vertical coordinate of the workstation window.
  • ymax: The top vertical coordinate of the workstation window.

void gr_createseg(int)
void gr_copysegws(int)
void gr_redrawsegws(void)
void gr_setsegtran(int, double, double, double, double, double, double, double)
void gr_closeseg(void)
void gr_emergencyclosegks(void)
void gr_updategks(void)
int gr_setspace(double zmin, double zmax, int rotation, int tilt)

Set the abstract Z-space used for mapping three-dimensional output primitives into the current world coordinate space.

This function establishes the limits of an abstract Z-axis and defines the angles for rotation and for the viewing angle (tilt) of a simulated three-dimensional graph, used for mapping corresponding output primitives into the current window. These settings are used for all subsequent three-dimensional output primitives until other values are specified. Angles of rotation and viewing angle must be specified between 0° and 90°.

Parameters
  • zmin: Minimum value for the Z-axis.
  • zmax: Maximum value for the Z-axis.
  • rotation: Angle for the rotation of the X axis, in degrees.
  • tilt: Viewing angle of the Z axis, in degrees.

void gr_inqspace(double *, double *, int *, int *)
int gr_setscale(int options)

Set the type of transformation to be used for subsequent GR output primitives.

OPTION_X_LOG Logarithmic X-axis
OPTION_Y_LOG Logarithmic Y-axis
OPTION_Z_LOG Logarithmic Z-axis
OPTION_FLIP_X Flip X-axis
OPTION_FLIP_Y Flip Y-axis
OPTION_FLIP_Z Flip Z-axis
Parameters
  • options: Scale specification (see table)

This function defines the current transformation according to the given scale specification which may be or’ed together using any of the above options. GR uses these options for all subsequent output primitives until another value is provided. The scale options are used to transform points from an abstract logarithmic or semi-logarithmic coordinate system, which may be flipped along each axis, into the world coordinate system.

Note
When applying a logarithmic transformation to a specific axis, the system assumes that the axes limits are greater than zero.

void gr_inqscale(int *)
int gr_textext(double x, double y, char *string)

Draw a text at position x, y using the current text attributes. Strings can be defined to create basic mathematical expressions and Greek letters.

The values for X and Y are in normalized device coordinates. The attributes that control the appearance of text are text font and precision, character expansion factor, character spacing, text color index, character height, character up vector, text path and text alignment.

Parameters
  • x: The X coordinate of starting position of the text string
  • y: The Y coordinate of starting position of the text string
  • string: The text to be drawn

The character string is interpreted to be a simple mathematical formula. The following notations apply:

Subscripts and superscripts: These are indicated by carets (‘^’) and underscores (‘_’). If the sub/superscript contains more than one character, it must be enclosed in curly braces (‘{}’).

Fractions are typeset with A ‘/’ B, where A stands for the numerator and B for the denominator.

To include a Greek letter you must specify the corresponding keyword after a backslash (‘') character. The text translator produces uppercase or lowercase Greek letters depending on the case of the keyword.

Letter Keyword
\(A\) \(\alpha\) alpha
\(B\) \(\beta\) beta
\(\Gamma\) \(\gamma\) gamma
\(\Delta\) \(\delta\) delta
\(E\) \(\epsilon\) epsilon
\(Z\) \(\zeta\) zeta
\(H\) \(\eta\) eta
\(\Theta\) \(\theta\) theta
\(I\) \(\iota\) iota
\(K\) \(\kappa\) kappa
\(\Lambda\) \(\lambda\) lambda
\(M\) \(\mu\) mu
\(N\) \(\nu\) v
\(\Xi\) \(\xi\) xi
\(O\) \(o\) omicron
\(\Pi\) \(\pi\) pi
\(P\) \(\rho\) rho
\(\Sigma\) \(\sigma\) sigma
\(T\) \(\tau\) tau
\(\Upsilon\) \(\upsilon\) upsilon
\(\Phi\) \(\phi\) phi
\(X\) \(\chi\) chi
\(\Psi\) \(\psi\) psi
\(\Omega\) \(\omega\) omega

For more sophisticated mathematical formulas, you should use the gr_mathtex function.

Note: ‘v’ is a replacement for ‘nu’ which would conflict with ‘ ‘ (newline)

void gr_inqtextext(double, double, char *, double *, double *)
void gr_axes(double x_tick, double y_tick, double x_org, double y_org, int major_x, int major_y, double tick_size)

Draw X and Y coordinate axes with linearly and/or logarithmically spaced tick marks.

Tick marks are positioned along each axis so that major tick marks fall on the axes origin (whether visible or not). Major tick marks are labeled with the corresponding data values. Axes are drawn according to the scale of the window. Axes and tick marks are drawn using solid lines; line color and width can be modified using the gr_setlinetype and gr_setlinewidth functions. Axes are drawn according to the linear or logarithmic transformation established by the gr_setscale function.

Parameters
  • x_tick: The interval between minor tick marks on the X axis.
  • y_tick: The interval between minor tick marks on the Y axis.
  • x_org: The world coordinate of the origin (point of intersection) of the X axis.
  • y_org: The world coordinate of the origin (point of intersection) of the Y axis.
  • major_x: Unitless integer value specifying the number of minor tick intervals between major tick marks on the X axis. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.
  • major_y: Unitless integer value specifying the number of minor tick intervals between major tick marks on the Y axis. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.
  • tick_size: The length of minor tick marks specified in a normalized device coordinate unit. Major tick marks are twice as long as minor tick marks. A negative value reverses the tick marks on the axes from inward facing to outward facing (or vice versa).

void gr_axeslbl(double, double, double, double, int, int, double, void (*)(double, double, const char *, double), void (*)(double, double, const char *, double))
void gr_grid(double x_tick, double y_tick, double x_org, double y_org, int major_x, int major_y)

Draw a linear and/or logarithmic grid.

Major grid lines correspond to the axes origin and major tick marks whether visible or not. Minor grid lines are drawn at points equal to minor tick marks. Major grid lines are drawn using black lines and minor grid lines are drawn using gray lines.

Parameters
  • x_tick: The length in world coordinates of the interval between minor grid lines in X direction.
  • y_tick: The length in world coordinates of the interval between minor grid lines in Y direction.
  • x_org: The world coordinate of the origin (point of intersection) of the X axis.
  • y_org: The world coordinate of the origin (point of intersection) of the Y axis.
  • major_x: Unitless integer value specifying the number of minor grid lines between major grid lines on the X axis. Values of 0 or 1 imply no grid lines.
  • major_y: Unitless integer value specifying the number of minor grid lines between major grid lines on the Y axis. Values of 0 or 1 imply no grid lines.

void gr_grid3d(double x_tick, double y_tick, double z_tick, double x_org, double y_org, double z_org, int major_x, int major_y, int major_z)

Draw a linear and/or logarithmic grid.

Major grid lines correspond to the axes origin and major tick marks whether visible or not. Minor grid lines are drawn at points equal to minor tick marks. Major grid lines are drawn using black lines and minor grid lines are drawn using gray lines.

Parameters
  • x_tick: The length in world coordinates of the interval between minor grid lines in X direction.
  • y_tick: The length in world coordinates of the interval between minor grid lines in Y direction.
  • z_tick: The length in world coordinates of the interval between minor grid lines in Z direction.
  • x_org: The world coordinate of the origin (point of intersection) of the X axis.
  • y_org: The world coordinate of the origin (point of intersection) of the Y axis.
  • z_org: The world coordinate of the origin (point of intersection) of the Z axis.
  • major_x: Unitless integer value specifying the number of minor grid lines between major grid lines on the X axis. Values of 0 or 1 imply no grid lines.
  • major_y: Unitless integer value specifying the number of minor grid lines between major grid lines on the Y axis. Values of 0 or 1 imply no grid lines.
  • major_z: Unitless integer value specifying the number of minor grid lines between major grid lines on the Z axis. Values of 0 or 1 imply no grid lines.

void gr_verrorbars(int n, double *px, double *py, double *e1, double *e2)

Draw a standard vertical error bar graph.

Parameters
  • n: The number of points
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • e1: A pointer to the absolute values of the lower error bar data
  • e2: A pointer to the absolute values of the upper error bar data

void gr_herrorbars(int n, double *px, double *py, double *e1, double *e2)

Draw a standard horizontal error bar graph.

Parameters
  • n: The number of points
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • e1: A pointer to the absolute values of the lower error bar data
  • e2: A pointer to the absolute values of the upper error bar data

void gr_polyline3d(int n, double *px, double *py, double *pz)

Draw a 3D curve using the current line attributes, starting from the first data point and ending at the last data point.

The values for x, y and z are in world coordinates. The attributes that control the appearance of a polyline are linetype, linewidth and color index.

Parameters
  • n: The number of points
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • pz: A pointer to the Z coordinates

void gr_polymarker3d(int n, double *px, double *py, double *pz)

Draw marker symbols centered at the given 3D data points.

The values for x, y and z are in world coordinates. The attributes that control the appearance of a polymarker are marker type, marker size scale factor and color index.

Parameters
  • n: The number of points
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • pz: A pointer to the Z coordinates

void gr_axes3d(double x_tick, double y_tick, double z_tick, double x_org, double y_org, double z_org, int major_x, int major_y, int major_z, double tick_size)

Draw X, Y and Z coordinate axes with linearly and/or logarithmically spaced tick marks.

Tick marks are positioned along each axis so that major tick marks fall on the axes origin (whether visible or not). Major tick marks are labeled with the corresponding data values. Axes are drawn according to the scale of the window. Axes and tick marks are drawn using solid lines; line color and width can be modified using the gr_setlinetype and gr_setlinewidth functions. Axes are drawn according to the linear or logarithmic transformation established by the gr_setscale function.

Parameters
  • x_tick: The length in world coordinates of the interval between minor grid lines in X direction.
  • y_tick: The length in world coordinates of the interval between minor grid lines in Y direction.
  • z_tick: The length in world coordinates of the interval between minor grid lines in Z direction.
  • x_org: The world coordinate of the origin (point of intersection) of the X axis.
  • y_org: The world coordinate of the origin (point of intersection) of the Y axis.
  • z_org: The world coordinate of the origin (point of intersection) of the Z axis.
  • major_x: Unitless integer value specifying the number of minor grid lines between major grid lines on the X axis. Values of 0 or 1 imply no grid lines.
  • major_y: Unitless integer value specifying the number of minor grid lines between major grid lines on the Y axis. Values of 0 or 1 imply no grid lines.
  • major_z: Unitless integer value specifying the number of minor grid lines between major grid lines on the Z axis. Values of 0 or 1 imply no grid lines.
  • tick_size: The length of minor tick marks specified in a normalized device coordinate unit. Major tick marks are twice as long as minor tick marks. A negative value reverses the tick marks on the axes from inward facing to outward facing (or vice versa).

void gr_titles3d(char *x_title, char *y_title, char *z_title)

Display axis titles just outside of their respective axes.

Parameters
  • x_title: The text to be displayed on the X axis
  • y_title: The text to be displayed on the Y axis
  • z_title: The text to be displayed on the Z axis

void gr_surface(int nx, int ny, double *px, double *py, double *pz, int option)

Draw a three-dimensional surface plot for the given data points.

x and y define a grid. z is a singly dimensioned array containing at least nx * ny data points. z describes the surface height at each point on the grid. Data is ordered as shown in the following table:

Parameters
  • nx: The number of points along the X axis
  • ny: The number of points along the Y axis
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • pz: A pointer to the Z coordinates
  • option: Surface display option (see table)

LINES 0 Use X Y polylines to denote the surface
MESH 1 Use a wire grid to denote the surface
FILLED_MESH 2 Applies an opaque grid to the surface
Z_SHADED_MESH 3 Applies Z-value shading to the surface
COLORED_MESH 4 Applies a colored grid to the surface
CELL_ARRAY 5 Applies a grid of individually-colored cells to the surface
SHADED_MESH 6 Applies light source shading to the 3-D surface

void gr_contour(int nx, int ny, int nh, double *px, double *py, double *h, double *pz, int major_h)

Draw contours of a three-dimensional data set whose values are specified over a rectangular mesh. Contour lines may optionally be labeled.

Parameters
  • nx: The number of points along the X axis
  • ny: The number of points along the Y axis
  • nh: The number of height values
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • h: A pointer to the height values
  • pz: A pointer to the Z coordinates
  • major_h: Directs GR to label contour lines. For example, a value of 3 would label every third line. A value of 1 will label every line. A value of 0 produces no labels. To produce colored contour lines, add an offset of 1000 to major_h

void gr_tricontour(int npoints, double *x, double *y, double *z, int nlevels, double *levels)

Draw a contour plot for the given triangle mesh.

Parameters
  • npoints: The number of points
  • x: A pointer to the X coordinates
  • y: A pointer to the Y coordinates
  • z: A pointer to the Z coordinates
  • nlevels: The number of contour levels
  • levels: A pointer to the contour levels

int gr_hexbin(int, double *, double *, int)
void gr_setcolormap(int)
void gr_inqcolormap(int *)
void gr_colorbar(void)
void gr_inqcolor(int, int *)
int gr_inqcolorfromrgb(double, double, double)
void gr_hsvtorgb(double h, double s, double v, double *r, double *g, double *b)
double gr_tick(double, double)
int gr_validaterange(double, double)
void gr_adjustlimits(double *, double *)
void gr_adjustrange(double *, double *)
void gr_beginprint(char *pathname)

Open and activate a print device.

This function opens an additional graphics output device. The device type is obtained from the given file extension. The following file types are supported:

Parameters
  • pathname: Filename for the print device.

The following file types are supported:

.ps, .eps PostScript
.pdf Portable Document Format
.bmp Windows Bitmap (BMP)
.jpeg, .jpg JPEG image file
.png Portable Network Graphics file (PNG)
.tiff, .tif Tagged Image File Format (TIFF)
.fig Xfig vector graphics file
.svg Scalable Vector Graphics
.wmf Windows Metafile

void gr_beginprintext(char *pathname, char *mode, char *format, char *orientation)

Open and activate a print device with the given layout attributes.

The available formats are:

A4 0.210 x 0.297
B5 0.176 x 0.250
Letter 0.216 x 0.279
Legal 0.216 x 0.356
Executive 0.191 x 0.254
A0 0.841 x 1.189
A1 0.594 x 0.841
A2 0.420 x 0.594
A3 0.297 x 0.420
A5 0.148 x 0.210
A6 0.105 x 0.148
A7 0.074 x 0.105
A8 0.052 x 0.074
A9 0.037 x 0.052
B0 1.000 x 1.414
B1 0.500 x 0.707
B10 0.031 x 0.044
B2 0.500 x 0.707
B3 0.353 x 0.500
B4 0.250 x 0.353
B6 0.125 x 0.176
B7 0.088 x 0.125
B8 0.062 x 0.088
B9 0.044 x 0.062
C5E 0.163 x 0.229
Comm10E 0.105 x 0.241
DLE 0.110 x 0.220
Folio 0.210 x 0.330
Ledger 0.432 x 0.279
Tabloid 0.279 x 0.432
Parameters
  • pathname: Filename for the print device.
  • mode: Output mode (Color, GrayScale)
  • format: Output format (see table)
  • orientation: Page orientation (Landscape, Portait)

void gr_endprint(void)
void gr_ndctowc(double *, double *)
void gr_wctondc(double *, double *)
void gr_wc3towc(double *, double *, double *)
void gr_drawrect(double xmin, double xmax, double ymin, double ymax)

Draw a rectangle using the current line attributes.

Parameters
  • xmin: Left edge of the rectangle
  • xmax: Right edge of the rectangle
  • ymin: Bottom edge of the rectangle
  • ymax: Upper edge of the rectangle

void gr_fillrect(double xmin, double xmax, double ymin, double ymax)

Draw a filled rectangle using the current fill attributes.

Parameters
  • xmin: Left edge of the rectangle
  • xmax: Right edge of the rectangle
  • ymin: Bottom edge of the rectangle
  • ymax: Upper edge of the rectangle

void gr_drawarc(double xmin, double xmax, double ymin, double ymax, int a1, int a2)

Draw a circular or elliptical arc covering the specified rectangle.

The resulting arc begins at a1 and ends at a2 degrees. Angles are interpreted such that 0 degrees is at the 3 o’clock position. The center of the arc is the center of the given rectangle.

Parameters
  • xmin: Left edge of the rectangle
  • xmax: Right edge of the rectangle
  • ymin: Bottom edge of the rectangle
  • ymax: Upper edge of the rectangle
  • a1: The start angle
  • a2: The end angle

void gr_fillarc(double xmin, double xmax, double ymin, double ymax, int a1, int a2)

Fill a circular or elliptical arc covering the specified rectangle.

The resulting arc begins at a1 and ends at a2 degrees. Angles are interpreted such that 0 degrees is at the 3 o’clock position. The center of the arc is the center of the given rectangle.

Parameters
  • xmin: Left edge of the rectangle
  • xmax: Right edge of the rectangle
  • ymin: Bottom edge of the rectangle
  • ymax: Upper edge of the rectangle
  • a1: The start angle
  • a2: The end angle

void gr_drawpath(int n, vertex_t *vertices, unsigned char *codes, int fill)

Draw simple and compound outlines consisting of line segments and bezier curves.

The following path codes are recognized:

STOP end the entire path
MOVETO move to the given vertex
LINETO draw a line from the current position to the given vertex
CURVE3 draw a quadratic Bézier curve
CURVE4 draw a cubic Bézier curve
CLOSEPOLY draw a line segment to the start point of the current path
Parameters
  • n: The number of vertices
  • vertices: A pointer to the vertices
  • codes: A pointer to the path codes
  • fill: A flag indication whether resulting path is to be filled or not

void gr_setarrowstyle(int style)

Set the arrow style to be used for subsequent arrow commands.

This function defines the arrow style for subsequent arrow primitives. The default arrow style is 1.

Parameters
  • style: The arrow style to be used

1 simple, single-ended
2 simple, single-ended, acute head
3 hollow, single-ended
4 filled, single-ended
5 triangle, single-ended
6 filled triangle, single-ended
7 kite, single-ended
8 filled kite, single-ended
9 simple, double-ended
10 simple, double-ended, acute head
11 hollow, double-ended
12 filled, double-ended
13 triangle, double-ended
14 filled triangle, double-ended
15 kite, double-ended
16 filled kite, double-ended
17 double line, single-ended
18 double line, double-ended

void gr_setarrowsize(double size)

Set the arrow size to be used for subsequent arrow commands.

This function defines the arrow size for subsequent arrow primitives. The default arrow size is 1.

Parameters
  • size: The arrow size to be used

void gr_drawarrow(double x1, double y1, double x2, double y2)

Draw an arrow between two points.

Different arrow styles (angles between arrow tail and wing, optionally filled heads, double headed arrows) are available and can be set with the gr_setarrowstyle function.

Parameters
  • x1: The X coordinate of the arrow start point (tail)
  • y1: The Y coordinate of the arrow start point (tail)
  • x2: The X coordinate of the arrow end point (head)
  • y2: The Y coordinate of the arrow end point (head)

int gr_readimage(char *, int *, int *, int **)
void gr_drawimage(double xmin, double xmax, double ymin, double ymax, int width, int height, int *data, int model)

Draw an image into a given rectangular area.

The points (xmin, ymin) and (xmax, ymax) are world coordinates defining diagonally opposite corner points of a rectangle. This rectangle is divided into width by height cells. The two-dimensional array data specifies colors for each cell.

Parameters
  • xmin: X coordinate of the lower left point of the rectangle
  • ymin: Y coordinate of the lower left point of the rectangle
  • xmax: X coordinate of the upper right point of the rectangle
  • ymax: Y coordinate of the upper right point of the rectangle
  • width: X dimension of the color index array
  • height: Y dimension of the color index array
  • data: color array
  • model: color model

The available color models are:

MODEL_RGB 0 AABBGGRR
MODEL_HSV 1 AAVVSSHH

int gr_importgraphics(char *)
void gr_setshadow(double offsetx, double offsety, double blur)

Allows drawing of shadows, realized by images painted underneath, and offset from, graphics objects such that the shadow mimics the effect of a light source cast on the graphics objects.

Parameters
  • offsetx: An x-offset, which specifies how far in the horizontal direction the shadow is offset from the object
  • offsety: A y-offset, which specifies how far in the vertical direction the shadow is offset from the object
  • blur: A blur value, which specifies whether the object has a hard or a diffuse edge

void gr_settransparency(double alpha)

Set the value of the alpha component associated with GR colors.

Parameters
  • alpha: An alpha value (0.0 - 1.0)

void gr_setcoordxform(double mat[3][2])

Change the coordinate transformation according to the given matrix.

Parameters
  • mat: 2D transformation matrix

void gr_begingraphics(char *path)

Open a file for graphics output.

gr_begingraphics allows to write all graphics output into a XML-formatted file until the gr_endgraphics functions is called. The resulting file may later be imported with the gr_importgraphics function.

Parameters
  • path: Filename for the graphics file.

void gr_endgraphics(void)
char *gr_getgraphics(void)
int gr_drawgraphics(char *)
void gr_mathtex(double x, double y, char *string)

Generate a character string starting at the given location. Strings can be defined to create mathematical symbols and Greek letters using LaTeX syntax.

Parameters
  • x: The X coordinate of the starting position of the text string
  • y: The Y coordinate of the starting position of the text string
  • string: The text string to be drawn

void gr_inqmathtex(double, double, char *, double *, double *)
void gr_beginselection(int, int)
void gr_endselection(void)
void gr_moveselection(double, double)
void gr_resizeselection(int, double, double)
void gr_inqbbox(double *, double *, double *, double *)
double gr_precision(void)
void gr_setregenflags(int)
int gr_inqregenflags(void)
void gr_savestate(void)
void gr_restorestate(void)
void gr_selectcontext(int)
void gr_destroycontext(int)
int gr_uselinespec(char *)
void gr_delaunay(int, const double *, const double *, int *, int **)
void gr_reducepoints(int n, const double *x, const double *y, int points, double *x_array, double *y_array)

Reduces the number of points of the x and y array.

Parameters
  • n: the number of points of the x and y arrays
  • x: the x value array
  • y: the y value array
  • points: the requested number of points
  • x_array: the return array for the x values
  • y_array: the return array for the y values

void gr_trisurface(int n, double *px, double *py, double *pz)

Draw a triangular surface plot for the given data points.

Parameters
  • n: The number of points
  • px: A pointer to the X coordinates
  • py: A pointer to the Y coordinates
  • pz: A pointer to the Z coordinates

void gr_gradient(int, int, double *, double *, double *, double *, double *)
void gr_quiver(int, int, double *, double *, double *, double *, int)
void gr_interp2(int nx, int ny, const double *x, const double *y, const double *z, int nxq, int nyq, const double *xq, const double *yq, double *zq, int method, double extrapval)

Interpolation in two dimensions using one of four different methods. The input points are located on a grid, described by nx, ny, x, y and z. The target grid ist described by nxq, nyq, xq and yq and the output is written to zq as a field of nxq * nyq values.

The available methods for interpolation are the following:

INTERP2_NEAREST 0 Nearest neighbour interpolation
INTERP2_LINEAR 1 Linear interpolation
INTERP_2_SPLINE 2 Interpolation using natural cubic splines
INTERP2_CUBIC 3 Cubic interpolation

Parameters
  • nx: The number of the input grid’s x-values
  • ny: The number of the input grid’s y-values
  • x: Pointer to the input grid’s x-values
  • y: Pointer to the input grid’s y-values
  • z: Pointer to the input grid’s z-values (num. of values: nx * ny)
  • nxq: The number of the target grid’s x-values
  • nyq: The number of the target grid’s y-values
  • xq: Pointer to the target grid’s x-values
  • yq: Pointer to the target grid’s y-values
  • zq: Pointer to the target grids’s z-values, used for output
  • method: Used method for interpolation
  • extrapval: The extrapolation value

gr_meta_args_t *gr_meta_args_new()
void gr_meta_args_delete(gr_meta_args_t *)
void gr_meta_args_push_arg(gr_meta_args_t *, const char *, ...)
void gr_meta_args_push_arg_buf(gr_meta_args_t *, const char *, const void *, int)
void gr_meta_args_push_kwarg(gr_meta_args_t *, const char *, const char *, ...)
void gr_meta_args_push_kwarg_buf(gr_meta_args_t *, const char *, const char *, const void *, int)
void *gr_openmeta(int, ...)
int gr_sendmeta(const void *, const char *, ...)
int gr_sendmeta_buf(const void *, const char *, const void *, int)
int gr_sendmeta_args(const void *p, const gr_meta_args_t *args)
void gr_closemeta(const void *)
const char *gr_version(void)

Returns the version string of the GR runtime.

Return
A pointer to the GR runtime version string.

struct vertex_t

Public Members

double x
double y