Skip to content

Commit 4965105

Browse files
authored
Merge pull request #10 from lorenzhs/xerr
latex: Add support for xerr/yerr columns for error plots
2 parents 4e3dd91 + b959e67 commit 4965105

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/latex.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
205205

206206
bool title_mark = false;
207207
bool ptitle_mark = false;
208+
bool xerr = false, yerr = false;
208209

209210
if (!groupfields.empty() && is_suffix(groupfields.back(), "|title")) {
210211
// remove |title from multiplot string
@@ -233,13 +234,21 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
233234
if (!sql->exist_col("y"))
234235
OUT_THROW("MULTIPLOT failed: result contains no 'y' column.");
235236

237+
if (sql->exist_col("xerr"))
238+
xerr = true;
239+
240+
if (sql->exist_col("yerr"))
241+
yerr = true;
242+
236243
if (title_mark && !sql->exist_col("title"))
237244
OUT_THROW("MULTIPLOT failed: title mark set but result contains no 'title' column.");
238245

239246
if (ptitle_mark && !sql->exist_col("ptitle"))
240247
OUT_THROW("MULTIPLOT failed: ptitle mark set but result contains no 'ptitle' column.");
241248

242-
unsigned int col_x = sql->find_col("x"), col_y = sql->find_col("y");
249+
unsigned int col_x = sql->find_col("x"), col_y = sql->find_col("y"),
250+
col_xerr = xerr ? sql->find_col("xerr") : -1,
251+
col_yerr = yerr ? sql->find_col("yerr") : -1;
243252

244253
unsigned int col_title = 0;
245254
if (title_mark)
@@ -319,6 +328,11 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
319328
coord << " (" << str_reduce(sql->text(col_x))
320329
<< ',' << str_reduce(sql->text(col_y))
321330
<< ')';
331+
if (xerr || yerr) {
332+
coord << " +- (" << (xerr ? str_reduce(sql->text(col_xerr)) : "0")
333+
<< ',' << (yerr ? str_reduce(sql->text(col_yerr)) : "0")
334+
<< ')';
335+
}
322336
}
323337

324338
// store last coordates group

0 commit comments

Comments
 (0)