Skip to content

Commit 349a68c

Browse files
lorenzhsByteHamster
authored andcommitted
Add "|attrplus" modifier to use \addplot+[attr] instead of \addplot[attr]
1 parent ccda1ad commit 349a68c

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/latex.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
204204
std::for_each(groupfields.begin(), groupfields.end(), trim_inplace_ws);
205205

206206
bool attr_mark = false;
207+
bool attrplus_mark = false;
207208
bool title_mark = false;
208209
bool ptitle_mark = false;
209210
bool xerr = false, yerr = false;
@@ -227,7 +228,15 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
227228
field.resize(field.size() - 5);
228229
multiplot.resize(multiplot.size() - 5);
229230
attr_mark = true;
230-
} else{
231+
}
232+
else if (!groupfields.empty() && is_suffix(field, "|attrplus")) {
233+
// remove |attrplus from multiplot string
234+
field.resize(field.size() - 9);
235+
multiplot.resize(multiplot.size() - 9);
236+
attr_mark = true;
237+
attrplus_mark = true;
238+
}
239+
else {
231240
std::string modifier = field.substr(field.find('|'));
232241
OUT_THROW("MULTIPLOT failed: unknown modifier '" + modifier + "'");
233242
}
@@ -395,7 +404,10 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
395404
{
396405
if (attr_mark) {
397406
// can't copy styles when an attribute is being selected
398-
out << "\\addplot[" << attrlist[entry] << "] coordinates { "
407+
out << "\\addplot";
408+
if (attrplus_mark)
409+
out << "+";
410+
out << "[" << attrlist[entry] << "] coordinates {"
399411
<< coordlist[entry] << " " << rm[2] << std::endl;
400412
} else {
401413
out << rm[1] << coordlist[entry] << " " << rm[2] << std::endl;
@@ -435,12 +447,16 @@ void SpLatex::multiplot(size_t ln, size_t indent, const std::string& cmdline)
435447
// append missing \addplot / \addlegendentry pairs
436448
while (entry < coordlist.size())
437449
{
438-
if (attr_mark)
439-
out << "\\addplot[" << attrlist[entry] << "] coordinates {"
450+
if (attr_mark) {
451+
out << "\\addplot";
452+
if (attrplus_mark)
453+
out << "+";
454+
out << "[" << attrlist[entry] << "] coordinates {"
440455
<< coordlist[entry] << " };" << std::endl;
441-
else
456+
} else {
442457
out << "\\addplot coordinates {" << coordlist[entry]
443458
<< " };" << std::endl;
459+
}
444460

445461
out << "\\addlegendentry{" << legendlist[entry]
446462
<< "};" << std::endl;

0 commit comments

Comments
 (0)