Commit 87dae42d2b56e24dedc79f9ffa525e6bc48908f9
Committed by
Scott Klum
1 parent
d6832ad6
Fix display of tables in the case of multiple alg/splits without smoothing
Showing
1 changed file
with
8 additions
and
9 deletions
openbr/core/plot.cpp
| ... | ... | @@ -187,7 +187,7 @@ struct RPlot |
| 187 | 187 | "TS$Y <- as.character(TS$Y)\n" |
| 188 | 188 | "CMC$Y <- as.numeric(as.character(CMC$Y))\n" |
| 189 | 189 | "\n" |
| 190 | - "if (%1) {\n\tsummarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE, conf.interval=%6, .drop=TRUE) {\n\t\t" | |
| 190 | + "if (%1) {\n\tsummarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE, conf.interval=%7, .drop=TRUE) {\n\t\t" | |
| 191 | 191 | "require(plyr)\n\n\t\tlength2 <- function (x, na.rm=FALSE) {\n\t\t\tif (na.rm) sum(!is.na(x))\n\t\t\telse length(x)" |
| 192 | 192 | "\n\t\t}\n\n\t\tdatac <- ddply(data, groupvars, .drop=.drop, .fun = function(xx, col) {\n\t\t\t" |
| 193 | 193 | "c(N=length2(xx[[col]], na.rm=na.rm), mean=mean(xx[[col]], na.rm=na.rm), sd=sd(xx[[col]], na.rm=na.rm))\n\t\t\t}," |
| ... | ... | @@ -204,7 +204,7 @@ struct RPlot |
| 204 | 204 | "far_labeller <- function(variable,value) { return(far_names[as.character(value)]) }\n" |
| 205 | 205 | "\n" |
| 206 | 206 | "# Code to format TAR@FAR table\n" |
| 207 | - "algs <- unique(TF$%2)\n" | |
| 207 | + "algs <- unique(%6)\n" | |
| 208 | 208 | "algs <- algs[!duplicated(algs)]\n" |
| 209 | 209 | "mat <- matrix(%3,nrow=6,ncol=length(algs),byrow=FALSE)\n" |
| 210 | 210 | "colnames(mat) <- algs \n" |
| ... | ... | @@ -212,8 +212,6 @@ struct RPlot |
| 212 | 212 | "FTtable <- as.table(mat)\n" |
| 213 | 213 | "\n" |
| 214 | 214 | "# Code to format FAR@TAR table\n" |
| 215 | - "algs <- unique(FT$%2)\n" | |
| 216 | - "algs <- algs[!duplicated(algs)]\n" | |
| 217 | 215 | "mat <- matrix(%4,nrow=6,ncol=length(algs),byrow=FALSE)\n" |
| 218 | 216 | "colnames(mat) <- algs \n" |
| 219 | 217 | "rownames(mat) <- c(\"TAR = 0.40\", \"TAR = 0.50\", \"TAR = 0.65\", \"TAR = 0.75\", \"TAR = 0.85\", \"TAR = 0.95\")\n" |
| ... | ... | @@ -234,8 +232,9 @@ struct RPlot |
| 234 | 232 | (major.smooth || minor.smooth) && confidence != 0 ? "paste(as.character(round(TF$Y, 3)), round(TF$ci, 3), sep=\"\\u00b1\")" : "TF$Y", |
| 235 | 233 | (major.smooth || minor.smooth) && confidence != 0 ? "paste(as.character(round(FT$Y, 3)), round(FT$ci, 3), sep=\"\\u00b1\")" : "FT$Y", |
| 236 | 234 | (major.smooth || minor.smooth) && confidence != 0 ? "paste(as.character(round(CT$Y, 3)), round(CT$ci, 3), sep=\"\\u00b1\")" : "CT$Y", |
| 235 | + (major.size > 1 && minor.size > 1) && !(major.smooth || minor.smooth) ? QString("paste(TF$%1, TF$%2, sep=\"_\")").arg(major.header, minor.header) : QString("TF$%1").arg(major.size > 1 ? major.header : (minor.header.isEmpty() ? major.header : minor.header)), | |
| 237 | 236 | QString::number(confidence)))); |
| 238 | - | |
| 237 | + | |
| 239 | 238 | // Open output device |
| 240 | 239 | file.write(qPrintable(QString("\n" |
| 241 | 240 | "# Open output device\n" |
| ... | ... | @@ -331,7 +330,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 331 | 330 | QString(" + annotation_logticks(sides=\"b\")") + |
| 332 | 331 | 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)," |
| 333 | 332 | " 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))").arg(QString::number(rocOpts.get<float>("textSize",12)), rocOpts.contains("legendPosition") ? "c"+QtUtils::toString(rocOpts.get<QPointF>("legendPosition")) : "'bottom'") + |
| 334 | - QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<QString>("ncol", QString("length(algs)"))))); | |
| 333 | + QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<int>("ncol", p.major.size > 1 ? p.major.size : (p.minor.header.isEmpty() ? p.major.size : p.minor.size))))); | |
| 335 | 334 | |
| 336 | 335 | p.file.write(qPrintable(QString("qplot(X, Y, data=DET, geom=\"line\"") + |
| 337 | 336 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| ... | ... | @@ -343,7 +342,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 343 | 342 | 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)," |
| 344 | 343 | " 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))").arg(QString::number(rocOpts.get<float>("textSize",12)), rocOpts.contains("legendPosition") ? "c"+QtUtils::toString(rocOpts.get<QPointF>("legendPosition")) : "'bottom'") + |
| 345 | 344 | QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format())) + scale_y_log10(labels=trans_format(\"log10\", math_format())) + annotation_logticks()") + |
| 346 | - QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<QString>("ncol", QString("length(algs)"))))); | |
| 345 | + QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<int>("ncol", p.major.size > 1 ? p.major.size : (p.minor.header.isEmpty() ? p.major.size : p.minor.size))))); | |
| 347 | 346 | |
| 348 | 347 | p.file.write(qPrintable(QString("qplot(X, Y, data=IET, geom=\"line\"") + |
| 349 | 348 | (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + |
| ... | ... | @@ -355,7 +354,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 355 | 354 | 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)," |
| 356 | 355 | " 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))").arg(QString::number(rocOpts.get<float>("textSize",12)), rocOpts.contains("legendPosition") ? "c"+QtUtils::toString(rocOpts.get<QPointF>("legendPosition")) : "'bottom'") + |
| 357 | 356 | QString(" + scale_x_log10(labels=trans_format(\"log10\", math_format())) + scale_y_log10(labels=trans_format(\"log10\", math_format())) + annotation_logticks()") + |
| 358 | - QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<QString>("ncol", QString("length(algs)"))))); | |
| 357 | + QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<int>("ncol", p.major.size > 1 ? p.major.size : (p.minor.header.isEmpty() ? p.major.size : p.minor.size))))); | |
| 359 | 358 | |
| 360 | 359 | p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + |
| 361 | 360 | QString(", xlab=\"Score\", ylab=\"Frequency\"") + |
| ... | ... | @@ -372,7 +371,7 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 372 | 371 | (cmcOpts.contains("yLimits") ? QString(" + scale_y_continuous(labels=percent) + coord_cartesian(ylim=%1)").arg("c"+QtUtils::toString(cmcOpts.get<QPointF>("yLimits",QPointF()))) : QString(" + scale_y_continuous(labels=percent)")) + |
| 373 | 372 | 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)," |
| 374 | 373 | " 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))").arg(QString::number(cmcOpts.get<float>("textSize",12)), cmcOpts.contains("legendPosition") ? "c"+QtUtils::toString(cmcOpts.get<QPointF>("legendPosition")) : "'bottom'") + |
| 375 | - QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<QString>("ncol", QString("length(algs)"))))); | |
| 374 | + QString(" + guides(col=guide_legend(ncol=%1))\n\n").arg(destination.get<int>("ncol", p.major.size > 1 ? p.major.size : (p.minor.header.isEmpty() ? p.major.size : p.minor.size))))); | |
| 376 | 375 | |
| 377 | 376 | 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") + |
| 378 | 377 | (p.major.size > 1 ? QString(", fill=factor(%1)").arg(p.major.header) : QString()) + | ... | ... |