From a616a0abe3f873e5186e17d1003cae02d0c51b46 Mon Sep 17 00:00:00 2001 From: Vogt Date: Thu, 14 Sep 2023 15:22:14 +0200 Subject: [PATCH] Add variable wr_onspace to allow printing the vetor name with one space delimiter --- src/frontend/plotting/gnuplot.c | 45 +++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/frontend/plotting/gnuplot.c b/src/frontend/plotting/gnuplot.c index 677a51bce..00f94a220 100644 --- a/src/frontend/plotting/gnuplot.c +++ b/src/frontend/plotting/gnuplot.c @@ -688,7 +688,7 @@ void ft_writesimple(double *xlims, double *ylims, FILE *file_data; struct dvec *v; int i, numVecs, maxlen, preci; - bool appendwrite, singlescale, vecnames; + bool appendwrite, singlescale, vecnames, onespace; NG_IGNORE(xlims); NG_IGNORE(ylims); @@ -701,6 +701,7 @@ void ft_writesimple(double *xlims, double *ylims, appendwrite = cp_getvar("appendwrite", CP_BOOL, NULL, 0); singlescale = cp_getvar("wr_singlescale", CP_BOOL, NULL, 0); vecnames = cp_getvar("wr_vecnames", CP_BOOL, NULL, 0); + onespace = cp_getvar("wr_onespace", CP_BOOL, NULL, 0); /* Sanity checking. */ for (v = vecs, numVecs = 0; v; v = v->v_link2) @@ -745,19 +746,37 @@ void ft_writesimple(double *xlims, double *ylims, /* Print names of vectors to first line */ if (vecnames) { bool prscale = TRUE; - for (v = vecs; v; v = v->v_link2) { - struct dvec *scale = v->v_scale; - /* If wr_singlescale is set, print scale name only in first column */ - if (prscale) - fprintf(file_data, " %-*s", preci + 7, scale->v_name); + if (onespace) { /* a single space between names */ + for (v = vecs; v; v = v->v_link2) { + struct dvec* scale = v->v_scale; + /* If wr_singlescale is set, print scale name only in first column */ + if (prscale) + fprintf(file_data, " %s", scale->v_name); - if (isreal(v)) - fprintf(file_data, " %-*s", preci + 7, v->v_name); - else - fprintf(file_data, " %-*s %-*s", preci + 7, v->v_name, preci + 7, v->v_name); - if (singlescale) - /* the following names are printed without scale vector names */ - prscale = FALSE; + if (isreal(v)) + fprintf(file_data, " %s", v->v_name); + else + fprintf(file_data, " %s %s", v->v_name, v->v_name); + if (singlescale) + /* the following names are printed without scale vector names */ + prscale = FALSE; + } + } + else { /* names formatted according to number width */ + for (v = vecs; v; v = v->v_link2) { + struct dvec* scale = v->v_scale; + /* If wr_singlescale is set, print scale name only in first column */ + if (prscale) + fprintf(file_data, " %-*s", preci + 7, scale->v_name); + + if (isreal(v)) + fprintf(file_data, " %-*s", preci + 7, v->v_name); + else + fprintf(file_data, " %-*s %-*s", preci + 7, v->v_name, preci + 7, v->v_name); + if (singlescale) + /* the following names are printed without scale vector names */ + prscale = FALSE; + } } fprintf(file_data, "\n"); }