Skip to content
b-k edited this page Aug 30, 2014 · 4 revisions
/** This produces a Gnuplot file that will produce an array of 2-D
 plots, one for each pair of columns in the data set. Along the diagonal
 is a plot of the variable against itself---a density plot of the variable.

 \param d  The data set whose (matrix) columns will be compared.
 \param f  The output pipe. E.g., fopen("lattice.gnuplot", "w") or popen("gnuplot --persist", "w")
*/
APOP_VAR_HEAD void apop_plot_lattice(const apop_data *d, FILE *f){
    double  width  = 1.2,//feel free to make these variable inputs.
            height = 1.2;
    double  margin = 0;
    fprintf(f, "set size %g, %g\n"
                "set rmargin 5\n"
                "set lmargin -1\n"
                "set tmargin 2.4\n"
                "set bmargin -2\n"
                "set origin %g, %g       \n"
                "set multiplot   #layout %zu, %zu downwards        \n"
                "unset xtics; unset xlabel; unset ytics; unset ylabel\n"
                "set nokey           \n"
        , width, height, margin,margin, d->matrix->size2, d->matrix->size2);
    for (size_t i = 0; i< d->matrix->size2; i++)
        for (size_t j = 0; j< d->matrix->size2; j++)
            printone(f, width, height, margin, i, j, d);
    fprintf(f, "unset multiplot\n");
}

Clone this wiki locally