Skip to content

Commit f3955ea

Browse files
committed
* r/R/eafdiffplot.R: Minor improvement.
1 parent 9945a4b commit f3955ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

r/R/eafdiffplot.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,19 @@ plot_eafdiff_side <- function (eafdiff, attsurfs = list(),
356356

357357
# Colors are correct for !full.eaf && type == "area"
358358
if (full.eaf || type == "point") {
359-
diff_values <- eafdiff[,3L]
360-
eafdiff <- eafdiff[, c(1L,2L), drop=FALSE]
361359
# FIXME: This is wrong, we should color (0.0, 1] with col[1], then (1, 2]
362360
# with col[1], etc, so that we never color the value 0.0 but we always
363361
# color the maximum value color without having to force it.
364362

365363
# Why flooring and not ceiling? If a point has value 2.05, it should
366364
# be painted with color 2 rather than 3.
367365
# +1 because col[1] is white ([0,1)).
368-
diff_values <- floor(diff_values) + 1
366+
diff_values <- floor(eafdiff[,3L]) + 1
369367
if (nunique(diff_values) > length(col)) {
370-
stop ("Too few colors: length(unique(diff_values)) > length(col)")
368+
stop ("Too few colors: there are ", nunique(diff_values),
369+
" unique values but only ", length(col), " colors")
371370
}
371+
eafdiff <- eafdiff[, c(1L,2L), drop=FALSE]
372372
}
373373
if (type == "area") {
374374
if (full.eaf) {

0 commit comments

Comments
 (0)