1 /* 2 * gretl -- Gnu Regression, Econometrics and Time-series Library 3 * Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 /* graphing.h for gretl */ 21 22 #ifndef GRAPHING_H 23 #define GRAPHING_H 24 25 #include <stdio.h> 26 27 typedef enum { 28 GPT_IMPULSES = 1 << 0, /* use impulses for plotting */ 29 GPT_LINES = 1 << 1, /* force use of lines for plotting */ 30 GPT_RESIDS = 1 << 2, /* doing residual plot */ 31 GPT_FA = 1 << 3, /* doing fitted/actual plot */ 32 GPT_DUMMY = 1 << 4, /* using a dummy for separation */ 33 GPT_XYZ = 1 << 5, /* X-Y, controlling for Z */ 34 GPT_FIT_OMIT = 1 << 6, /* user said don't draw fitted line on graph */ 35 GPT_DATA_STYLE = 1 << 7, /* data style is set by user */ 36 GPT_IDX = 1 << 8, /* plot against time or obs index */ 37 GPT_TS = 1 << 9, /* doing time series plot */ 38 GPT_Y2AXIS = 1 << 10, /* plot has second y-axis */ 39 GPT_AUTO_FIT = 1 << 11, /* automatic (OLS) fitted line was added */ 40 GPT_FIT_HIDDEN = 1 << 12, /* autofit line calculated, but suppressed */ 41 GPT_PNG_OUTPUT = 1 << 13, /* output is to PNG file */ 42 GPT_PRINT_MARKERS = 1 << 14, /* print observation markers */ 43 GPT_LETTERBOX = 1 << 15, /* special format for time series graphs */ 44 GPT_PARAMETRIC = 1 << 16, /* gnuplot should be in parametric mode */ 45 GPT_XZEROAXIS = 1 << 17, /* show x = 0 line */ 46 GPT_YZEROAXIS = 1 << 18, /* show y = 0 line */ 47 GPT_MONO = 1 << 19, /* monochrome output */ 48 GPT_GRID_Y = 1 << 20, /* display horizontal grid lines */ 49 GPT_GRID_X = 1 << 21, /* display vertical grid lines */ 50 GPT_POLAR = 1 << 22, /* plot is in polar mode */ 51 GPT_XL = 1 << 23, /* large */ 52 GPT_XXL = 1 << 24, /* extra-large */ 53 GPT_XW = 1 << 25, /* extra-wide */ 54 GPT_TIMEFMT = 1 << 26, /* using gnuplot "timefmt" */ 55 GPT_ICON = 1 << 27, /* saving plot "as icon" */ 56 GPT_STEPS = 1 << 28, /* force steps for plot */ 57 GPT_LOGY = 1 << 29 /* log y axis */ 58 } GptFlags; 59 60 /* an extra "command" for use with GUI callback */ 61 #define GP_ASYNC (NC+1) 62 63 typedef guint32 gretlRGB; 64 65 typedef struct GPT_SPEC_ GPT_SPEC; 66 67 #define N_GP_LINETYPES 8 68 69 #define GP_WIDTH 640 70 #define GP_HEIGHT 480 71 #define GP_LB_WIDTH 680 72 #define GP_LB_HEIGHT 400 73 #define GP_XL_WIDTH 680 74 #define GP_XL_HEIGHT 510 75 #define GP_XXL_WIDTH 680 76 #define GP_XXL_HEIGHT 680 77 #define GP_XW_WIDTH 800 78 #define GP_SQ_SIZE 480 79 80 typedef enum { 81 PLOT_REGULAR = 0, 82 PLOT_H_TEST, 83 PLOT_PROB_DIST, 84 PLOT_FORECAST, 85 PLOT_GARCH, 86 PLOT_FREQ_SIMPLE, 87 PLOT_FREQ_NORMAL, 88 PLOT_FREQ_GAMMA, 89 PLOT_FREQ_DISCRETE, 90 PLOT_PERIODOGRAM, 91 PLOT_CORRELOGRAM, 92 PLOT_CUSUM, 93 PLOT_MULTI_SCATTER, 94 PLOT_TRI_GRAPH, 95 PLOT_RANGE_MEAN, 96 PLOT_HURST, 97 PLOT_LEVERAGE, 98 PLOT_IRFBOOT, 99 PLOT_KERNEL, 100 PLOT_ROOTS, 101 PLOT_ELLIPSE, 102 PLOT_MULTI_IRF, 103 PLOT_PANEL, 104 PLOT_BI_GRAPH, 105 PLOT_MANY_TS, 106 PLOT_RQ_TAU, 107 PLOT_FACTORIZED, 108 PLOT_BOXPLOTS, 109 PLOT_CURVE, 110 PLOT_QQ, 111 PLOT_USER, 112 PLOT_XCORRELOGRAM, 113 PLOT_BAR, 114 PLOT_STACKED_BAR, 115 PLOT_3D, 116 PLOT_BAND, 117 PLOT_HEATMAP, 118 PLOT_GEOMAP, 119 PLOT_TYPE_MAX 120 } PlotType; 121 122 typedef enum { 123 PLOT_FIT_NONE, 124 PLOT_FIT_OLS, 125 PLOT_FIT_QUADRATIC, 126 PLOT_FIT_CUBIC, 127 PLOT_FIT_INVERSE, 128 PLOT_FIT_LOESS, 129 PLOT_FIT_LOGLIN, 130 PLOT_FIT_LINLOG, 131 PLOT_FIT_NA /* fit option not applicable */ 132 } FitType; 133 134 typedef enum { 135 GP_TERM_NONE, 136 GP_TERM_PNG, 137 GP_TERM_EPS, 138 GP_TERM_PDF, 139 GP_TERM_FIG, 140 GP_TERM_TEX, 141 GP_TERM_EMF, 142 GP_TERM_SVG, 143 GP_TERM_PLT, 144 GP_TERM_VAR 145 } TermType; 146 147 typedef enum { 148 NA_SKIP, /* exclude regions with missing payload */ 149 NA_OUTLINE, /* show outlines of such areas */ 150 NA_FILL /* give such regions a specific fill color */ 151 } NaAction; 152 153 #define maybe_big_multiplot(c) (c == PLOT_MULTI_IRF || \ 154 c == PLOT_MULTI_SCATTER || \ 155 c == PLOT_PANEL) 156 157 #define frequency_plot_code(c) (c == PLOT_FREQ_SIMPLE || \ 158 c == PLOT_FREQ_NORMAL || \ 159 c == PLOT_FREQ_GAMMA || \ 160 c == PLOT_FREQ_DISCRETE) 161 162 #define set_png_output(p) (p->flags |= GPT_PNG_OUTPUT) 163 #define get_png_output(p) (p->flags & GPT_PNG_OUTPUT) 164 #define unset_png_output(p) (p->flags &= ~GPT_PNG_OUTPUT) 165 166 const char *gretl_gnuplot_term_line (TermType ttype, 167 PlotType ptype, 168 GptFlags flags, 169 const char *font); 170 171 const char *get_png_line_for_plotspec (const GPT_SPEC *spec); 172 173 char *gretl_png_font_string (void); 174 175 const char *gp_justification_string (int j); 176 177 int split_graph_fontspec (const char *s, char *name, int *psz); 178 179 void gnuplot_missval_string (FILE *fp); 180 181 void write_gp_dataval (double x, FILE *fp, int final); 182 183 FILE *open_plot_input_file (PlotType ptype, GptFlags flags, int *err); 184 185 FILE *open_3d_plot_input_file (int *iact); 186 187 int finalize_plot_input_file (FILE *fp); 188 189 int finalize_3d_plot_input_file (FILE *fp); 190 191 int gnuplot_graph_wanted (PlotType ptype, gretlopt opt); 192 193 void gnuplot_cleanup (void); 194 195 int specified_gp_output_format (void); 196 197 int write_plot_output_line (const char *path, FILE *fp); 198 199 int write_plot_type_string (PlotType ptype, GptFlags flags, FILE *fp); 200 201 void write_plot_line_styles (int ptype, FILE *fp); 202 203 int write_plot_bounding_box_request (FILE *fp); 204 205 void set_effective_plot_ci (int ci); 206 207 void set_special_plot_size (float width, float height); 208 209 int set_plotstyle (const char *style); 210 211 const char *get_plotstyle (void); 212 213 PlotType plot_type_from_string (const char *str); 214 215 void plot_get_scaled_dimensions (int *width, int *height, double scale); 216 217 int graph_written_to_file (void); 218 219 int graph_displayed (void); 220 221 void reset_plot_count (void); 222 223 int matrix_plot (gretl_matrix *m, const int *list, const char *literal, 224 gretlopt opt); 225 226 int gnuplot (const int *plotlist, const char *literal, 227 const DATASET *dset, gretlopt opt); 228 229 int multi_scatters (const int *list, const DATASET *dset, 230 gretlopt opt); 231 232 int matrix_scatters (const gretl_matrix *m, const int *list, 233 const DATASET *dset, gretlopt opt); 234 235 int gnuplot_3d (int *list, const char *literal, 236 DATASET *dset, gretlopt *opt); 237 238 int plot_freq (FreqDist *freq, DistCode dist, gretlopt opt); 239 240 int plot_corrmat (VMatrix *corr, gretlopt opt); 241 242 int garch_resid_plot (const MODEL *pmod, const DATASET *dset); 243 244 int rmplot (const int *list, DATASET *dset, 245 gretlopt opt, PRN *prn); 246 247 int hurstplot (const int *list, DATASET *dset, gretlopt opt, 248 PRN *prn); 249 250 int qq_plot (const int *list, const DATASET *dset, gretlopt opt); 251 252 int hf_plot (const int *list, const char *literal, 253 const DATASET *dset, gretlopt opt); 254 255 int correlogram_plot (const char *vname, 256 const double *acf, 257 const double *pacf, 258 const gretl_matrix *PM, 259 int m, double pm, 260 gretlopt opt); 261 262 int periodogram_plot (const char *vname, 263 int T, int L, const double *x, 264 gretlopt opt); 265 266 int arma_spectrum_plot (MODEL *pmod, const DATASET *dset, 267 gretlopt opt); 268 269 int theil_forecast_plot (const int *plotlist, const DATASET *dset, 270 gretlopt opt); 271 272 int gretl_panel_ts_plot (int vnum, DATASET *dset, gretlopt opt); 273 274 int panel_means_XY_scatter (const int *list, const DATASET *dset, 275 gretlopt opt); 276 277 int cli_panel_plot (const int *list, const char *literal, 278 const DATASET *dset, gretlopt opt); 279 280 int plot_fcast_errs (const FITRESID *fr, const double *maxerr, 281 const DATASET *dset, gretlopt opt); 282 283 int plot_simple_fcast_bands (const MODEL *pmod, 284 const FITRESID *fr, 285 const DATASET *dset, 286 gretlopt opt); 287 288 int plot_tau_sequence (const MODEL *pmod, const DATASET *dset, 289 int k); 290 291 int 292 gretl_VAR_plot_impulse_response (GRETL_VAR *var, 293 int targ, int shock, 294 int periods, double alpha, 295 const DATASET *dset, 296 gretlopt opt); 297 298 int gretl_VAR_plot_FEVD (GRETL_VAR *var, int targ, int periods, 299 const DATASET *dset, gretlopt opt); 300 301 int 302 gretl_VAR_plot_multiple_irf (GRETL_VAR *var, 303 int periods, double alpha, 304 const DATASET *dset, 305 gretlopt opt); 306 307 int gretl_VECM_combined_EC_plot (GRETL_VAR *var, 308 const DATASET *dset); 309 310 int gretl_system_residual_plot (void *p, int ci, int eqn, const DATASET *dset); 311 312 int gretl_system_residual_mplot (void *p, int ci, const DATASET *dset); 313 314 int gretl_VAR_roots_plot (GRETL_VAR *var); 315 316 int confidence_ellipse_plot (gretl_matrix *V, double *b, 317 double tcrit, double Fcrit, double alpha, 318 const char *iname, const char *jname); 319 320 int xy_plot_with_control (const int *list, const char *literal, 321 const DATASET *dset, gretlopt opt); 322 323 int gnuplot_process_file (gretlopt opt, PRN *prn); 324 325 int print_gnuplot_literal_lines (const char *s, int ci, 326 gretlopt opt, FILE *fp); 327 328 int is_auto_fit_string (const char *s); 329 330 void set_graph_color_from_string (int i, const char *cstr); 331 332 void graph_palette_reset (int i); 333 334 void print_rgb_hash (char *s, gretlRGB color); 335 336 gretlRGB gretl_rgb_get (const char *s); 337 338 void print_palette_string (char *s); 339 340 gretlRGB get_graph_color (int i); 341 342 gretlRGB get_boxcolor (void); 343 344 gretlRGB get_shadecolor (void); 345 346 void set_boxcolor (gretlRGB color); 347 348 void set_shadecolor (gretlRGB color); 349 350 int parse_gnuplot_color (const char *s, char *targ); 351 352 int gnuplot_test_command (const char *cmd); 353 354 void gnuplot_png_set_default_scale (double s); 355 356 void date_from_gnuplot_time (char *targ, size_t tsize, 357 const char *fmt, double x); 358 359 double gnuplot_time_from_date (const char *s, 360 const char *fmt); 361 362 int gnuplot_has_wxt (void); 363 364 int write_map_gp_file (const char *plotfile, 365 int plotfile_is_image, 366 const char *datfile, 367 const gretl_matrix *bbox, 368 const gretl_matrix *zrange, 369 gretl_bundle *opts, 370 int non_standard, 371 int na_action, 372 int show); 373 374 int transcribe_geoplot_file (const char *src, 375 const char *dest, 376 const char *datname); 377 378 int write_tdisagg_plot (const gretl_matrix *YY, int mult, 379 const char *title, DATASET *dset); 380 381 #endif /* GRAPHING_H */ 382 383