Commit 33dd7d19f14fed32df049822127faed86f4e4f73
1 parent
3f534073
Bug fix
Showing
1 changed file
with
23 additions
and
25 deletions
openbr/core/plot.cpp
| ... | ... | @@ -123,10 +123,28 @@ struct RPlot |
| 123 | 123 | } |
| 124 | 124 | file.write("data <- rbind(data, tmp)\n"); |
| 125 | 125 | } |
| 126 | + for (int i=0; i<pivotItems.size(); i++) { | |
| 127 | + const int size = pivotItems[i].size(); | |
| 128 | + if (size > major.size) { | |
| 129 | + minor = major; | |
| 130 | + major = Pivot(i, size, pivotHeaders[i]); | |
| 131 | + } else if (size > minor.size) { | |
| 132 | + minor = Pivot(i, size, pivotHeaders[i]); | |
| 133 | + } | |
| 134 | + } | |
| 135 | + | |
| 136 | + const QString &smooth = destination.get<QString>("smooth", ""); | |
| 137 | + major.smooth = !smooth.isEmpty() && (major.header == smooth) && (major.size > 1); | |
| 138 | + minor.smooth = !smooth.isEmpty() && (minor.header == smooth) && (minor.size > 1); | |
| 139 | + if (major.smooth) major.size = 1; | |
| 140 | + if (minor.smooth) minor.size = 1; | |
| 141 | + if (major.size < minor.size) | |
| 142 | + std::swap(major, minor); | |
| 126 | 143 | |
| 144 | + flip = minor.header == "Algorithm"; | |
| 127 | 145 | // Format data |
| 128 | 146 | if (isEvalFormat) |
| 129 | - file.write("\n" | |
| 147 | + file.write(qPrintable(QString("\n" | |
| 130 | 148 | "# Split data into individual plots\n" |
| 131 | 149 | "plot_index = which(names(data)==\"Plot\")\n" |
| 132 | 150 | "Metadata <- data[grep(\"Metadata\",data$Plot),-c(1)]\n" |
| ... | ... | @@ -158,7 +176,7 @@ struct RPlot |
| 158 | 176 | "far_labeller <- function(variable,value) { return(far_names[as.character(value)]) }\n" |
| 159 | 177 | "\n" |
| 160 | 178 | "# Code to format TAR@FAR table\n" |
| 161 | - "algs <- unique(FT$.)\n" | |
| 179 | + "algs <- unique(FT$%1)\n" | |
| 162 | 180 | "algs <- algs[!duplicated(algs)]\n" |
| 163 | 181 | "mat <- matrix(FT$Y,nrow=6,ncol=length(algs),byrow=FALSE)\n" |
| 164 | 182 | "colnames(mat) <- algs \n" |
| ... | ... | @@ -169,7 +187,7 @@ struct RPlot |
| 169 | 187 | "mat <- matrix(CT$Y,nrow=6,ncol=length(algs),byrow=FALSE)\n" |
| 170 | 188 | "colnames(mat) <- algs \n" |
| 171 | 189 | "rownames(mat) <- c(\" Rank 1\", \"Rank 5\", \"Rank 10\", \"Rank 20\", \"Rank 50\", \"Rank 100\")\n" |
| 172 | - "CMCtable <- as.table(mat)\n"); | |
| 190 | + "CMCtable <- as.table(mat)\n").arg(major.header))); | |
| 173 | 191 | |
| 174 | 192 | // Open output device |
| 175 | 193 | file.write(qPrintable(QString("\n" |
| ... | ... | @@ -197,9 +215,9 @@ struct RPlot |
| 197 | 215 | "plot.new()\n" |
| 198 | 216 | "print(title(\"Gallery * Probe = Genuine + Impostor + Ignored\"))\n" |
| 199 | 217 | "plot.new()\n" |
| 200 | - "print(textplot(FTtable,cex=1))\n" | |
| 218 | + "print(textplot(FTtable))\n" | |
| 201 | 219 | "print(title(\"Table of True Accept Rates at various False Accept Rates\"))\n" |
| 202 | - "print(textplot(CMCtable,cex=1))\n" | |
| 220 | + "print(textplot(CMCtable))\n" | |
| 203 | 221 | "print(title(\"Table of retrieval rate at various ranks\"))\n"; |
| 204 | 222 | file.write(qPrintable(textplot.arg(PRODUCT_NAME, PRODUCT_VERSION))); |
| 205 | 223 | } |
| ... | ... | @@ -207,26 +225,6 @@ struct RPlot |
| 207 | 225 | // Write figures |
| 208 | 226 | file.write("\n" |
| 209 | 227 | "# Write figures\n"); |
| 210 | - | |
| 211 | - for (int i=0; i<pivotItems.size(); i++) { | |
| 212 | - const int size = pivotItems[i].size(); | |
| 213 | - if (size > major.size) { | |
| 214 | - minor = major; | |
| 215 | - major = Pivot(i, size, pivotHeaders[i]); | |
| 216 | - } else if (size > minor.size) { | |
| 217 | - minor = Pivot(i, size, pivotHeaders[i]); | |
| 218 | - } | |
| 219 | - } | |
| 220 | - | |
| 221 | - const QString &smooth = destination.get<QString>("smooth", ""); | |
| 222 | - major.smooth = !smooth.isEmpty() && (major.header == smooth) && (major.size > 1); | |
| 223 | - minor.smooth = !smooth.isEmpty() && (minor.header == smooth) && (minor.size > 1); | |
| 224 | - if (major.smooth) major.size = 1; | |
| 225 | - if (minor.smooth) minor.size = 1; | |
| 226 | - if (major.size < minor.size) | |
| 227 | - std::swap(major, minor); | |
| 228 | - | |
| 229 | - flip = minor.header == "Algorithm"; | |
| 230 | 228 | } |
| 231 | 229 | |
| 232 | 230 | bool finalize(bool show = false) | ... | ... |