Skip to content

Commit 3ab83a8

Browse files
Bug fix: scatter plot with convert.duplicates.to.weights=F and less than min.points.jitter duplicate points.
1 parent a0c13da commit 3ab83a8

1 file changed

Lines changed: 28 additions & 22 deletions

File tree

R/plotluck.R

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -573,29 +573,35 @@ gplt.scatter <- function(data, x, y='NULL', w='NULL',
573573
if (convert.duplicates.to.weights) {
574574
p <- p + geom_point(alpha=0.6,
575575
position=pos, ...)
576-
} else if (max(table(data[, c(x, y)])) >= min.points.jitter) {
577-
# test for repeated points, optionally jitter
578-
# - if both x and y are numeric, jitter in both directions
579-
# - if one is a factor, only jitter in this direction
580-
# (enough empty space between levels)
581-
if (num.x) {
582-
if (num.y) {
583-
w.jitter <- w.jitter * diff(range(data[[x]], na.rm=TRUE))
584-
h.jitter <- h.jitter * diff(range(data[[y]], na.rm=TRUE))
576+
} else {
577+
578+
if (max(table(data[, c(x, y)])) >= min.points.jitter) {
579+
# test for repeated points, optionally jitter
580+
# - if both x and y are numeric, jitter in both directions
581+
# - if one is a factor, only jitter in this direction
582+
# (enough empty space between levels)
583+
if (num.x) {
584+
if (num.y) {
585+
w.jitter <- w.jitter * diff(range(data[[x]], na.rm=TRUE))
586+
h.jitter <- h.jitter * diff(range(data[[y]], na.rm=TRUE))
587+
} else {
588+
# num.x, !num.y
589+
w.jitter <- 0
590+
h.jitter <- factor.jitter
591+
}
585592
} else {
586-
# num.x, !num.y
587-
w.jitter <- 0
588-
h.jitter <- factor.jitter
593+
# !num.x
594+
if (num.y) {
595+
w.jitter <- factor.jitter
596+
h.jitter <- 0
597+
} else {
598+
w.jitter <- factor.jitter
599+
h.jitter <- factor.jitter
600+
}
589601
}
590602
} else {
591-
# !num.x
592-
if (num.y) {
593-
w.jitter <- factor.jitter
594-
h.jitter <- 0
595-
} else {
596-
w.jitter <- factor.jitter
597-
h.jitter <- factor.jitter
598-
}
603+
w.jitter <- 0
604+
h.jitter <- 0
599605
}
600606
p <- p + geom_point(alpha=0.6, position=position_jitter(width=w.jitter, height=h.jitter), ...)
601607
}
@@ -1890,8 +1896,8 @@ plotluck.multi <- function(data, x=NULL, y=NULL, w=NULL,
18901896

18911897
# use the limited space to make subgraphs
18921898
# relatively rectangular
1893-
opts$max.facets.row <- NULL
1894-
opts$max.facets.row <- NULL
1899+
opts$max.facets.row <- NULL
1900+
opts$max.facets.column <- NULL
18951901

18961902
if (x == 'all' && y == 'all') {
18971903
# write the axis labels only on the margins

0 commit comments

Comments
 (0)