Commit 12b3b65c1613cb281d49af63a92c652e4d95e505

Authored by Scott Klum
1 parent 328f1682

Legend works without specifying position

Showing 1 changed file with 4 additions and 2 deletions
openbr/core/plot.cpp
... ... @@ -220,7 +220,9 @@ bool Plot(const QStringList &files, const File &destination, bool show)
220 220  
221 221 const bool minimalist = destination.getBool("minimalist");
222 222 const QString title = destination.get<QString>("title", QString());
223   - const QString legendPosition = QtUtils::toString(destination.get<QPointF>("legendPosition",QPointF()));
  223 + const QPointF legendPoint = destination.get<QPointF>("legendPosition",QPointF());
  224 + const QString legendPosition = legendPoint.isNull() ? "'right'" : "c" + QtUtils::toString(legendPoint);
  225 + qDebug() << legendPosition;
224 226  
225 227 RPlot p(files, destination);
226 228  
... ... @@ -252,7 +254,7 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show)
252 254 (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") +
253 255 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
254 256 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
255   - QString(" + theme_minimal() + theme(legend.position=c%1) + theme(legend.background = element_rect(fill = 'white')) + theme(panel.grid.major = element_line(colour = \"gray\")) + theme(panel.grid.minor = element_line(colour = \"gray\", linetype = \"dashed\")) + scale_y_continuous(labels=percent)\n\n").arg(legendPosition)));
  257 + QString(" + theme_minimal() + theme(legend.position=%1) + theme(legend.background = element_rect(fill = 'white')) + theme(panel.grid.major = element_line(colour = \"gray\")) + theme(panel.grid.minor = element_line(colour = \"gray\", linetype = \"dashed\")) + scale_y_continuous(labels=percent)\n\n").arg(legendPosition)));
256 258  
257 259 p.file.write(qPrintable(QString("qplot(factor(%1)%2, data=BC, %3").arg(p.major.smooth ? (p.minor.header.isEmpty() ? "Algorithm" : p.minor.header) : p.major.header, (p.major.smooth || p.minor.smooth) ? ", Y" : "", (p.major.smooth || p.minor.smooth) ? "geom=\"boxplot\"" : "geom=\"bar\", position=\"dodge\", weight=Y") +
258 260 (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) +
... ...