83 namespace gnuplot_gen {
88 const string GNUPLOT_CommonStyleDef = R
"~(# 89 #---common-styles-for-plots-from-Lumiera--------- 90 set style line 1 linetype 1 linewidth 2 linecolor rgb '#240CC3' 91 set style line 2 linetype 3 linewidth 2 linecolor rgb '#1149D6' 92 set style line 3 linetype 2 linewidth 2 linecolor rgb '#0B7FCC' 93 set style line 4 linetype 6 linewidth 2 linecolor rgb '#37999D' 94 set style line 5 linetype 7 linewidth 2 linecolor rgb '#248269' 95 set style line 6 linetype 13 linewidth 2 linecolor rgb '#00C443' 96 set style line 7 linetype 12 linewidth 2 linecolor rgb '#EBE83E' 97 set style line 8 linetype 5 linewidth 2 linecolor rgb '#762C14' 98 set style line 9 linetype 4 linewidth 2 linecolor rgb '#AA0519' 100 set style line 10 linetype 1 linewidth 1 linecolor rgb '#303030' 101 set style line 11 linetype 0 linewidth 1 linecolor rgb '#A0A0A0' dashtype 3 102 #---(End)styles---------------------------------- 105 const string GNUPLOT_AxisGridSetup = R
"~(# 106 #---axis-and-grid-setup-------------------------- 109 set grid back linestyle 11 111 set arrow 10 from graph 0,0 to graph 1.04,0 size screen 0.025,15,60 filled ls 10 112 set arrow 11 from graph 0,0 to graph 0,1.08 size screen 0.025,15,60 filled ls 10 116 const string GNUPLOT_BASIC_PLOT_DEF = R
"~(# 118 # GNUPLOT - data plot from Lumiera 123 if TermSize}size ${TermSize}${endif} 125 }set term wxt size ${TermSize} 126 ${endif}${endif Term} 128 set datafile separator ",;" 130 ####---------Data-------------------------------- 131 $RunData << _End_of_Data_ 140 }set xlabel '${Xlabel}' 142 }stats $RunData using (abscissaName=strcol(1)) every ::0::0 nooutput 144 set xlabel abscissaName 147 }set ylabel '${Ylabel}' ${end if Ylabel 150 set xrange [${Xrange}] ${endif 152 set yrange [${Yrange}] ${endif 153 }set key autotitle columnheader tmargin 157 const string GNUPLOT_SIMPLE_DATA_PLOT = R
"~(# 158 ####--------------------------------------------- 159 plot for [i=2:*] $RunData using 1:i with ${DiagramKind} linestyle i-1 164 const string GNUPLOT_SCATTER_REGRESSION = R
"~(# 165 stats $RunData using 1:2 nooutput 168 }# regression line function (given as parameter) 169 regLine(x) = ${RegrSlope} * x + ${RegrSocket} 171 }# regression line function derived from data 172 regLine(x) = STATS_slope * x + STATS_intercept 175 regLabel = sprintf("Model: %3.2f·p + %3.2f", STATS_slope, STATS_intercept) 177 set key horizontal width -4 180 ${else}${if Xrange}${else 183 ${end if}${end if Xtics 185 plots = STATS_columns - 1 186 # Adjust layout based on number of data sequences; 187 # additional sequences placed into secondary diagram 190 set multiplot layout 2,1 # 2 rows 1 column 191 set lmargin at screen 0.12 # fixed margins to align diagrams 192 set rmargin at screen 0.88 196 ####---------Scatter-Regression-Plot------------- 197 plot $RunData using 1:2 with points linestyle 1, \ 198 regLine(x) with line linestyle 9 title regLabel 201 # switch off decorations for secondary diagram 205 set key bmargin vertical 207 set yrange [${Y2range}] 212 } set ylabel '${Y2label}' ${endif 215 ####--------------------------------- 216 plot $RunData using 1:3 with impulses linestyle 3 219 # more than one additional data sequence 222 } set y2range [${Y3range}] 227 } set y2label '${Y3label}' offset -1.5 229 ####--------------------------------------------- 230 plot $RunData using 1:3 with impulses linestyle 3, \ 231 for [i=4:*] $RunData using 1:i with points linestyle 5+(i-4) axes x1y2 253 +GNUPLOT_SIMPLE_DATA_PLOT};
255 params.set (
"CommonStyleDef", GNUPLOT_CommonStyleDef)
256 .set (
"AxisGridSetup", GNUPLOT_AxisGridSetup)
257 .set (KEY_DiagramKind,
"points")
259 return plot.render (params.genNode());
277 +GNUPLOT_SCATTER_REGRESSION};
279 params.set (
"CommonStyleDef", GNUPLOT_CommonStyleDef)
280 .set (
"AxisGridSetup", GNUPLOT_AxisGridSetup)
282 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.