74 namespace gnuplot_gen {
79 const string GNUPLOT_CommonStyleDef = R
"~(# 80 #---common-styles-for-plots-from-Lumiera--------- 81 set style line 1 linetype 1 linewidth 2 linecolor rgb '#240CC3' 82 set style line 2 linetype 3 linewidth 2 linecolor rgb '#1149D6' 83 set style line 3 linetype 2 linewidth 2 linecolor rgb '#0B7FCC' 84 set style line 4 linetype 6 linewidth 2 linecolor rgb '#37999D' 85 set style line 5 linetype 7 linewidth 2 linecolor rgb '#248269' 86 set style line 6 linetype 13 linewidth 2 linecolor rgb '#00C443' 87 set style line 7 linetype 12 linewidth 2 linecolor rgb '#EBE83E' 88 set style line 8 linetype 5 linewidth 2 linecolor rgb '#762C14' 89 set style line 9 linetype 4 linewidth 2 linecolor rgb '#AA0519' 91 set style line 10 linetype 1 linewidth 1 linecolor rgb '#303030' 92 set style line 11 linetype 0 linewidth 1 linecolor rgb '#A0A0A0' dashtype 3 93 #---(End)styles---------------------------------- 96 const string GNUPLOT_AxisGridSetup = R
"~(# 97 #---axis-and-grid-setup-------------------------- 100 set grid back linestyle 11 102 set arrow 10 from graph 0,0 to graph 1.04,0 size screen 0.025,15,60 filled ls 10 103 set arrow 11 from graph 0,0 to graph 0,1.08 size screen 0.025,15,60 filled ls 10 107 const string GNUPLOT_BASIC_PLOT_DEF = R
"~(# 109 # GNUPLOT - data plot from Lumiera 114 if TermSize}size ${TermSize}${endif} 116 }set term wxt size ${TermSize} 117 ${endif}${endif Term} 119 set datafile separator ",;" 121 ####---------Data-------------------------------- 122 $RunData << _End_of_Data_ 131 }set xlabel '${Xlabel}' 133 }stats $RunData using (abscissaName=strcol(1)) every ::0::0 nooutput 135 set xlabel abscissaName 138 }set ylabel '${Ylabel}' ${end if Ylabel 141 set xrange [${Xrange}] ${endif 143 set yrange [${Yrange}] ${endif 144 }set key autotitle columnheader tmargin 148 const string GNUPLOT_SIMPLE_DATA_PLOT = R
"~(# 149 ####--------------------------------------------- 150 plot for [i=2:*] $RunData using 1:i with ${DiagramKind} linestyle i-1 155 const string GNUPLOT_SCATTER_REGRESSION = R
"~(# 156 stats $RunData using 1:2 nooutput 159 }# regression line function (given as parameter) 160 regLine(x) = ${RegrSlope} * x + ${RegrSocket} 162 }# regression line function derived from data 163 regLine(x) = STATS_slope * x + STATS_intercept 166 regLabel = sprintf("Model: %3.2f·p + %3.2f", STATS_slope, STATS_intercept) 168 set key horizontal width -4 171 ${else}${if Xrange}${else 174 ${end if}${end if Xtics 176 plots = STATS_columns - 1 177 # Adjust layout based on number of data sequences; 178 # additional sequences placed into secondary diagram 181 set multiplot layout 2,1 # 2 rows 1 column 182 set lmargin at screen 0.12 # fixed margins to align diagrams 183 set rmargin at screen 0.88 187 ####---------Scatter-Regression-Plot------------- 188 plot $RunData using 1:2 with points linestyle 1, \ 189 regLine(x) with line linestyle 9 title regLabel 192 # switch off decorations for secondary diagram 196 set key bmargin vertical 198 set yrange [${Y2range}] 203 } set ylabel '${Y2label}' ${endif 206 ####--------------------------------- 207 plot $RunData using 1:3 with impulses linestyle 3 210 # more than one additional data sequence 213 } set y2range [${Y3range}] 218 } set y2label '${Y3label}' offset -1.5 220 ####--------------------------------------------- 221 plot $RunData using 1:3 with impulses linestyle 3, \ 222 for [i=4:*] $RunData using 1:i with points linestyle 5+(i-4) axes x1y2 244 +GNUPLOT_SIMPLE_DATA_PLOT};
246 params.set (
"CommonStyleDef", GNUPLOT_CommonStyleDef)
247 .set (
"AxisGridSetup", GNUPLOT_AxisGridSetup)
248 .set (KEY_DiagramKind,
"points")
250 return plot.render (params.genNode());
268 +GNUPLOT_SCATTER_REGRESSION};
270 params.set (
"CommonStyleDef", GNUPLOT_CommonStyleDef)
271 .set (
"AxisGridSetup", GNUPLOT_AxisGridSetup)
273 return plot.render (params.genNode());
Preconfigured setup for data visualisation with Gnuplot.
Text template substitution engine.
string scatterRegression(ParamRecord params)
Generate a (X,Y)-scatter plot with regression line.
string dataPlot(ParamRecord params)
Generate a Gnuplot diagram to visualise the given data points.
Implementation namespace for support and library code.
A minimalistic text templating engine with flexible data binding.
A complement to allow instantiation of a TextTemplate with ETD data.