From abe33c8eba21e6dc4ceeb468fe9319a3d7d5a17b Mon Sep 17 00:00:00 2001 From: Ben Klein Date: Wed, 8 Jul 2015 22:29:29 -0400 Subject: [PATCH] updated docs with plotting example --- docs/docs/api_docs/c_api/functions.md | 15 ++++++++++----- openbr/core/plot.cpp | 14 +++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/docs/api_docs/c_api/functions.md b/docs/docs/api_docs/c_api/functions.md index 5abaa22..d9f241b 100644 --- a/docs/docs/api_docs/c_api/functions.md +++ b/docs/docs/api_docs/c_api/functions.md @@ -630,13 +630,18 @@ Key | Value | Description --- | ---- | ----------- title | [QString] | Plot title size | float | Line width -legendPosition | [QPointF] | Legend coordinates on plot +legendPosition | [QPointF] | Legend coordinates on plot, ex. legendPosition=(X,Y) textSize | float | Size of text for title, legend and axes -xLab/yLab | [QString] | Label for x/y axis +xTitle/yTitle | [QString] | Title for x/y axis xLog/yLog | bool | Plot log scale for x/y axis -xLimits/yLimits | [QPointF] | Set x/y axis limits -xLabels/yLabels | [QString] | Labels for ticks on x/y axis -xBreaks/yBreaks | [QString] | Specify breaks/ticks on x/y axis +xLimits/yLimits | [QPointF] | Set x/y axis limits, ex. xLimits=(lower,upper) +xLabels/yLabels | [QString] | Labels for ticks on x/y axis, ex. xLabeles=percent or xLabels=c(1,5,10) +xBreaks/yBreaks | [QString] | Specify breaks/ticks on x/y axis, ex. xBreaks=pretty_breaks(n=10) or xBreaks=c(1,5,10) + +If specifying plot options it is a good idea to wrap the destination file in single quotes to avoid parsing errors. +The example below plots plots the six br_eval results in the Algorithm_Dataset folder described above, sets the number of legend columns and specifies some options for the CMC plot. + +`br -plot Algorithm_Dataset/* 'destination.pdf[ncol=3,cmcOptions=[xLog=false,xLimits=(1,20),xBreaks=pretty_breaks(n=10),xTitle=Ranks 1 through 20]]'` This function requires a current [R][R] installation with the following packages: diff --git a/openbr/core/plot.cpp b/openbr/core/plot.cpp index d85bb6b..862c8d7 100644 --- a/openbr/core/plot.cpp +++ b/openbr/core/plot.cpp @@ -282,7 +282,7 @@ struct RPlot (opts.contains("size") ? QString(", size=I(%1)").arg(opts.get("size")) : QString()) + (major.size > 1 ? QString(", colour=factor(%1)").arg(major.header) : QString()) + (minor.size > 1 ? QString(", linetype=factor(%1)").arg(minor.header) : QString()) + - (QString(", xlab=\"%1\", ylab=\"%2\") + theme_minimal()").arg(opts.get("xLab"), opts.get("yLab"))) + + (QString(", xlab=\"%1\", ylab=\"%2\") + theme_minimal()").arg(opts.get("xTitle"), opts.get("yTitle"))) + ((major.smooth || minor.smooth) && confidence != 0 && data != "CMC" ? QString(" + geom_errorbar(data=%1[seq(1, NROW(%1), by = 29),], aes(x=X, ymin=%2), width=0.1, alpha=I(1/2))").arg(data, flipY ? "(1-lower), ymax=(1-upper)" : "lower, ymax=upper") : QString()) + (major.size > 1 ? getScale("colour", major.header, major.size) : QString()) + (minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(minor.header) : QString()) + @@ -318,10 +318,10 @@ bool Plot(const QStringList &files, const File &destination, bool show) // Use a br::file for simple storage of plot options QMap optMap; - optMap.insert("rocOptions", File(QString("[xLab=False Accept Rate,yLab=True Accept Rate,xLog=true,yLog=false]"))); - optMap.insert("detOptions", File(QString("[xLab=False Accept Rate,yLab=False Reject Rate,xLog=true,yLog=true]"))); - optMap.insert("ietOptions", File(QString("[xLab=False Positive Identification Rate (FPIR),yLab=False Negative Identification Rate (FNIR),xLog=true,yLog=true]"))); - optMap.insert("cmcOptions", File(QString("[xLab=Rank,yLab=Retrieval Rate,xLog=true,yLog=false,size=1,xLabels=c(1,5,10,50,100),xBreaks=c(1,5,10,50,100)]"))); + optMap.insert("rocOptions", File(QString("[xTitle=False Accept Rate,yTitle=True Accept Rate,xLog=true,yLog=false]"))); + optMap.insert("detOptions", File(QString("[xTitle=False Accept Rate,yTitle=False Reject Rate,xLog=true,yLog=true]"))); + optMap.insert("ietOptions", File(QString("[xTitle=False Positive Identification Rate (FPIR),yTitle=False Negative Identification Rate (FNIR),xLog=true,yLog=true]"))); + optMap.insert("cmcOptions", File(QString("[xTitle=Rank,yTitle=Retrieval Rate,xLog=true,yLog=false,size=1,xLabels=c(1,5,10,50,100),xBreaks=c(1,5,10,50,100)]"))); foreach (const QString &key, optMap.keys()) { const QStringList options = destination.get(key, QStringList()); @@ -424,8 +424,8 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) // Use a br::file for simple storage of plot options QMap optMap; - optMap.insert("rocOptions", File(QString("[xLab=False Accepts Per Image,yLab=True Accept Rate,xLog=true,yLog=false]"))); - optMap.insert("prOptions", File(QString("[xLab=False Accept Rate,yLab=False Reject Rate,xLog=true,yLog=true]"))); + optMap.insert("rocOptions", File(QString("[xTitle=False Accepts Per Image,yTitle=True Accept Rate,xLog=true,yLog=false]"))); + optMap.insert("prOptions", File(QString("[xTitle=False Accept Rate,yTitle=False Reject Rate,xLog=true,yLog=true]"))); foreach (const QString &key, optMap.keys()) { const QStringList options = destination.get(key, QStringList()); -- libgit2 0.21.4