graphing

graphing

Synopsis

#define             GRAPH_NO_DATA
enum                GptFlags;
typedef             gretlRGB;
typedef             GPT_SPEC;
#define             MAXTITLE
#define             N_GP_COLORS
#define             BOXCOLOR
#define             SHADECOLOR
enum                PlotType;
enum                FitType;
enum                TermType;
enum                PNGTerm;
enum                PDFTerm;
#define             frequency_plot_code                 (c)
#define             set_png_output                      (p)
#define             get_png_output                      (p)
const char *        get_gretl_png_term_line             (PlotType ptype,
                                                         GptFlags flags);
const char *        get_png_line_for_plotspec           (const GPT_SPEC *spec);
const char *        get_gretl_emf_term_line             (PlotType ptype,
                                                         int color);
const char *        gp_justification_string             (int j);
int                 split_graph_fontspec                (const char *s,
                                                         char *name,
                                                         int *psz);
void                gnuplot_missval_string              (FILE *fp);
FILE *              get_plot_input_stream               (PlotType ptype,
                                                         int *err);
FILE *              get_gnuplot_batch_stream            (PlotType ptype,
                                                         int *err);
void                gnuplot_cleanup                     (void);
int                 specified_gp_output_format          (void);
int                 write_plot_type_string              (PlotType ptype,
                                                         FILE *fp);
void                write_plot_line_styles              (int ptype,
                                                         FILE *fp);
void                print_plot_bounding_box_request     (FILE *fp);
PlotType            plot_type_from_string               (const char *str);
int                 gnuplot_make_graph                  (void);
int                 graph_written_to_file               (void);
int                 get_current_gp_term                 (void);
void                reset_plot_count                    (void);
int                 matrix_plot                         (gretl_matrix *m,
                                                         const int *list,
                                                         const char *literal,
                                                         gretlopt opt);
int                 gnuplot                             (const int *plotlist,
                                                         const char *literal,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 multi_scatters                      (const int *list,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 gnuplot_3d                          (int *list,
                                                         const char *literal,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 plot_freq                           (FreqDist *freq,
                                                         DistCode dist);
int                 garch_resid_plot                    (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);
int                 rmplot                              (const int *list,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 hurstplot                           (const int *list,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn);
int                 qq_plot                             (const int *list,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 theil_forecast_plot                 (const int *plotlist,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 gretl_panel_ts_plot                 (int vnum,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 plot_fcast_errs                     (const FITRESID *fr,
                                                         const double *maxerr,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 plot_simple_fcast_bands             (const MODEL *pmod,
                                                         const FITRESID *fr,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 plot_tau_sequence                   (const MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         int k);
int                 gretl_VAR_plot_impulse_response     (GRETL_VAR *var,
                                                         int targ,
                                                         int shock,
                                                         int periods,
                                                         double alpha,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 gretl_VAR_plot_FEVD                 (GRETL_VAR *var,
                                                         int targ,
                                                         int periods,
                                                         const DATAINFO *pdinfo);
int                 gretl_VAR_plot_multiple_irf         (GRETL_VAR *var,
                                                         int periods,
                                                         double alpha,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 gretl_VECM_combined_EC_plot         (GRETL_VAR *var,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo);
int                 gretl_system_residual_plot          (void *p,
                                                         int ci,
                                                         const DATAINFO *pdinfo);
int                 gretl_system_residual_mplot         (void *p,
                                                         int ci,
                                                         const DATAINFO *pdinfo);
int                 gretl_VAR_roots_plot                (GRETL_VAR *var);
int                 confidence_ellipse_plot             (gretl_matrix *V,
                                                         double *b,
                                                         double tcrit,
                                                         double Fcrit,
                                                         double alpha,
                                                         const char *iname,
                                                         const char *jname);
int                 xy_plot_with_control                (const int *list,
                                                         const char *literal,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);
int                 gnuplot_process_file                (gretlopt opt,
                                                         PRN *prn);
int                 is_auto_fit_string                  (const char *s);
int                 gnuplot_has_ttf                     (int reset);
int                 gnuplot_pdf_terminal                (void);
int                 gnuplot_png_terminal                (void);
int                 gnuplot_has_latin5                  (void);
int                 gnuplot_has_cp1254                  (void);
int                 gnuplot_has_cp950                   (void);
int                 gnuplot_has_bbox                    (void);
int                 gnuplot_has_utf8                    (void);
void                set_graph_palette                   (int i,
                                                         gretlRGB color);
void                set_graph_palette_from_string       (int i,
                                                         const char *cstr);
void                graph_palette_reset                 (int i);
void                print_rgb_hash                      (char *s,
                                                         const gretlRGB *color);
void                gretl_rgb_get                       (gretlRGB *color,
                                                         const char *s);
void                print_palette_string                (char *s);
const gretlRGB *    get_graph_color                     (int i);
int                 gnuplot_test_command                (const char *cmd);
void                gnuplot_png_set_use_aa              (int s);
int                 gnuplot_has_wxt                     (void);

Description

Details

GRAPH_NO_DATA

#define GRAPH_NO_DATA -999


enum GptFlags

typedef enum {
    GPT_IMPULSES       = 1 << 0,  /* use impulses for plotting */
    GPT_LINES          = 1 << 1,  /* force use of lines for plotting */
    GPT_RESIDS         = 1 << 2,  /* doing residual plot */
    GPT_FA             = 1 << 3,  /* doing fitted/actual plot */
    GPT_DUMMY          = 1 << 4,  /* using a dummy for separation */
    GPT_XYZ            = 1 << 5,  /* X-Y, controlling for Z */
    GPT_BATCH          = 1 << 6,  /* working in batch mode */
    GPT_GUI            = 1 << 7,  /* called from GUI context */
    GPT_FIT_OMIT       = 1 << 8,  /* user said don't draw fitted line on graph */
    GPT_DATA_STYLE     = 1 << 9,  /* data style is set by user */
    GPT_IDX            = 1 << 10, /* plot against time or obs index */
    GPT_TS             = 1 << 11, /* doing time series plot */
    GPT_Y2AXIS         = 1 << 12, /* plot has second y-axis */
    GPT_AUTO_FIT       = 1 << 13, /* automatic (OLS) fitted line was added */
    GPT_FIT_HIDDEN     = 1 << 14, /* autofit line calculated, but suppressed */
    GPT_PNG_OUTPUT     = 1 << 15, /* output is to PNG file */
    GPT_PRINT_MARKERS  = 1 << 16, /* print observation markers */
    GPT_LETTERBOX      = 1 << 17, /* special format for time series graphs */
    GPT_PARAMETRIC     = 1 << 18, /* gnuplot should be in parametric mode */
    GPT_XZEROAXIS      = 1 << 19, /* show x = 0 line */
    GPT_YZEROAXIS      = 1 << 20, /* show y = 0 line */
    GPT_FILL_SWITCH    = 1 << 21, /* switching from errorbars to fill */
    GPT_ERR_SWITCH     = 1 << 22, /* switching from fill to errorbars */
    GPT_MONO           = 1 << 23, /* monochrome output */
    GPT_GRID           = 1 << 24, /* display default gnuplot grid */
    GPT_POLAR          = 1 << 25  /* plot is in polar mode */
} GptFlags; 


gretlRGB

typedef struct gretlRGB_ gretlRGB;


GPT_SPEC

typedef struct GPT_SPEC_ GPT_SPEC;


MAXTITLE

#define MAXTITLE 128


N_GP_COLORS

#define N_GP_COLORS 8


BOXCOLOR

#define BOXCOLOR (N_GP_COLORS - 2)


SHADECOLOR

#define SHADECOLOR (N_GP_COLORS - 1)


enum PlotType

typedef enum {
    PLOT_REGULAR = 0,
    PLOT_H_TEST,
    PLOT_PROB_DIST,
    PLOT_FORECAST,
    PLOT_GARCH,
    PLOT_FREQ_SIMPLE,
    PLOT_FREQ_NORMAL,
    PLOT_FREQ_GAMMA,
    PLOT_PERIODOGRAM,
    PLOT_CORRELOGRAM,
    PLOT_CUSUM,
    PLOT_MULTI_SCATTER,
    PLOT_TRI_GRAPH,
    PLOT_RANGE_MEAN,
    PLOT_HURST,
    PLOT_LEVERAGE,
    PLOT_IRFBOOT,
    PLOT_KERNEL,
    PLOT_ROOTS,
    PLOT_ELLIPSE,
    PLOT_MULTI_IRF,
    PLOT_PANEL,
    PLOT_BI_GRAPH,
    PLOT_MANY_TS,
    PLOT_RQ_TAU,
    PLOT_FACTORIZED,
    PLOT_BOXPLOTS,
    PLOT_CURVE,
    PLOT_QQ,
    PLOT_USER,
    PLOT_TYPE_MAX
} PlotType;


enum FitType

typedef enum {
    PLOT_FIT_NONE,
    PLOT_FIT_OLS,
    PLOT_FIT_QUADRATIC,
    PLOT_FIT_CUBIC,
    PLOT_FIT_INVERSE,
    PLOT_FIT_LOESS,
    PLOT_FIT_NA       /* fit option not applicable */
} FitType;


enum TermType

typedef enum {
    GP_TERM_NONE,
    GP_TERM_PNG,
    GP_TERM_EPS,
    GP_TERM_PDF,
    GP_TERM_FIG,
    GP_TERM_TEX,
    GP_TERM_EMF,
    GP_TERM_SVG,
    GP_TERM_PLT
} TermType;


enum PNGTerm

typedef enum {
    GP_PNG_NONE,  /* no PNG terminal available */
    GP_PNG_OLD,   /* old driver from gnuplot 3.N */
    GP_PNG_GD1,   /* libgd driver, no truecolor option */
    GP_PNG_GD2,   /* libgd with truecolor option */
    GP_PNG_CAIRO  /* newer cairo-based driver */
} PNGTerm;


enum PDFTerm

typedef enum {
    GP_PDF_NONE,
    GP_PDF_PDFLIB,
    GP_PDF_CAIRO
} PDFTerm;


frequency_plot_code()

#define             frequency_plot_code(c)


set_png_output()

#define set_png_output(p) (p->flags |= GPT_PNG_OUTPUT)


get_png_output()

#define get_png_output(p) (p->flags & GPT_PNG_OUTPUT) 


get_gretl_png_term_line ()

const char *        get_gretl_png_term_line             (PlotType ptype,
                                                         GptFlags flags);

Constructs a suitable line for sending to gnuplot to invoke the PNG "terminal". Checks the environment for setting of GRETL_PNG_GRAPH_FONT. Also appends a color-specification string if the gnuplot PNG driver supports this.

ptype :

indication of the sort of plot to be made, which may made a difference to the color palette chosen.

flags :

plot option flags.

Returns :

the terminal string, "set term png ..."

get_png_line_for_plotspec ()

const char *        get_png_line_for_plotspec           (const GPT_SPEC *spec);


get_gretl_emf_term_line ()

const char *        get_gretl_emf_term_line             (PlotType ptype,
                                                         int color);

Constructs a suitable line for sending to gnuplot to invoke the EMF "terminal".

ptype :

indication of the sort of plot to be made.

color :

1 if graph is to be in color, else 0.

Returns :

the term string, "set term emf ..."

gp_justification_string ()

const char *        gp_justification_string             (int j);


split_graph_fontspec ()

int                 split_graph_fontspec                (const char *s,
                                                         char *name,
                                                         int *psz);


gnuplot_missval_string ()

void                gnuplot_missval_string              (FILE *fp);


get_plot_input_stream ()

FILE *              get_plot_input_stream               (PlotType ptype,
                                                         int *err);

If we're in GUI mode: writes a unique temporary filename into the internal variable gretl_plotfile; opens plotfile for writing; and writes initial lines into the output file to select the PNG terminal type and direct gnuplot's output to a temporary file in the gretl user directory.

If not in GUI mode, opens the file gpttmp.plt in the gretl user directory.

This function is not for use in batch mode.

ptype :

indication of the sort of plot to be made.

err :

location to receive error code.

Returns :

writable stream on success, NULL on failure.

get_gnuplot_batch_stream ()

FILE *              get_gnuplot_batch_stream            (PlotType ptype,
                                                         int *err);

ptype :

indication of the sort of plot to be made.

err :

location to receive error code.

Returns :

writable stream on success, NULL on failure.

gnuplot_cleanup ()

void                gnuplot_cleanup                     (void);

Removes any temporary gnuplot input file written in the user's dot directory.


specified_gp_output_format ()

int                 specified_gp_output_format          (void);


write_plot_type_string ()

int                 write_plot_type_string              (PlotType ptype,
                                                         FILE *fp);


write_plot_line_styles ()

void                write_plot_line_styles              (int ptype,
                                                         FILE *fp);


print_plot_bounding_box_request ()

void                print_plot_bounding_box_request     (FILE *fp);


plot_type_from_string ()

PlotType            plot_type_from_string               (const char *str);

str :

initial comment line from plot file.

Returns :

the special plot code corresponding to the initial comment string in the plot file, or PLOT_REGULAR if no special comment is recognized.

gnuplot_make_graph ()

int                 gnuplot_make_graph                  (void);

Executes gnuplot to produce a graph: in the gretl GUI in interactive mode this will be a PNG file. In the CLI program in interactive mode there will be a direct call to gnuplot to display the graph. In batch mode the type of file written depends on the options selected by the user.

Returns :

0 on success, non-zero on error.

graph_written_to_file ()

int                 graph_written_to_file               (void);


get_current_gp_term ()

int                 get_current_gp_term                 (void);


reset_plot_count ()

void                reset_plot_count                    (void);


matrix_plot ()

int                 matrix_plot                         (gretl_matrix *m,
                                                         const int *list,
                                                         const char *literal,
                                                         gretlopt opt);


gnuplot ()

int                 gnuplot                             (const int *plotlist,
                                                         const char *literal,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);

Writes a gnuplot plot file to display the values of the variables in list and calls gnuplot to make the graph.

plotlist :

list of variables to plot, by ID number.

literal :

commands to be passed to gnuplot.

Z :

data array.

pdinfo :

data information struct.

opt :

option flags.

Returns :

0 on successful completion, non-zero code on error.

multi_scatters ()

int                 multi_scatters                      (const int *list,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);

Writes a gnuplot plot file to display up to 6 small graphs based on the variables in list, and calls gnuplot to make the graph.

list :

list of variables to plot, by ID number.

Z :

data array.

pdinfo :

data information struct.

opt :

can include OPT_L to use lines, OPT_U to direct output to a named file.

Returns :

0 on successful completion, error code on error.

gnuplot_3d ()

int                 gnuplot_3d                          (int *list,
                                                         const char *literal,
                                                         double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt);

Writes a gnuplot plot file to display a 3D plot (Z on the vertical axis, X and Y on base plane).

list :

list of variables to plot, by ID number: Y, X, Z

literal :

literal command(s) to pass to gnuplot (or NULL)

Z :

data array.

pdinfo :

data information struct.

opt :

unused at present.

Returns :

0 on successful completion, error code on error.

plot_freq ()

int                 plot_freq                           (FreqDist *freq,
                                                         DistCode dist);

Plot the actual frequency distribution for a variable versus a theoretical distribution: Gaussian, gamma or none.

freq :

pointer to frequency distribution struct.

dist :

probability distribution code.

Returns :

0 on successful completion, error code on error.

garch_resid_plot ()

int                 garch_resid_plot                    (const MODEL *pmod,
                                                         const DATAINFO *pdinfo);


rmplot ()

int                 rmplot                              (const int *list,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);


hurstplot ()

int                 hurstplot                           (const int *list,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         PRN *prn);


qq_plot ()

int                 qq_plot                             (const int *list,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);


theil_forecast_plot ()

int                 theil_forecast_plot                 (const int *plotlist,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);


gretl_panel_ts_plot ()

int                 gretl_panel_ts_plot                 (int vnum,
                                                         const double **Z,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt);


plot_fcast_errs ()

int                 plot_fcast_errs                     (const FITRESID *fr,
                                                         const double *maxerr,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);


plot_simple_fcast_bands ()

int                 plot_simple_fcast_bands             (const MODEL *pmod,
                                                         const FITRESID *fr,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);


plot_tau_sequence ()

int                 plot_tau_sequence                   (const MODEL *pmod,
                                                         const DATAINFO *pdinfo,
                                                         int k);


gretl_VAR_plot_impulse_response ()

int                 gretl_VAR_plot_impulse_response     (GRETL_VAR *var,
                                                         int targ,
                                                         int shock,
                                                         int periods,
                                                         double alpha,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);


gretl_VAR_plot_FEVD ()

int                 gretl_VAR_plot_FEVD                 (GRETL_VAR *var,
                                                         int targ,
                                                         int periods,
                                                         const DATAINFO *pdinfo);


gretl_VAR_plot_multiple_irf ()

int                 gretl_VAR_plot_multiple_irf         (GRETL_VAR *var,
                                                         int periods,
                                                         double alpha,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);


gretl_VECM_combined_EC_plot ()

int                 gretl_VECM_combined_EC_plot         (GRETL_VAR *var,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo);


gretl_system_residual_plot ()

int                 gretl_system_residual_plot          (void *p,
                                                         int ci,
                                                         const DATAINFO *pdinfo);


gretl_system_residual_mplot ()

int                 gretl_system_residual_mplot         (void *p,
                                                         int ci,
                                                         const DATAINFO *pdinfo);


gretl_VAR_roots_plot ()

int                 gretl_VAR_roots_plot                (GRETL_VAR *var);


confidence_ellipse_plot ()

int                 confidence_ellipse_plot             (gretl_matrix *V,
                                                         double *b,
                                                         double tcrit,
                                                         double Fcrit,
                                                         double alpha,
                                                         const char *iname,
                                                         const char *jname);

Plots a 95% confidence ellipse for the parameter estimates in b with covariance V.

V :

2x2 covariance matrix.

b :

2-vector containing point estimates

tcrit :

critical t-value for 1 - alpha confidence.

Fcrit :

critical F-value for 1 - alpha confidence.

alpha :

nominal non-coverage, as decimal.

iname :

name of first parameter.

jname :

name of second parameter.

Returns :

0 on success, non-zero on error.

xy_plot_with_control ()

int                 xy_plot_with_control                (const int *list,
                                                         const char *literal,
                                                         const double **Z,
                                                         const DATAINFO *pdinfo,
                                                         gretlopt opt);

Constructs a scatterplot of modified Y against modified X, where the modification consists in taking the residuals from OLS regression of the variable in question on the control variable, a la Frisch-Waugh-Lovell.

list :

list of variables by ID number: Y, X, control.

literal :

extra gnuplot commands or NULL.

Z :

data array.

pdinfo :

pointer to dataset information.

opt :

use OPT_G for GUI graph.

Returns :

0 on success, non-zero on error.

gnuplot_process_file ()

int                 gnuplot_process_file                (gretlopt opt,
                                                         PRN *prn);

Respond to the "gnuplot" command with OPT_D, to specify that input should be taken from a user-created gnuplot command file.

opt :

may include OPT_U for output to specified file.

prn :

gretl printing struct.

Returns :

0 on success, or if ignored; otherwise error code.

is_auto_fit_string ()

int                 is_auto_fit_string                  (const char *s);


gnuplot_has_ttf ()

int                 gnuplot_has_ttf                     (int reset);


gnuplot_pdf_terminal ()

int                 gnuplot_pdf_terminal                (void);


gnuplot_png_terminal ()

int                 gnuplot_png_terminal                (void);


gnuplot_has_latin5 ()

int                 gnuplot_has_latin5                  (void);


gnuplot_has_cp1254 ()

int                 gnuplot_has_cp1254                  (void);


gnuplot_has_cp950 ()

int                 gnuplot_has_cp950                   (void);


gnuplot_has_bbox ()

int                 gnuplot_has_bbox                    (void);


gnuplot_has_utf8 ()

int                 gnuplot_has_utf8                    (void);


set_graph_palette ()

void                set_graph_palette                   (int i,
                                                         gretlRGB color);


set_graph_palette_from_string ()

void                set_graph_palette_from_string       (int i,
                                                         const char *cstr);


graph_palette_reset ()

void                graph_palette_reset                 (int i);


print_rgb_hash ()

void                print_rgb_hash                      (char *s,
                                                         const gretlRGB *color);


gretl_rgb_get ()

void                gretl_rgb_get                       (gretlRGB *color,
                                                         const char *s);


print_palette_string ()

void                print_palette_string                (char *s);


get_graph_color ()

const gretlRGB *    get_graph_color                     (int i);


gnuplot_test_command ()

int                 gnuplot_test_command                (const char *cmd);

See if the installed version of gnuplot will accept a given command.

cmd :

gnuplot command string.

Returns :

0 if gnuplot successfully handles the given command, 1 on error.

gnuplot_png_set_use_aa ()

void                gnuplot_png_set_use_aa              (int s);


gnuplot_has_wxt ()

int                 gnuplot_has_wxt                     (void);