Commit 328f1682932adc42cf1030d8d94915cf07ec3ddb
1 parent
df39c436
Added title and legend position options to CMC plots
Showing
1 changed file
with
4 additions
and
2 deletions
openbr/core/plot.cpp
| @@ -219,6 +219,8 @@ bool Plot(const QStringList &files, const File &destination, bool show) | @@ -219,6 +219,8 @@ bool Plot(const QStringList &files, const File &destination, bool show) | ||
| 219 | qDebug("Plotting %d file(s) to %s", files.size(), qPrintable(destination)); | 219 | qDebug("Plotting %d file(s) to %s", files.size(), qPrintable(destination)); |
| 220 | 220 | ||
| 221 | const bool minimalist = destination.getBool("minimalist"); | 221 | const bool minimalist = destination.getBool("minimalist"); |
| 222 | + const QString title = destination.get<QString>("title", QString()); | ||
| 223 | + const QString legendPosition = QtUtils::toString(destination.get<QPointF>("legendPosition",QPointF())); | ||
| 222 | 224 | ||
| 223 | RPlot p(files, destination); | 225 | RPlot p(files, destination); |
| 224 | 226 | ||
| @@ -245,12 +247,12 @@ bool Plot(const QStringList &files, const File &destination, bool show) | @@ -245,12 +247,12 @@ bool Plot(const QStringList &files, const File &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()) + | 247 | (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"))); | 248 | QString(" + theme(aspect.ratio=1)\n\n"))); |
| 247 | 249 | ||
| 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()) + | 250 | + 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(), title) + |
| 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()") + | 251 | ((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()") + |
| 250 | (minimalist ? "" : " + scale_x_log10(labels=c(1,5,10,50,100), breaks=c(1,5,10,50,100)) + annotation_logticks(sides=\"b\")") + | 252 | (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()) + | 253 | (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()) + | 254 | (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"))); | 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))); |
| 254 | 256 | ||
| 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") + | 257 | 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()) + | 258 | (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + |