graphing

graphing —

Synopsis




#define     GRAPH_NO_DATA
enum        GptFlags;
#define     MAXTITLE
#define     MAX_PLOT_LABELS
#define     MAX_PLOT_LINES
#define     N_GP_COLORS
#define     BOXCOLOR
enum        PlotType;
enum        FitType;
enum        TermType;
#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_gretl_emf_term_line         (PlotType ptype,
                                             int color);
const char* gp_justification_string         (int j);
const char* gnuplot_label_front_string      (void);
int         gnuplot_init                    (PlotType ptype,
                                             FILE **fpp);
int         write_plot_type_string          (PlotType ptype,
                                             FILE *fp);
PlotType    plot_type_from_string           (const char *str);
int         gnuplot_make_graph              (void);
void        reset_plot_count                (void);
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 ***pZ,
                                             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,
                                             PRN *prn);
int         hurstplot                       (const int *list,
                                             const double **Z,
                                             DATAINFO *pdinfo,
                                             PRN *prn);
int         gretl_panel_ts_plot             (const int *list,
                                             const double **Z,
                                             DATAINFO *pdinfo);
int         plot_fcast_errs                 (int t1,
                                             int t2,
                                             const double *obs,
                                             const double *depvar,
                                             const double *yhat,
                                             const double *maxerr,
                                             const char *varname,
                                             int time_series);
int         gretl_VAR_plot_impulse_response (GRETL_VAR *var,
                                             int targ,
                                             int shock,
                                             int periods,
                                             const double **Z,
                                             const DATAINFO *pdinfo);
int         gretl_VAR_plot_multiple_irf     (GRETL_VAR *var,
                                             int periods,
                                             const double **Z,
                                             const DATAINFO *pdinfo);
int         gretl_VAR_residual_plot         (const GRETL_VAR *var,
                                             const DATAINFO *pdinfo);
int         gretl_VAR_residual_mplot        (const GRETL_VAR *var,
                                             const DATAINFO *pdinfo);
int         gretl_VAR_roots_plot            (GRETL_VAR *var);
int         confidence_ellipse_plot         (gretl_matrix *V,
                                             double *b,
                                             double t,
                                             double c,
                                             const char *iname,
                                             const char *jname);
int         is_auto_fit_string              (const char *s);
int         gnuplot_has_ttf                 (int reset);
int         gnuplot_has_pdf                 (void);
int         gnuplot_has_specified_colors    (void);
int         gnuplot_has_style_fill          (void);
void        set_graph_palette               (int i,
                                             const char *colstr);
void        graph_palette_reset             (int i);
void        print_palette_string            (char *targ);
const char* graph_color_string              (int i);
int         gnuplot_test_command            (const char *cmd);
void        pprint_gnuplot_encoding         (const char *termstr,
                                             PRN *prn);
void        fprint_gnuplot_encoding         (const char *termstr,
                                             FILE *fp);

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_BATCH          = 1 << 5,  /* working in batch mode */
    GPT_GUI            = 1 << 6,  /* called from GUI context */
    GPT_FIT_OMIT       = 1 << 7,  /* User said don't draw fitted line on graph */
    GPT_DATA_STYLE     = 1 << 8,  /* data style is set by user */
    GPT_FILE           = 1 << 9,  /* send output to named file */
    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_MINIMAL_BORDER = 1 << 15, /* omitting top and right borders */
    GPT_PNG_OUTPUT     = 1 << 16, /* output is to PNG file */
    GPT_ALL_MARKERS    = 1 << 17, /* all observation markers displayed */
    GPT_ALL_MARKERS_OK = 1 << 18, /* OK to show all observation markers */
    GPT_LETTERBOX      = 1 << 19  /* special format for time series graphs */
} GptFlags; 


MAXTITLE

#define MAXTITLE 128


MAX_PLOT_LABELS

#define MAX_PLOT_LABELS 3


MAX_PLOT_LINES

#define MAX_PLOT_LINES 8


N_GP_COLORS

#define N_GP_COLORS 4


BOXCOLOR

#define BOXCOLOR (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_VAR_ROOTS,
    PLOT_ELLIPSE,
    PLOT_MULTI_IRF,
    PLOT_PANEL,
    PLOT_BI_GRAPH,
    PLOT_TYPE_MAX
} PlotType;


enum FitType

typedef enum {
    PLOT_FIT_NONE,
    PLOT_FIT_OLS,
    PLOT_FIT_QUADRATIC,
    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;


frequency_plot_code()

#define     frequency_plot_code(c)

c :

set_png_output()

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

p :

get_png_output()

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

p :

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_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);

j :
Returns :

gnuplot_label_front_string ()

const char* gnuplot_label_front_string      (void);

Returns :

gnuplot_init ()

int         gnuplot_init                    (PlotType ptype,
                                             FILE **fpp);

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

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

This function is not used in batch mode.

ptype : indication of the sort of plot to be made.
fpp : pointer to stream to be opened.
Returns : 0 on success, 1 on failure.

write_plot_type_string ()

int         write_plot_type_string          (PlotType ptype,
                                             FILE *fp);

ptype :
fp :
Returns :

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, passing as an argument the gretl plotfile.

Returns : the return value from the system command.

reset_plot_count ()

void        reset_plot_count                (void);


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.
Returns : 0 on successful completion, error code on error.

gnuplot_3d ()

int         gnuplot_3d                      (int *list,
                                             const char *literal,
                                             double ***pZ,
                                             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)
pZ : pointer to data matrix.
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);

pmod :
pdinfo :
Returns :

rmplot ()

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

list :
Z :
pdinfo :
prn :
Returns :

hurstplot ()

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

list :
Z :
pdinfo :
prn :
Returns :

gretl_panel_ts_plot ()

int         gretl_panel_ts_plot             (const int *list,
                                             const double **Z,
                                             DATAINFO *pdinfo);

list :
Z :
pdinfo :
Returns :

plot_fcast_errs ()

int         plot_fcast_errs                 (int t1,
                                             int t2,
                                             const double *obs,
                                             const double *depvar,
                                             const double *yhat,
                                             const double *maxerr,
                                             const char *varname,
                                             int time_series);

t1 :
t2 :
obs :
depvar :
yhat :
maxerr :
varname :
time_series :
Returns :

gretl_VAR_plot_impulse_response ()

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

var :
targ :
shock :
periods :
Z :
pdinfo :
Returns :

gretl_VAR_plot_multiple_irf ()

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

var :
periods :
Z :
pdinfo :
Returns :

gretl_VAR_residual_plot ()

int         gretl_VAR_residual_plot         (const GRETL_VAR *var,
                                             const DATAINFO *pdinfo);

var :
pdinfo :
Returns :

gretl_VAR_residual_mplot ()

int         gretl_VAR_residual_mplot        (const GRETL_VAR *var,
                                             const DATAINFO *pdinfo);

var :
pdinfo :
Returns :

gretl_VAR_roots_plot ()

int         gretl_VAR_roots_plot            (GRETL_VAR *var);

var :
Returns :

confidence_ellipse_plot ()

int         confidence_ellipse_plot         (gretl_matrix *V,
                                             double *b,
                                             double t,
                                             double c,
                                             const char *iname,
                                             const char *jname);

V :
b :
t :
c :
iname :
jname :
Returns :

is_auto_fit_string ()

int         is_auto_fit_string              (const char *s);

s :
Returns :

gnuplot_has_ttf ()

int         gnuplot_has_ttf                 (int reset);

reset :
Returns :

gnuplot_has_pdf ()

int         gnuplot_has_pdf                 (void);

Returns :

gnuplot_has_specified_colors ()

int         gnuplot_has_specified_colors    (void);

Returns :

gnuplot_has_style_fill ()

int         gnuplot_has_style_fill          (void);

Returns :

set_graph_palette ()

void        set_graph_palette               (int i,
                                             const char *colstr);

i :
colstr :

graph_palette_reset ()

void        graph_palette_reset             (int i);

i :

print_palette_string ()

void        print_palette_string            (char *targ);

targ :

graph_color_string ()

const char* graph_color_string              (int i);

i :
Returns :

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.

pprint_gnuplot_encoding ()

void        pprint_gnuplot_encoding         (const char *termstr,
                                             PRN *prn);

termstr :
prn :

fprint_gnuplot_encoding ()

void        fprint_gnuplot_encoding         (const char *termstr,
                                             FILE *fp);

termstr :
fp :