Commit 42f68f339aded1be0f4cfe10b01883a2de7b61aa
1 parent
30f8fe2e
Added rocOption plotting functionality
Showing
1 changed file
with
15 additions
and
2 deletions
openbr/core/plot.cpp
| @@ -229,15 +229,28 @@ bool Plot(const QStringList &files, const File &destination, bool show) | @@ -229,15 +229,28 @@ bool Plot(const QStringList &files, const File &destination, bool show) | ||
| 229 | cmcOpts.set(words[0],words[1]); | 229 | cmcOpts.set(words[0],words[1]); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | + File rocOpts; | ||
| 233 | + const QStringList rocOptions = destination.get<QStringList>("rocOptions", QStringList()); | ||
| 234 | + foreach (const QString& option, rocOptions) { | ||
| 235 | + QStringList words = QtUtils::parse(option, '='); | ||
| 236 | + QtUtils::checkArgsSize(words[0],words,1,2); | ||
| 237 | + rocOpts.set(words[0],words[1]); | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + | ||
| 232 | RPlot p(files, destination); | 241 | RPlot p(files, destination); |
| 233 | 242 | ||
| 234 | - p.file.write(qPrintable(QString("qplot(X, 1-Y, data=DET%1").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") + | 243 | + p.file.write(qPrintable(QString("qplot(X, 1-Y, data=DET%1, main=\"%2\"").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"", rocOpts.get<QString>("title",QString())) + |
| 235 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | 244 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| 236 | (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + | 245 | (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + |
| 237 | QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + | 246 | QString(", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()") + |
| 238 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | 247 | (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + |
| 239 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | 248 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 240 | - QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format())) + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\")\n\n"))); | 249 | + QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format()))") + |
| 250 | + (rocOpts.contains("yLimits") ? QString(" + scale_y_continuous(labels=percent, limits=%3)").arg("c"+QtUtils::toString(rocOpts.get<QPointF>("yLimits",QPointF()))) : QString(" + scale_y_continuous(labels=percent)")) + | ||
| 251 | + QString(" + annotation_logticks(sides=\"b\")") + | ||
| 252 | + QString(" + theme(legend.title = element_text(size = %1), plot.title = element_text(size = %1), axis.text = element_text(size = %1), axis.title.x = element_text(size = %1), axis.title.y = element_text(size = %1)," | ||
| 253 | + " legend.position=%2, legend.background = element_rect(fill = 'white'), panel.grid.major = element_line(colour = \"gray\"), panel.grid.minor = element_line(colour = \"gray\", linetype = \"dashed\"), legend.text = element_text(size = %1))\n\n").arg(QString::number(rocOpts.get<float>("textSize",12)), rocOpts.contains("legendPosition") ? "c"+QtUtils::toString(rocOpts.get<QPointF>("legendPosition")) : "'right'"))); | ||
| 241 | 254 | ||
| 242 | p.file.write(qPrintable(QString("qplot(X, Y, data=DET%1").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") + | 255 | p.file.write(qPrintable(QString("qplot(X, Y, data=DET%1").arg((p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") + |
| 243 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | 256 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |