Skip to content

Commit

Permalink
Merge pull request #596 from biometrics/ploting_fixes
Browse files Browse the repository at this point in the history
update to support new versions of R
  • Loading branch information
bhklein authored Jul 18, 2023
2 parents 323bbee + 8c82491 commit 266029e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions openbr/core/plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ bool Plot(const QStringList &files, const File &destination, bool show)
// Use a br::file for simple storage of plot options
QMap<QString,File> optMap;
optMap.insert("rocOptions", File(QString("[xTitle=False Accept Rate,yTitle=True Accept Rate,xLog=true,yLog=false,xLimits=(.0000001,.1)]")));
optMap.insert("detOptions", File(QString("[xTitle=False Accept Rate,yTitle=False Reject Rate,xLog=true,yLog=true,xLimits=(.0000001,.1),yLimits=(.0001,1)]")));
optMap.insert("detOptions", File(QString("[xTitle=False Accept Rate,yTitle=False Reject Rate,xLog=true,yLog=true,xLimits=(.0000001,.1),yLimits=(.00001,1)]")));
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=(1,5,10,50,100),xBreaks=(1,5,10,50,100)]")));
optMap.insert("farOptions", File(QString("[xTitle=Score,yTitle=False Accept Rate,xLog=false,yLog=true,xLabels=waiver(),yLimits=(.0000001,1)]")));
optMap.insert("frrOptions", File(QString("[xTitle=Score,yTitle=False Reject Rate,xLog=false,yLog=true,xLabels=waiver(),yLimits=(.0001,1)]")));
optMap.insert("frrOptions", File(QString("[xTitle=Score,yTitle=False Reject Rate,xLog=false,yLog=true,xLabels=waiver(),yLimits=(.00001,1)]")));

foreach (const QString &key, optMap.keys()) {
const QStringList options = destination.get<QStringList>(key, QStringList());
Expand Down Expand Up @@ -393,7 +393,7 @@ bool PlotEER(const QStringList &files, const File &destination, bool show)
optMap.insert("rocOptions", File(QString("[xTitle=False Accept Rate,yTitle=True Accept Rate,xLog=true,yLog=false,xLimits=(.0000001,.1)]")));
optMap.insert("detOptions", File(QString("[xTitle=False Accept Rate,yTitle=False Reject Rate,xLog=true,yLog=true,xLimits=(.0000001,.1),yLimits=(.0001,1)]")));
optMap.insert("farOptions", File(QString("[xTitle=Score,yTitle=False Accept Rate,xLog=false,yLog=true,xLabels=waiver(),yLimits=(.0000001,1)]")));
optMap.insert("frrOptions", File(QString("[xTitle=Score,yTitle=False Reject Rate,xLog=false,yLog=true,xLabels=waiver(),yLimits=(.0001,1)]")));
optMap.insert("frrOptions", File(QString("[xTitle=Score,yTitle=False Reject Rate,xLog=false,yLog=true,xLabels=waiver(),yLimits=(.00001,1)]")));

foreach (const QString &key, optMap.keys()) {
const QStringList options = destination.get<QStringList>(key, QStringList());
Expand Down
12 changes: 4 additions & 8 deletions share/openbr/plotting/plot_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ library("grid")
# Code to format FAR values
far_names <- list('0.0001'="FAR = 0.01%", '0.001'="FAR = 0.1%", '0.01'="FAR = 1%")
far_labeller <- function(variable,value) {
if (as.character(value) %in% names(far_names)) {
return(far_names[as.character(value)])
} else {
return(as.character(value))
}
return(as.character(value))
}

getScale <- function(mode, title, vals) {
Expand Down Expand Up @@ -124,7 +120,7 @@ plotLine <- function(lineData=NULL, options=NULL, flipY=FALSE, geometry="path")
}

plotSD <- function(sdData=NULL) {
p <- qplot(X, data=sdData, geom="histogram", fill=Y, position="identity", alpha=I(1/2), xlab="Score", ylab="Frequency")
p <- qplot(X, data=sdData, geom="histogram", fill=Y, alpha=I(1/2), xlab="Score", ylab="Frequency")
p <- p + scale_fill_manual("Ground Truth", values=c("blue", "red")) + theme_minimal() + scale_x_continuous(minor_breaks=NULL) + scale_y_continuous(minor_breaks=NULL) + theme(axis.text.y=element_blank(), axis.ticks=element_blank(), axis.text.x=element_text(angle=-90, hjust=0))
if (majorSize > 1) {
if (minorSize > 1) {
Expand All @@ -146,7 +142,7 @@ plotSD <- function(sdData=NULL) {

plotBC <- function(bcData=NULL) {
factor <- if (majorSmooth) minorHeader else majorHeader
plotString <- paste("qplot(factor(", factor, ")", if(smooth) ", Y" else "", ", data=bcData, ", if(smooth) "geom=\"boxplot\"" else "geom=\"bar\", position=\"dodge\", weight=Y", sep="")
plotString <- paste("qplot(factor(", factor, ")", if(smooth) ", Y" else "", ", data=bcData, ", if(smooth) "geom=\"boxplot\"" else "geom=\"bar\", weight=Y", sep="")
p <- eval(parse(text=paste(plotString, if(majorSize > 1) paste(", fill=factor(", majorHeader, ")", sep="") else "", ", xlab=\"False Accept Rate\", ylab=\"True Accept Rate\") + theme_minimal()", sep="")))
if (majorSize > 1) p <- p + getScale("fill", majorHeader, majorSize)
if (minorSize > 1) p <- p + facet_grid(facets=as.formula(paste(minorHeader, "~", "X")), labeller=far_labeller) else p <- p + facet_grid(. ~ X, labeller=far_labeller)
Expand All @@ -156,7 +152,7 @@ plotBC <- function(bcData=NULL) {
}

plotOverlap <- function(overlapData=NULL) {
p <- qplot(X, data=overlapData, geom="histogram", position="identity", xlab="Overlap", ylab="Frequency")
p <- qplot(X, data=overlapData, geom="histogram", xlab="Overlap", ylab="Frequency")
p <- p + theme_minimal() + scale_x_continuous(minor_breaks=NULL) + scale_y_continuous(minor_breaks=NULL) + theme(axis.text.y=element_blank(), axis.ticks=element_blank(), axis.text.x=element_text(angle=-90, hjust=0))
if (majorSize > 1) {
if (minorSize > 1) {
Expand Down

0 comments on commit 266029e

Please sign in to comment.