See also the separate document on Tips & Tricks with GnuDraw.
Tables:
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 90In 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".
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.
TP_SOLID solid line TP_DOTTED dotted line TP_DASHED dashed line TP_LDASHED long-dashed line TP_USER user-defined line
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
#include <packages/gnudraw/gnudraw.h> CloseDrawWindow();
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.
#include <packages/gnudraw/gnudraw.h> Draw(const iArea, const mYt); Draw(const iArea, const mYt, const dXfirst, const dXstep);
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.
#include <packages/gnudraw/gnudraw.h> DrawAbout();
This function gives a line of information on the GnuDraw version on screen.
#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);
Alternatively, a vector of line indices can be passed along, see Tips.
Draws an ACF and/or PACF.
#include <packages/gnudraw/gnudraw.h> DrawAdjust(const iType, ...);
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_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
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.
#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);
DrawAxis and DrawAxisAuto are partially implemented in GnuDraw, with ANCHOR_USER restricted to a choice of dAnchor= 0.
#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);
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.
#include <packages/gnudraw/gnudraw.h> DrawBoxPlot(const iArea, const mY, const sY); DrawBoxPlot(const iArea, const mY, const sY, const iIndex);
Draws a box plot of the data in the specified area. Note that subsequent plots in the same drawwindow might get disturbed slightly.
#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);
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.
#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);
Draws a correlogram (the ACF is computed using acf, resulting in a slightly different plot from the oxdraw version of DrawCorrelogram).
#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);
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.
#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);
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.
#include <packages/gnudraw/gnudraw.h> DrawLegend(const iArea, const iOffsX, const iOffsY, const fHidden);
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.
#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);
#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);
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.
#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);
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]
#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);
Draws a QQ plot. The following distributions are supported:
#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);
Draws the estimated spectral density.
#include <packages/gnudraw/gnudraw.h> DrawSymbol(const iArea, const dX1, const dY1, const dX2, const dY2, const iSymType, const iIndex);
#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);
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.
#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);
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.
#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);
Alternatively, a vector of line indices can be passed along, see Tips.
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.
#include <packages/gnudraw/gnudraw.h> DrawX(const iArea, const mYt, const vX);
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.
#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);
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.
#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);
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).
#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);
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:
dFac | z | Lower | Upper |
---|---|---|---|
> 0 | 1 x iT | vY - dF * mZ | vY + dF * mZ |
> 0 | 2 x iT | vY - dF * mZ[0][] | vY + dF * mZ[1][] |
= 0 | 2 x iT | mZ[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.
#include <packages/gnudraw/gnudraw.h> SaveDrawWindow(const sFilename);
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:
For better compatibility with OxDraw, change the size of the graph using
DrawAdjust(ADJ_PAPERSCALE, 50); // half-heightwhich 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% heightbut these are not compatible with OxDraw.
#include <packages/gnudraw/gnudraw.h> SetDraw(const iOption, ...);
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
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).
#include <packages/gnudraw/gnudraw.h> SetDrawWindow(const sTitle);
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.
#include <packages/gnudraw/gnudraw.h> SetTextWindow(const sTitle);
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.
#include <packages/gnudraw/gnudraw.h> ShowDrawWindow();
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.
#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.oxThis will however only work if only compatible graphing functions have been used.
oxl -DGNUDRAW -g gnugauss.prgThe 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