@@ -72,14 +72,17 @@ class SpGnuplot
7272 // ! Process # CONNECT commands
7373 bool connect (size_t ln, size_t indent, const std::string& cmdline);
7474
75- // ! Struct to rewrite Gnuplot "plot" directives with new datafile/index pairs
75+ // ! Struct to rewrite Gnuplot "plot" directives with new datafile/index
76+ // ! pairs
7677 struct Dataset
7778 {
7879 unsigned int index;
7980 std::string title;
81+ std::string type;
8082 };
8183
82- // ! Helper to rewrite Gnuplot "plot" directives with new datafile/index pairs
84+ // ! Helper to rewrite Gnuplot "plot" directives with new datafile/index
85+ // ! pairs
8386 void plot_rewrite (size_t ln, size_t indent,
8487 const std::vector<Dataset>& datasets,
8588 const char * plot_type);
@@ -157,7 +160,7 @@ void SpGnuplot::plot_rewrite(size_t ln, size_t indent,
157160 if (datasets[i].title .size ())
158161 oss << " title \" " << datasets[i].title << ' "' ;
159162
160- oss << " with linespoints " ;
163+ oss << " with " << datasets[i]. type ;
161164 }
162165
163166 if (datasets.size ())
@@ -217,7 +220,7 @@ void SpGnuplot::plot_rewrite(size_t ln, size_t indent,
217220 if (datasets[entry].title .size ())
218221 oss << " title \" " << datasets[entry].title << ' "' ;
219222
220- oss << " with linespoints " ;
223+ oss << " with " << datasets[entry]. type ;
221224
222225 ++entry;
223226 }
@@ -254,6 +257,7 @@ void SpGnuplot::plot(size_t ln, size_t indent, const std::string& cmdline)
254257 // append plot line to gnuplot
255258 std::vector<Dataset> datasets (1 );
256259 datasets[0 ].index = m_dataindex;
260+ datasets[0 ].type = " linespoints" ;
257261
258262 // finish index in datafile
259263 df << std::endl << std::endl;
@@ -296,7 +300,15 @@ void SpGnuplot::multiplot(size_t ln, size_t indent, const std::string& cmdline)
296300 if (!sql->exist_col (" y" ))
297301 OUT_THROW (" MULTIPLOT failed: result contains no 'y' column." );
298302
299- unsigned int colx = sql->find_col (" x" ), coly = sql->find_col (" y" );
303+ unsigned int col_x = sql->find_col (" x" ), col_y = sql->find_col (" y" );
304+
305+ int col_xmin = !sql->exist_col (" xmin" ) ? -1 : sql->find_col (" xmin" );
306+ int col_xmax = !sql->exist_col (" xmax" ) ? -1 : sql->find_col (" xmax" );
307+ int col_ymin = !sql->exist_col (" ymin" ) ? -1 : sql->find_col (" ymin" );
308+ int col_ymax = !sql->exist_col (" ymax" ) ? -1 : sql->find_col (" ymax" );
309+
310+ bool have_xerrorbars = col_xmin >= 0 && col_xmax >= 0 ;
311+ bool have_yerrorbars = col_ymin >= 0 && col_ymax >= 0 ;
300312
301313 // check existance of group fields and save ids
302314 std::vector<int > groupcols;
@@ -350,13 +362,32 @@ void SpGnuplot::multiplot(size_t ln, size_t indent, const std::string& cmdline)
350362 datasets.push_back (Dataset ());
351363 datasets.back ().index = m_dataindex;
352364 datasets.back ().title = os.str ();
365+ datasets.back ().type = " linespoints" ;
366+
367+ if (have_xerrorbars && have_yerrorbars)
368+ datasets.back ().type = " xyerrorbars" ;
369+ else if (have_xerrorbars)
370+ datasets.back ().type = " xerrorbars" ;
371+ else if (have_yerrorbars)
372+ datasets.back ().type = " yerrorbars" ;
353373
354374 df << " # index " << m_dataindex << ' ' << os.str () << std::endl;
355375 }
356376
357377 // group fields match with last row -> append coordinates.
358- df << sql->text (colx) << ' \t '
359- << sql->text (coly) << std::endl;
378+ df << sql->text (col_x)
379+ << ' \t ' << sql->text (col_y);
380+
381+ if (have_xerrorbars) {
382+ df << ' \t ' << sql->text (col_xmin)
383+ << ' \t ' << sql->text (col_xmax);
384+ }
385+ if (have_yerrorbars) {
386+ df << ' \t ' << sql->text (col_ymin)
387+ << ' \t ' << sql->text (col_ymax);
388+ }
389+
390+ df << std::endl;
360391
361392 ++rows;
362393 }
0 commit comments