Commit 4e02e315da8c21ee616f274a8129030f6ae7ee18

Authored by Brendan Klare
2 parents f45eff41 fd580382

Merge branch 'master' of https://github.com/biometrics/openbr

Showing 1 changed file with 17 additions and 3 deletions
openbr/core/plot.cpp
@@ -220,6 +220,15 @@ bool Plot(const QStringList &files, const File &destination, bool show) @@ -220,6 +220,15 @@ bool Plot(const QStringList &files, const File &destination, bool show)
220 220
221 const bool minimalist = destination.getBool("minimalist"); 221 const bool minimalist = destination.getBool("minimalist");
222 222
  223 + // Use a br::file for simple storage of plot options
  224 + File cmcOpts;
  225 + const QStringList cmcOptions = destination.get<QStringList>("cmcOptions", QStringList());
  226 + foreach (const QString& option, cmcOptions) {
  227 + QStringList words = QtUtils::parse(option, '=');
  228 + QtUtils::checkArgsSize(words[0],words,1,2);
  229 + cmcOpts.set(words[0],words[1]);
  230 + }
  231 +
223 RPlot p(files, destination); 232 RPlot p(files, destination);
224 233
225 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\"") + 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\"") +
@@ -245,12 +254,15 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show) @@ -245,12 +254,15 @@ bool Plot(const QStringList &amp;files, const File &amp;destination, bool show)
245 (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg((p.flip ? p.major.header : p.minor.header), (p.flip ? p.minor.header : p.major.header)) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) + 254 (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg((p.flip ? p.major.header : p.minor.header), (p.flip ? p.minor.header : p.major.header)) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) +
246 QString(" + theme(aspect.ratio=1)\n\n"))); 255 QString(" + theme(aspect.ratio=1)\n\n")));
247 256
248 - p.file.write(qPrintable(QString("ggplot(CMC, aes(x=X, y=Y%1%2)) + xlab(\"Rank\") + ylab(\"Retrieval Rate\")").arg(p.major.size > 1 ? QString(" ,colour=factor(%1)").arg(p.major.header) : QString(), p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) +  
249 - ((p.major.smooth || p.minor.smooth) ? (minimalist ? " + stat_summary(geom=\"line\", fun.y=mean)" : " + stat_summary(geom=\"line\", fun.y=min, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=max, aes(linetype=\"Min/Max\")) + stat_summary(geom=\"line\", fun.y=mean, aes(linetype=\"Mean\")) + scale_linetype_manual(\"Legend\", values=c(\"Mean\"=1, \"Min/Max\"=2))") : " + geom_line()") + 257 + p.file.write(qPrintable(QString("ggplot(CMC, aes(x=X, y=Y%1%2)) + ggtitle(\"%3\") + xlab(\"Rank\") + ylab(\"Retrieval Rate\")").arg(p.major.size > 1 ? QString(" ,colour=factor(%1)").arg(p.major.header) : QString(), p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString(), cmcOpts.get<QString>("title",QString())) +
  258 + QString(((p.major.smooth || p.minor.smooth) ? (minimalist ? " + stat_summary(geom=\"line\", fun.y=mean, size=%1)" : " + stat_summary(geom=\"line\", fun.y=min, aes(linetype=\"Min/Max\"), size=%1) + stat_summary(geom=\"line\", "
  259 + "fun.y=max, aes(linetype=\"Min/Max\"), size=%1) + stat_summary(geom=\"line\", fun.y=mean, aes(linetype=\"Mean\"), size=%1) + scale_linetype_manual(\"Legend\", values=c(\"Mean\"=1, \"Min/Max\"=2))") : " + geom_line(size=%1)")).arg(QString::number(cmcOpts.get<float>("thickness",1))) +
250 (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") + 260 (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") +
251 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + 261 (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) +
252 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + 262 (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) +
253 - QString(" + theme_minimal() + scale_y_continuous(labels=percent)\n\n"))); 263 + (cmcOpts.contains("yLimits") ? QString(" + scale_y_continuous(labels=percent, limits=%3)").arg("c"+QtUtils::toString(cmcOpts.get<QPointF>("yLimits",QPointF()))) : QString(" + scale_y_continuous(labels=percent)")) +
  264 + QString(" + theme_minimal() + 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),"
  265 + " 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(cmcOpts.get<float>("textSize",12)), cmcOpts.contains("legendPosition") ? "c"+QtUtils::toString(cmcOpts.get<QPointF>("legendPosition")) : "'right'")));
254 266
255 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") + 267 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") +
256 (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + 268 (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) +
@@ -299,6 +311,8 @@ bool filesHaveSinglePoint(const QStringList &amp;files) { @@ -299,6 +311,8 @@ bool filesHaveSinglePoint(const QStringList &amp;files) {
299 return false; 311 return false;
300 } 312 }
301 313
  314 +// Properly
  315 +
302 bool PlotDetection(const QStringList &files, const File &destination, bool show) 316 bool PlotDetection(const QStringList &files, const File &destination, bool show)
303 { 317 {
304 qDebug("Plotting %d detection file(s) to %s", files.size(), qPrintable(destination)); 318 qDebug("Plotting %d detection file(s) to %s", files.size(), qPrintable(destination));