GnuDraw Graphics Function Reference

Chapter contents:

Chapter contents:

See also the separate document on Tips & Tricks with GnuDraw.

Tables:

Default line attributes
Symbol types
Line types
Plotting styles

Table draw.1: Default line attributes

index    color           line type  width   symbol   size

 0       white            solid      10     plus     90
 1       black            solid       6     plus     90
 2       red              solid      10     plus     90
 3       blue             solid      10     box      90
 4       blue/green       solid      10     circle   90
 5       purple           dotted     10     plus     90
 6       green            dotted     10     plus     90
 7       brown/yellow     long dash  10     plus     90
 8       dark purple      long dash  10     plus     90
 9       pastel yellow    dotted     10     plus     90
10       pastel green     dotted     10     plus     90
11       pastel blue      solid      10     plus     90
12                        solid      10     plus     90
13       light grey       solid      10     plus     90
14       grey             solid      10     plus     90
15       light grey       solid      10     plus     90
In GnuDraw, instead of the integer line index the routines also accept either a string with a RGB colour specification, like "#FFFF00", or a string with a colour name, like "yellow".

Table draw.2: Symbol types

    PL_FILLBOX    filled box        PL_FILLCIRCLE    filled circle   
    PL_BOX        open box          PL_TRIANGLE      triangle        
    PL_PLUS       plus              PL_FILLTRIANGLE  filled triangle 
    PL_DASH       dash              PL_DIAMOND       diamond         
    PL_CIRCLE     circle            PL_FILLDIAMOND   filled diamond  
    PL_LINE       no symbol         PL_CROSS         cross  
    PL_DOT        dot (GnuDraw only)
The symbol types in GnuDraw may differ slightly from the ones in OxDraw.

Table draw.3: Line types

    TP_SOLID      solid line 
    TP_DOTTED     dotted line 
    TP_DASHED     dashed line 
    TP_LDASHED    long-dashed line 
    TP_USER       user-defined line 

Table draw.4: Plotting styles

    ST_LINE           line (points connected)
    ST_SYMBOLS        symbols              
    ST_LINESYMBOLS    line and symbols     
    ST_INDEX          index line           
    ST_INDEXSYMBOLS   index line with symbols
    ST_BARS           bars                 
    ST_SHADING        shading              

[Top]

CloseDrawWindow

#include <packages/gnudraw/gnudraw.h>
CloseDrawWindow();
No return value.

Closes the draw window. On many platforms nothing will happen, e.g. when the graphs appear in GiveWin, the graph will remain active there.

GnuDraw: Subsequent commands will use clean graphing window.

[Top]

Draw

#include <packages/gnudraw/gnudraw.h>
Draw(const iArea, const mYt);
Draw(const iArea, const mYt, const dXfirst, const dXstep);
iArea
in: int, area index
mYt
in: m x T matrix with m rows of data
dXfirst
in: (optional) double, X-value of first observation, x, default is 1
dXstep
in: (optional) double, gap between X-values, dx, default is 1

No return value.

This function draws m variables against an X variable, where the X variable consists of evenly spaced observations x, x+dx, x+2dx, x+3dx, .... Each variable is drawn by linking up the points. The first line index is 2.

[Top]

DrawAbout

#include <packages/gnudraw/gnudraw.h>
DrawAbout();
No return value.

This function gives a line of information on the GnuDraw version on screen.

[Top]

DrawAcf

#include <packages/gnudraw/gnudraw.h>
DrawAcf(const iArea, const vY, const sY, const cLag, ...);
DrawAcf(const iArea, const vY, const sY, const cLag, const fAcf,
    const fPacf, const fErrorBand, int iIndex, const fBar, const fJoin);
iArea
in: int, area index
vY
in: k x T matrix, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
cLag
in: int, highest lag to be used in the ACF
fAcf
in: int, TRUE: draw ACF (optional argument, drawn by default)
fPacf
in: int, TRUE: draw PACF (optional argument, not drawn by default)
fErrorBand
in: int, TRUE: draw error bands (optional argument, not drawn by default)
iIndex
in: int, line index, see default line attributes, (optional argument, default is 2).

Alternatively, a vector of line indices can be passed along, see Tips.

fBar
in: int, 1: draw bar plot, 0: draw index plot, 2: connect points using lines (optional argument, using bars by default)
fJoin
in: int, TRUE: draw plots together in one window, else draw each row of vY separately (optional argument, the default can be set using SetDraw(SET_JOIN, fJoin))

No return value.

Draws an ACF and/or PACF.

[Top]

DrawAdjust

#include <packages/gnudraw/gnudraw.h>
DrawAdjust(const iType, ...);
iType
in: int, type of adjustment
d1 ... d5
in: optional arguments

No return value.
Description.
This function adjusts the properties of the current graph.

The expected number of arguments depends on the type of adjustment (use -1 to keep the default value):

constant         d1          d2          d3         d4        d5

ADJ_AREAMATRIX   Y areas     X areas     box
ADJ_AREA_3D      area        azimuth     elevation  distance  twist
ADJ_AREA_P       area        x_1         y_1        width     height
ADJ_AREA_X       area        x_1         x_2        grow 
ADJ_AREA_Y       area        y_1         y_2        grow 
ADJ_AREA_Z       area        z_1         z_2        grow
ADJ_AREASCOLOR   red:0-255	 green:0-255 blue:0-255
ADJ_AXISCENTRE   0,1
ADJ_AXISFORMAT   fmt         isxaxis
ADJ_AXISGRID     0,1         colour      type
ADJ_AXISHIDE     0,1 
ADJ_AXISLABEL    rotation    font        size       tick size
ADJ_AXISLINE     zero line   above       no line    no small
ADJ_AXISSCALE    type        scale       shift      isxaxis
ADJ_AXISTEXT     labels      locations   isxaxis
ADJ_AXES2ND      0,1         0,1
ADJ_CNTRPARAM    nc
ADJ_CNTRPARAM    z1          zInc        zEnd
ADJ_CNTRPARAM    vc
ADJ_COLOR        colour      type        linewidth
ADJ_COLORMODEL   display:0,1 print:0-4
ADJ_FILLCURVE    isxaxis     level
ADJ_INDEX        0,1,2       base
ADJ_LABEL        coord       just
ADJ_LEGEND       area        no columns  font size  resize    box     
ADJ_MINMAX       minimum     maximum
ADJ_PAPERCOLOR   red:0-255   green:0-255 blue:0-255
ADJ_PAPERSCALE   percentage  percentage
ADJ_SCALE        scale       shift
ADJ_SHOW         0,1,2
ADJ_SYMBOL       type        size
ADJ_SYMBOLUSE    style 
ADJ_WARN         0,1

In GnuDraw the options ADJ_AREA_3D, ADJ_AREASCOLOR, ADJ_AXISCENTRE, ADJ_PAPERCOLOR, ADJ_SCALE and ADJ_SYMBOLUSE are not implemented at present.
New options are

ADJ_AXES2ND
Plot the last line against the second x- and/or y-axis, when corresponding parameter is 1.
ADJ_AXISFORMAT
Adjusts the format of the x-, y- or z-axis tic labels to a specified format, e.g. the format "$%2.0f" would give integers prepended with the $ sign, or " %.1P pi" would give "1.5 pi". Note that Ox tends to use a string starting with a % as a format specifier, hence prepend a space if needed.
ADJ_AXISTEXT
Replaces the tics on the axis by the labels specified in the first argument, at locations as specified in the second argument.
ADJ_CNTRPARAM
Adjust the number of contour lines used in bivariate plot. One integer argument indicates the number of contours; two or three scalar arguments indicate start, increment and possibly the end of the set of contour levels; one vector argument draws contours at given heights.
ADJ_FILLCURVE
Fill a region. Without further arguments, a region underneath the plot is filled (results sometimes unpredictable); when the axis is specified, the region towards that axis is filled; when a level is also specified, a region towards the line axis=level is filled.
ADJ_LABEL
Place the label using plot coordinates (d1=0, default), using graph coordinates (d1=1, with coordinates running from (0,0) to (1,1) per area) or screen-coordinates (d1=2, with coordinates running from (0,0) to (1,1) over all areas), possibly justified left (-1), center (0) or right (1) as specified by just.
ADJ_SHOW
Set or unset the calling of GnuPlot. If the argument is 0, GnuPlot is not called in SaveDrawWindow or ShowDrawWindow. On Linux, the output terminal can be changed from x11 (default, argument 1) to wxt (alternative, if Gnuplot supports it, with value 2).
ADJ_WARN
GnuDraw gives some warning messages on screen if input is not as expected. Use ADJ_WARN to turn off all output.
Changed is the implementation of ADJ_COLOR. The dashed line types are not easily available in GnuPlot. Instead, a combination of lines and points is used. When the type TP_USER is chosen, a third parameter should be passed along containing a string with the GnuPlot line type, e.g. `impulses', `boxes' or `steps'. The last parameter can indicate the line thickness (default= 10). If a color d1 < -1 is chosen, arrows of color |d1| are plotted instead of line segments. Also, the color argument can be a colour indication like "#FFFF00", "yellow" or any other RGB colour indicator (both these colors result in a bright yellow). Such RGB string as colour indicator can also be used in all other plotting routines, instead of the integer iIndex.

ADJ_INDEX with first argument equal to 1 draws an index line, use 2 for bars. The second argument (not implemented in GnuDraw) sets the base for the index line or bars.

The type for ADJ_AXISSCALE is one of:

    AXIS_LINEAR  standard axis,
    AXIS_LOG     log-scale (data is in natural logarithms),
    AXIS_LOG10   log10-scale (data is in base-10 logarithms),
    AXIS_SCALED  scaled: set scale and shift, plotting C'= aC+b 
    AXIS_DATE    dated: interpret as Julian date/time values.
With ADJ_AXISSCALE an extra option isxaxis can be given with values of 1: X axis, default, 0: Y axis, 2: Z axis, 3: X2 axis, 4: Y2 axis.

ADJ_LEGEND can be used to show a box around the legend; by default, GnuDraw does not display the box (but the default behaviour can be changed using SetDraw(SET_LEGEND, ...). Number of columns, fontsize and resizing are not implemented in GnuDraw.

For ADJ_SYMBOL, the default symbol size is 90; the symbol types do not correspond fully to the symbol types in OxDraw, see the table with Symbol Types.

ADJ_AREA_X, ADJ_AREA_Y, ADJ_AREA_Z have an optional argument grow. Set this to one if the area should only grow if it already has dimensions fixed.
With ADJ_AREA_X, the x_1 and x_2 can be specified as dayofcalendar() values for time series plots.

ADJ_PAPERSCALE with one argument changes the scale of the y-axis (in percentages); if two arguments are supplied, both x- and y-axis are scaled, where the y-axis is scaled by the second argument.

See Tips for a couple of advanced uses of DrawAdjust.

[Top]

DrawAxis, DrawAxisAuto

#include <packages/gnudraw/gnudraw.h>
DrawAxis(const iArea, const iIsXaxis, const dAnchor,
    const dAxmin, const dAxmax, const dFirstLarge,
    const dLargeStep, const dSmallStep, const iFreq);
DrawAxisAuto(const iArea, const iIsXaxis, ...);
DrawAxisAuto(const iArea, const iIsXaxis, bool fShow,
    int iAnchor, double dAnchor);
iArea
in: int, area index
iIsXaxis
in: int, 1: X axis, 0: Y axis, 2: Z axis, 3: X2 axis, 4: Y2 axis
dAnchor
in: int, anchor of the axis (e.g. Y location of X axis). In GnuPlot, choice of anchor is not possible, and its meaning is changed to 0: Tics on zeroaxis, non-zero: tics on border, show zeroaxis, M_NAN: tics on border, no zeroaxis.
dAxmin
in: axis minimum (not working in GnuDraw, adjust ADJ_AREA_X or ADJ_AREA_Y instead.
dAxmax
in: axis maximum, in GnuDraw effectively the location of the last large tick.
dFirstLarge
in: location of first large tick
dLargeStep
in: step size between large ticks
dSmallStep
in: step size between small ticks
iFreq
in: int, frequency (for time series axis). Default is 1, for 1 year; if dLargeStep is expressed in months, set iFreq to 12.
fShow
in: int, TRUE: show the axis
iAnchor
in: int, axis anchor location, ANCHOR_MIN: at minimum, ANCHOR_MAX: at maximum, ANCHOR_USER: at dAnchor
dAnchor2
in: int, if iAnchor=ANCHOR_USER: anchor of the 3D axis (Z location of X and Y axis, Y location of Z)

No return value.

DrawAxis and DrawAxisAuto are partially implemented in GnuDraw, with ANCHOR_USER restricted to a choice of dAnchor= 0.

See Tips for using DrawAxis with a time series axis.

[Top]

DrawBivDensity

#include <packages/gnudraw/gnudraw.h>
DrawBivDensity(const iArea, const mY, const sY, const fDens,
    const fHist, const fNormal);
DrawBivDensity(const iArea, const mY, const sY, const fDens,
    const fHist, const fNormal, const iMode);
DrawBivDensity(const iArea, const mY, const sY, const fDens,
    const fHist, const fNormal, const iMode, const vW);
iArea
in: int, area index
mY
in: k x T matrix, each combination of rows is a new plot
sY
in: string, variable name, or array of strings (k > 1)
fDens
in: int, TRUE: draw estimated bivariate density
fHist
in: int, TRUE: draw histogram
fNormal
in: int, TRUE: add normal density for reference
iMode
in: int, type of plot:
0 - surface plot only
1 - surface plot with contours on ground level
2 - contour plot
vW (optional)
in: 1 x T matrix, weights to apply in weighted density plot

Return value:
vX
out: 1 x nX vector with X variable of last plot
vY
out: 1 x nY vector with Y variable of last plot
mZ
out: nY x nX matrix with heights above plain

Draws the histogram and/or density of the data in the specified area. When fNormal is TRUE, a normal density with the same mean and variance as the data will be drawn. When weights are supplied, a weighted density plot is created.

For the last plot, the output [vX, vY, mZ] can be used as input for DrawXYZ. This way, it is possible to quickly draw a surface and a contour plot without reestimating the kernel approximation, i.e. using

  [vX, vY, mZ]= DrawBivDensity(0, mY, asY, TRUE, FALSE, FALSE, 0);
  DrawXYZ(1, vX, vY, mZ, 2, asY[0], asY[1], "height");
For compatibility with the OxDraw version of DrawXYZ, the first coordinate is plotted on the Y axis, the second on the X axis.

See DrawAdjust(ADJ_CNTRPARAM, n) for adjusting the number of contour lines.

[Top]

DrawBoxPlot

#include <packages/gnudraw/gnudraw.h>
DrawBoxPlot(const iArea, const mY, const sY);
DrawBoxPlot(const iArea, const mY, const sY, const iIndex);
iArea
in: int, area index
mY
in: k x T matrix, each row is a new plot (needs T > 5)
sY
in: string, variable name, or array of strings (k > 1)
iIndex
in: int, line index, see default line attributes, (optional argument, default is 2).

No return value.

Draws a box plot of the data in the specified area. Note that subsequent plots in the same drawwindow might get disturbed slightly.

[Top]

DrawCdf

#include <packages/gnudraw/gnudraw.h>
DrawCdf(const iArea, const vY, const sY, ...);
DrawCdf(const iArea, const vY, const sY, const vP0, const vQ, const iIndex);
iArea
in: int, area index
vY
in: k x T matrix, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
vP0
in: k x 1 vector, true parameter values (optional argument)
vQ
in: vector of size 3, quantiles to indicate in plot (optional argument, default is vQ= <0.05, .5, .95>)
iIndex
in: int, line index, see default line attributes, (optional argument, default is 2).

Return value:
mX, mY
out: k x n matrices with X- and Y-coordinates of estimated cdfs.

Draws a empirical cumulative distribution function of the data in the specified area, together with a box indicating the quantiles, and a cross at the location of the true parameters.

[Top]

DrawCorrelogram

#include <packages/gnudraw/gnudraw.h>
DrawCorrelogram(const iArea, const vY, const sY,
    const cLag);
DrawCorrelogram(const iArea, const vY, const sY,
    const cLag, const fJoin);
iArea
in: int, area index
vY
in: k x T matrix, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
cLag
in: int, highest lag to be used in correlogram
fJoin
in: int, TRUE: correlograms are drawn together in one area. The default can be set using SetDraw(SET_JOIN, fJoin).

No return value.

Draws a correlogram (the ACF is computed using acf, resulting in a slightly different plot from the oxdraw version of DrawCorrelogram).

[Top]

DrawDensity

#include <packages/gnudraw/gnudraw.h>
DrawDensity(const iArea, const vY, const sY, ...);
DrawDensity(const iArea, const vY, const sY, const fDens,
    const fHist, const fNormal, const fCdf, const fStand, const cBar,
    const iIndex, const vWeight, const fJoin);
iArea
in: int, area index
vY
in: k x T matrix, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
fDens
in: int, TRUE: draw estimated density (optional argument, default)
fHist
in: int, TRUE: draw histogram (optional argument, not drawn by default)
fNormal
in: int, TRUE: add normal density for reference (optional argument, not drawn by default)
fCdf
in: int, TRUE: plot CDF in separate area (optional argument, not drawn by default)
fStand
in: int, TRUE: use standardized data (optional argument, default uses original data)
cBar
in: int, number of bars (0: use default; optional argument)
iIndex
in: int, line index, see default line attributes, (optional argument, default is 2).
vWeight
in: 1 x T matrix with weights (optional argument, default is 1).
fJoin
in: int, TRUE: draw plots together in one window, else draw each row of vY separately (optional argument, the default can be set using SetDraw(SET_JOIN, fJoin))

Return value:
mX, mY
out: k x n matrices with X- and Y-coordinates of estimated densities, or empty if no densities were estimated

Draws the histogram and/or density of the data in the specified area. When fNormal is TRUE, a normal density with the same mean and variance as the data will be drawn. When fCdf is TRUE, the CDF is plotted in a separate area. In case weights are supplied, a weighted density plot is created.

[Top]

DrawHistogram

#include <packages/gnudraw/gnudraw.h>
DrawHistogram(const iArea, const vBar, ...);
DrawHistogram(const iArea, const vBar, const sY, const dMin, const dStep,
    const iIndex, const iColorIn);
DrawHistogram(const iArea, const vBar, const dMin, const dStep,
    const iIndex, const iColorIn);
iArea
in: int, area index
vBar
in: k x T matrix with bar heights, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
dMin
in: double, first X-coordinate of histogram (optional argument, default is 1)
dStep
in: double, bar step size (optional argument, default is 1)
iIndex
in: int, line index, see default line attributes, (optional argument, default is 2).
iColorIn
in: int, colour index for inside of bars, see default line attributes, (optional argument, default is 0: white).

No return value.

Draws a histogram when the data is already in histogram format, i.e. vBar contains the bar heights.

Note that GnuDraw allows the specification of the variable names; this option is not available in OxDraw.

[Top]

DrawLegend

#include <packages/gnudraw/gnudraw.h>
DrawLegend(const iArea, const iOffsX, const iOffsY,
    const fHidden);
iArea
in: int, area index
iOffsX
in: int, X pixel offset from left, 0, .., 1000, or
in: double, X fraction offset from left in graph area,or
in: int, 0 or 1, indicator for left or right (allowing GnuPlot to place legend not fully in the corner, but more freely)
iOffsY
in: int, Y pixel offset from top, 0, .., 1000, or
in: double, Y fraction offset from top in graph area, or
in: int, 0 or 1, indicator for top or bottom (allowing GnuPlot to place legend not fully in the corner, but more freely)
fHidden
in: int, 1: hide the legend, 0: show legend, -1 (GnuDraw only) place legend outside graph

No return value.

Slight difference with oxdraw, as also fraction offset from top left is allowed as input.
If both iOffsX and iOffsY are integer 0 or 1, GnuDraw places the legend in the top-left (0, 0) or bottom-right (1, 1) corner. Default is top-left.
Furthermore, the legend can be placed next to the graph, instead of in the graphing area itself.

[Top]

DrawLine

#include <packages/gnudraw/gnudraw.h>
DrawLine(const iArea, const dX1, const dY1, const dX2,
    const dY2, const iIndex);
DrawLine(const iArea, const dX1, const dY1, const dZ1,
    const dX2, const dY2, const dZ2, const iIndex);
iArea
in: int, area index
dX1, dY1
in: int, real-world coordinates of starting point
dX2, dY2
in: int, Y real-world coordinates of end point
dZ1, dZ2
in: int, real-world Z coordinates for symbol in 3D graph
iIndex
in: int, line index, see default line attributes, (optional argument, default is 2). With a negative line index, an arrowhead is drawn on the line (see Tips).

No return value.
[Top]

DrawMatrix

#include <packages/gnudraw/gnudraw.h>
DrawMatrix(const iArea, const mYt, const asY,
    const dXfirst, const dXstep, ...);
DrawMatrix(const iArea, const mYt, const asY,
    const dXfirst, const dXstep, iSymbol, iIndex);
iArea
in: int, area index
mYt
in: m x T matrix with m rows of data
asY
in: array of strings (holds variable names), or 0 (no names)
dXfirst
in: double, X-value of first observation, x
dXstep
in: double, gap between X-values, dx
iSymbol
in: int, 0: draw line, 1: draw symbols, 2: draw both, 3: draw indices (optional argument, default is 0). See also Plotting styles. Alternatively a vector with value for each row of data can be specified.
iIndex
in: int, line index for first row, see default line attributes, (optional argument, default is 2). Each subsequent row will have the next index. Alternatively a vector with value for each row of data can be specified, see Tips.

No return value.

This is a more flexible version of the Draw() function. DrawMatrix draws the m variables in the rows of mYt. The X variable consists of evenly spaced observations x, x+dx, x+2dx, x+3dx, .... The following table gives the default settings for each line index. Note that index 0 is the background colour, and 1 the foreground colour.

[Top]

DrawPLine, DrawPSymbol, DrawPText

#include <packages/gnudraw/gnudraw.h>
DrawPLine(const iArea, const iX1, const iY1, const iX2,
    const iY2, const iIndex);
DrawPSymbol(const iArea, const iX1, const iY1, const iX2,
    const iY2, const iSymType, const iIndex);
DrawPText(const iArea, const sText, const iPx1,
    const iPy1, ...);
DrawPText(const iArea, const sText,const iPx1,const iPy1,
    const iFontNo, const iFontSize, const fTitle, const iJust);
No return value.
Pixel coordinate versions of DrawLine, DrawSymbol DrawText.

DrawPSymbol is not implemented in GnuDraw.

The coordinates (0, 0) indicate the lower left corner. The upper right corner is either (15.000, 10.000), or (1, 1). iFontNo and iFontSize are disregarded. With iJust (deprecated), justification of the text can be chosen. Possible options are -1 (default, left), 0 (center) or 1 (right).

[Top]

DrawQQ

#include <packages/gnudraw/gnudraw.h>
DrawQQ(const iArea, const vY, const sY, const iDens,
    const df1, const df2);
DrawQQ(const iArea, const vY, const sY, const iDens,
    const df1, const df2, const bJoin);
iArea
in: int, area index
vY
in: k x T matrix, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
iDens
in: int, one of: QQ_CHI, QQ_F, QQ_N, QQ_N_SE, QQ_T, QQ_U
df1
in: int, first parameter for distribution
df2
in: int, second parameter for distribution
bJoin
in: boolean, TRUE: draw plots together in one window, else draw each row of vY separately (optional argument, drawing rows separately by default)

No return value.

Draws a QQ plot. The following distributions are supported:

  • QQ_CHI : chi ^2(df1),
  • QQ_F : F(df1, df2),
  • QQ_N : N(0, 1),
  • QQ_N_SE : N(0, 1), with pointwise asymptotic 95% standard error bands, as derived in Engler and Nielsen(2009),
  • QQ_T : t(df1),
  • QQ_U : Uniform(0,1), resulting in a Quantile plot.
[Top]

DrawSpectrum

#include <packages/gnudraw/gnudraw.h>
DrawSpectrum(const iArea, const vY, const sY,
    const iOrder);
DrawSpectrum(const iArea, const vY, const sY,
    const iOrder, const fJoin);
iArea
in: int, area index
vY
in: k x T matrix, each row is a new plot
sY
in: string, variable name, or array of strings (k > 1)
iOrder
in: int, lag truncation parameter m
fJoin
in: (optional, GnuDraw only) boolean, if TRUE spectra are plotted together in one window. The default can be set using SetDraw(SET_JOIN, fJoin).

No return value.

Draws the estimated spectral density.

[Top]

DrawSymbol

#include <packages/gnudraw/gnudraw.h>
DrawSymbol(const iArea, const dX1, const dY1, const dX2,
    const dY2, const iSymType, const iIndex);
iArea
in: int, area index
dX1, dY1
in: int, real-world coordinates, lower-left corner of bounding box
dX2, dY2
in: int, real-world coordinates, upper-right corner of bounding box
iSymType
in: int, symbol type
iIndex
in: int, line index for first row, see default line attributes, (optional argument, default is 2). Each subsequent row will have the next index.

No return value.
[Top]

DrawT

#include <packages/gnudraw/gnudraw.h>
DrawT(const iArea, const mYt, const mnYear,
    const mnPeriod, const iFreq);
DrawT(const iArea, const mYt, const mMY, 
    const dDum, const dDum);
iArea
in: int, area index
mYt
in: m x T matrix with m y variables
mnYear
in: int, year of first observation
mnPeriod
in: int, period of first observation
iFreq
in: int, frequency of observations
mMY
in: 2 x T matrix with months and years or 3 x T matrix with days, months and years or 1 x T matrix with Julian day
dDum
in: not used, only placeholder

No return value.

Draws m variables in the specified area against time. Each variable is drawn by linking up the points. The first line index is 2. Time can be specified as a combination of the year and period of the first observation together with the frequency, as a 2 x T matrix with months and years or as a 3 x T matrix with day, month and years.

See also DrawTMatrix for a more extensive function.

[Top]

DrawText, DrawTitle

#include <packages/gnudraw/gnudraw.h>
DrawText(const iArea, const sText, const dX1,
    const dY1, ...);
DrawText(const iArea, const sText, const dX1, const dY1,
    const iFontNo, const iFontSize, const iTitle, const iRotation,
    const dZ1);
DrawText(const iArea, const sText, const dX1, const dY1,
    const iFontNo, const iFontSize, const iTitle, const iRotation,
    const dZ1, const iJust);
DrawTitle(const iArea, const sText);
iArea
in: int, area index.
dX1, dY1, dZ1
in: real-world coordinates, anchor of text. Z-coordinate is required for 3-dimensional plots. For time series data, dX1 should contain the calender index according to the dayofcalendar() function, possible with the fraction of the day passed for intradaily data.
iFontNo (not implemented in GnuDraw)
in: int, font number (0 for first font; use -1 for the default font)
iFontSize
in: int, font size (e.g. 300; use -1 for the default size). The effective font size depends on the output type used.
iTitle
in: int, 0 or TEXT_TEXT: is normal text, else
TEXT_TITLE - graph title (coordinates are ignored)
TEXT_XLABEL - label along X-axis (coordinates are ignored)
TEXT_YLABEL - label along Y-axis (coordinates are ignored)
TEXT_ZLABEL - label along Z-axis (coordinates are ignored)
TEXT_AREA - (GnuDraw specific) normal text with coordinates referring to area, running from (0,0) to (1,1).
TEXT_PANEL - (GnuDraw specific) normal text with coordinates referring to panel, running from (0,0) to (1,1) or (15000,10000)
iRotation
in: int, rotation (in degrees, default is 0 for normal text, 90 for Y-label). Rotation only works for TEXT_TEXT and TEXT_YLABEL, not for X-labels or the graph title.
dZ1
in: int, real-world Z coordinate of text anchor (for text in 3D graphs; default is 0)
iJust
in: integer (optional, GnuDraw specific), indicates justification of label. Possible (GnuPlot) options are -1 (default, left), 0 (center) or 1 (right).

No return value.

Note that the backward slash for LaTeX commands (if you use LaTeX output) must be doubled, for example:

DrawText(0, "$\\phi \\rightarrow \\infty$", 1962, 1, -1, -1, 0, 45);
With EPS output, you can use postscript symbols as explained in the ps_guide.ps (part of the GnuPlot documentation), like in
DrawText(0, "{/Symbol f \256 \245}", 1962, 1, -1, -1, 0, 45);
DrawTitle draws text at the title location. This corresponds to DrawText(iArea, sText, 0, 0, -1, -1, TEXT_TITLE). With a command
  DrawTitle(-1, "A title")
a title is put on top of all graphing windows jointly, instead of only above one of the windows (GnuDraw only).

Text can also be rotated, by specifying the angle in degrees. The fontsize can be used, but output depends on the terminal in use, e.g. results can be very different for screen, pdf or eps output.

The coordinate system can either be the standard coordinate system (TEXT_TEXT), a graph coordinate system running from (0,0) to (1,1), (TEXT_AREA) or referring to the full screen (TEXT_PANEL, effectively this corresponds to using DrawPText). It can be justified using iJust here, or by using a DrawAdjust(ADJ_LABEL, iGraph, iJust) command, where iGraph=0 for the standard coordinates, 1 for area coordinates, and 2 for panel coordinates.

[Top]

DrawTMatrix

#include <packages/gnudraw/gnudraw.h>
DrawTMatrix(const iArea, const mYt, const asY,
    const mnYear, const mnPeriod, const iFreq, ...);
DrawTMatrix(const iArea, const mYt, const asY,
    const mnYear, const mnPeriod, const iFreq, 
    const iSymbol, const iIndex);
DrawTMatrix(const iArea, const mYt, const asY,
    const mYMDHMS, const sFormat, const imxTics, ...);
DrawTMatrix(const iArea, const mYt, const asY,
    const mYMDHMS, const sFormat, const imxTics,
    const iSymbol, const iIndex);
iArea
in: int, area index
mYt
in: m x T matrix with m y variables
asY
in: array of strings (holds variable names), or 0 (no names)
mnYear
in: int, year of first observation, or minus hour of first observation
mnPeriod
in: int, period of first observation (e.g. month, quarter or minute)
iFreq
in: int, frequency of observations (within year or hour)
iSymbol
in: int, 0: draw line, 1: draw symbols, 2: draw both, 3: (GnuDraw only) draw indices (optional argument, default is 0).
iIndex
in: int, line index for first row, see Default line attributes, (optional argument, default is 2). Each subsequent row will have the next index.

Alternatively, a vector of line indices can be passed along, see Tips.

mYMDHMS
in: 1 x T matrix with Julian day, and possibly intra-day timing as a fraction of the day 4 x T matrix with Julian day, hour, min, seconds or 6 x T matrix with year, month, day, hour, min, and seconds, or 2 x T matrix with Julian day and seconds since midnight, or 4 x T matrix with year, month, day, and seconds since midnight.
Higher frequencies can be skipped from the matrix if not used. To leave lower frequencies unspecified, use rows of missings for year, month, day, etc.
sFormat
in: string, with user-specified datings the format on the time axis can be specified, using a subset of %Y, %y, %m, %d, %H, %M, %S for the year (4-digit or 2-digit), month, day, hour, minute and second. The string should contain opening and closing quotes, e.g. sFormat= "'%H:%M:%s'".
If not-specified (e.g., zero, missing, or empty string), a default format is chosen.
imxTics
in: int, number of intervals between larger tic-marks. If zero, default value is chosen.

No return value.

This is a more flexible version of the DrawT() function. Draws m variables in the specified area against time. See under DrawMatrix for the default settings for each line index.

The x-area of the time series plot can be adapted using DrawAdjust, see the example among the Tips.

[Top]

DrawX

#include <packages/gnudraw/gnudraw.h>
DrawX(const iArea, const mYt, const vX);
iArea
in: int, area index
mYt
in: m x T matrix with m y variables
vX
in: 1 x T matrix with x variable or
m x T matrix with multiple x variablesGnuDraw

No return value.

Draws m y variables in the specified area against an x variable. Each point is marked, but the points are not linked, resulting in a cross plot. The first line index is 2.

[Top]

DrawXMatrix

#include <packages/gnudraw/gnudraw.h>
DrawXMatrix(const iArea, const mYt, const asY, const vX,
    const sX, ...);
DrawXMatrix(const iArea, const mYt, const asY, const vX,
    const sX, const iSymbol, const iIndex);
mYt
in: m x T matrix with m y variables
asY
in: array of strings (holds variable names), or 0 (no names)
iArea
in: int, area index
vX
in: 1 x T or m x T matrix with x variables
sX
in: string, or array of strings (holds variable names), or 0 (no names)
iSymbol
in: int, 0: draw line, 1: draw symbols, 2: draw both, 3: (GnuDraw only) draw indices (optional argument, default is 0).
iIndex
in: int, line index for first row, see Default line attributes, (optional argument, default is 2). Each subsequent row will have the next index. Using GnuDraw, an m-vector of indices can given, indicating each lines color.

No return value.

This is a more flexible version of the DrawX() function. Draws m variables in the specified area against an x variable. See under DrawMatrix for the default settings for each line index.

[Top]

DrawXYZ

#include <packages/gnudraw/gnudraw.h>
DrawXYZ(const iArea, const vX, const vY, const mZ);
DrawXYZ(const iArea, const vX, const vY, const mZ,
    const iMode, const sX, const sY, const sZ, 
    const iPalette, const iIndex);
iArea
in: int, area index
vX
in: 1 x k matrix with X variable
vY
in: 1 x n matrix with Y variable
mZ
in: k x n matrix with Z variable, heights above XY plane
or
in: 1 x n=k matrix with Z coordinates for points (X, Y, Z), rough approximation of surface is constructed
iMode
in: int, type of plot:
0 - surface plot only
1 - surface plot with contours on ground level
2 - contour plot
sX
in: string, name of X variable (optional argument)
sY
in: string, name of Y variable (optional argument)
sZ
in: string, name of Z variable (optional argument)
iPalette
in: int, palette index, not implemented in GnuDraw (optional argument).
iIndex
in: int, line index for mesh (optional argument, default is 2).

No return value.

For compatibility with the OxDraw version of DrawXYZ, the first coordinate is plotted on the Y axis, the second on the X axis.

This routines plots Z data above a grid. See also DrawBivDensity and DrawAdjust(ADJ_CNTRPARAM, n).

[Top]

DrawZ

#include <packages/gnudraw/gnudraw.h>
DrawZ(const mZ, ...);
DrawZ(const mZ, const sZ, const iMode, const dFac,
    const iIndex);
DrawZ(const mZ, const sZ, const iMode, const dFac,
    const iSymbol, const iIndex);
mZ
in: 1 x T matrix with Z variable (symmetric BAR, BAND, HILO or FAN plot),
2 x T matrix with Z variables (asymmetric BAR, BAND or HILO plot) or
q x T matrix with Z variables (asymmetric FAN plot) containing distance of grid-lines from center.
sZ
in: string, 1 name of Z variable
iMode
in: int, type of Z variable (optional argument):
ZMODE_SYMBOL - use values as symbol size,
ZMODE_VALUE - draw value as text,
ZMODE_BAR - draw error bars (the default),
ZMODE_BAND - draw error bands,
ZMODE_FAN - draw error fans,
ZMODE_HILO - draw high-low plot (min(X, Z) to max(X, Z)),
ZMODE_3D - draw 3-D points.
ZMODE_COLOR - use value as RGB color, between 0 (0x000000) and 2^24-1 (0xFFFFFF)
dFac
in: double, bar/band/offset factor (optional argument, 2.0 is default), or
q vector with quantiles used for FAN plot (default is [.05, .075, ..., .95]). For ZMODE_VALUE, the value is taken as a percentage offset from the (x,y) coordinates towards the top-right, to not put the value on top of the point itself.
iSymbol (GnuDraw only)
in: int, 0: draw line, 1: draw symbols, 2: draw both, 3: draw indices, -1: follow symbol type of last graphics object (optional argument, default is 0). Specifies the line/symbol type of the error bands, when used in combination with ZMODE_BAND or ZMODE_3D; skipped otherwise.
iIndex
in: int, line index for first row, see Default line attributes (optional argument, default is 2).

No return value.

DrawZ adds a Z component to the most recent graphics object. DrawZ should be a should be used immediately after a call to one of the draw functions Draw, DrawMatrix, DrawX, etc.).

The mode ZMODE_SYMBOL adapts symbol size. Default symbol size is 90.

Added is the functionality to plot asymmetric BAR, BAND and HILO plots (with mZ containing two rows, with either the `standard deviation' of the lower and higher part of the density, or (if dFac= 0) the lower and upper ranges. For these cases, the resulting lower and upper values are as indicated in the following table:

dFaczLowerUpper
> 01 x iTvY - dF * mZvY + dF * mZ
> 02 x iTvY - dF * mZ[0][]vY + dF * mZ[1][]
= 02 x iTmZ[0][]mZ[1][]

Asymmetric FAN plots are possible where the distance of the gridlines to the center can be specified completely. For a sensible fan plot, specify a larger (say 10-20) number of gridlines. As an example, the following two graphs would look the same:

  mX= rann(100, 10);
  vMu= meanc(mX);
  vS= sqrt(varc(mX));
  Draw(0, vMu);
  DrawZ(vS, "S", ZMODE_FAN, M_NAN);

  Draw(1, vMu);
  DrawZ(quann(range(.05, .95, .05)').*vS, "S", ZMODE_FAN, range(.05, .95, .05));
  ShowDrawWindow();
See scatcol.ox for an example of the use of ZMODE_COLOR.

The style of the labels is governed using a global setting with SetDraw(SET_LABDRAWZ, bStyle). By default (TRUE), a single label X x S is shown.

[Top]

SaveDrawWindow

#include <packages/gnudraw/gnudraw.h>
SaveDrawWindow(const sFilename);

sFilename
in: valid file name.

No return value.

Saves the current graph to a file with extension .plt or .plb. GnuPlot uses this file as input to create a file with the specified extension. On Linux, OSX and Windows platforms, GnuPlot is called automatically, leaving both the .plt and the final output file at the specified location. The following formats are supported:

.emf:
GnuPlot graphics file, resulting in EMF output (1, 1).
.eps or .tkf:
GnuPlot graphics file, resulting in Encapsulated PostScript output.
.gif:
GnuPlot graphics file, resulting in GIF image.
.fig:
XFig color graphics file. The image can be edited on screen using the XFig plotting program.
.pdf:
GnuPlot graphics file, resulting in PDF image. Note that PDF output is only available if your GnuPlot installation supports PDF; this is usually only the case for non-Windows installations.
Furthermore, the PDF implemenation of GnuPlot in combination with enhanced fonts, or changing font sizes, is not fully robust. You might prefer to use EPS output instead, converting to PDF with the epstopdf tool.
.png:
GnuPlot graphics file, resulting in PNG image.
.svg:
GnuPlot graphics file, resulting in SVG output
.tex or .aux:
GnuPlot graphics file, resulting in PSLaTeX output
.etex:
GnuPlot graphics file, resulting in EPSLaTeX output. Results in two output files, with extensions .tex and .eps.
.plb:
GnuPlot graphics file, no indication of final output included

For better compatibility with OxDraw, change the size of the graph using

  DrawAdjust(ADJ_PAPERSCALE, 50);       // half-height
which results in a half-height graph. GnuDraw can also handle calls like
  DrawAdjust(ADJ_PAPERSCALE, 80, 50);    // 80% width, 50% height
  DrawAdjust(ADJ_PAPERSCALE, 0.8, 0.5);  // 80% width, 50% height
but these are not compatible with OxDraw.
[Top]

SetDraw

#include <packages/gnudraw/gnudraw.h>
SetDraw(const iOption, ...);
iType
in: int, type of adjustment
i1 ... i5
in: optional arguments

No return value.

The expected number of arguments depends on the type of adjustment:

option          i1           i2             i3            i4           i5 

SET_AXIS        fontsize     step           tick       
SET_AXISLINE    no X-line    no Y-line      center dates  no small Y      
SET_BOX         box:0--1     X-grid:0--1    Y-grid:0--1       
SET_COLOR       lineno:0--15 red:0--255     green:0--255  blue:0--255     
SET_COLORMODEL  model:0--3          
SET_FONT        fontno:0--3  fontsize       enhanced:0--1
SET_GRID        color:0--15  type:0--15         
SET_HISTOGRAM   inside:0--15 outside:0--15       
SET_JOIN        join:0--1  
SET_LABDRAWZ    style:0--1
SET_LEGEND      boxed:0--1   columns         
SET_LEGENDHIDE  hide:0--1          
SET_LINE        lineno:0--15 linetype:0--4  width         on           off 
SET_MARGIN      left t top         
SET_OUTPUT      type:0--2
SET_PRINTPAGE   orient:0--1  papertype:0--2 X-size        Y-size     
SET_SYMBOL      lineno:0--15 symtype:0--4   size            
Only the options SET_BOX, SET_COLORMODEL, SET_FONT, SET_JOIN, SET_LABDRAWZ, SET_LEGEND, SET_LEGENDHIDE, SET_LINE, SET_OUTPUT and SET_SYMBOL are implemented in GnuDraw. The default lineno is 2, symbol size is 90, font size is 300, width is 10. For the colormodel, a colormodel of 3 results in a color plot, colormodels 0-2 give a monochrome plot (if the output type of the plot supports this). Legends are drawn by default without a box, in contrast to the OxDraw default. Changing the number of columns of the legend is not implemented.

For SET_FONT, an extra boolean enhanced can be set, indicating that fonts can use subscripts, superscripts etc. Default is TRUE.

SET_JOIN, SET_LABDRAWZ and SET_OUTPUT are specific to GnuDraw. The first controls whether acf, correlogram, density or spectrum plots are joined together into one window. This is off by default (as is the default in OxDraw).

SET_LABDRAWZ sets the style of the labels for a DrawZ plot. If TRUE (default), a single label of the format X x S appears in the legend. If FALSE, two separate labels (e.g. X and S) are given in the legend.

The argument of SET_OUTPUT governs the type of screen output. Values are 0 (no output, corresponding to a call to DrawAdjust(ADJ_SHOW, FALSE)), 1 (default, either Windows or standard X11 output), or 2 (Linux only, wxt output).

[Top]

SetDrawWindow

#include <packages/gnudraw/gnudraw.h>
SetDrawWindow(const sTitle);
sTitle
in: string, name of window

No return value.

Under Unix, this function continues graphing in a window with the name sTitle. All subsequent graphs, shown by the ShowDrawWindow command, appear within this window, instead of opening in new screens as in the default behaviour.

On non-Unix systems, this function for the moment does nothing.

See packages/gnudraw/samples/ar1.ox for an example.

[Top]

SetTextWindow

#include <packages/gnudraw/gnudraw.h>
SetTextWindow(const sTitle);
sTitle
in: string, name of window

No return value.

This function is only relevant when interacting with GiveWin otherwise it does nothing. It sets the name of the GiveWin window in which the output (from the print() function) of the Ox program appears to sTitle.

[Top]

ShowDrawWindow

#include <packages/gnudraw/gnudraw.h>
ShowDrawWindow();
No return value.

Shows the drawing. Note that in some implementations the graphs cannot be displayed. Then a message is printed (SaveDrawWindow() will still work in that case!). ShowDrawWindow is implemented for the Windows, Linux and Sun environments.

A call to ShowDrawWindow also clears the drawing buffer, so that subsequent graphing starts from an empty sheet.

[Top]

OxDraw

OxDraw is the standard package in Ox for making graphs. A program which is set up to use GnuDraw with the statement
#include <packages/gnudraw/gnudraw.h>
can still be used with OxDraw by using a compiler directive on the command line, starting the program with
  oxl -DOXDRAW myprogram.ox
This will however only work if only compatible graphing functions have been used.

OxGauss

To use GnuDraw from OxGauss, no change to the Gauss programme is needed at all. The Ox executable will default to using GnuDraw when the program is started using
  oxl -DGNUDRAW -g gnugauss.prg
The option -DGNUDRAW defines the token GNUDRAW, triggering the use of GnuDraw instead of OxDraw. Saving the graphs from OxGauss should be possible setting the variable _ptek="filename.eps", or using one of the other file extensions.


GnuDraw version 7.0. Original OxDraw © JA Doornik
Changes made on 18-May-2015 for including GnuDraw statements by CS Bos