Skip to content

Commit 880f42d

Browse files
committed
first attempt at supporting geom_jitter
1 parent 789e1ec commit 880f42d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

R/trace_generation.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,35 @@ geom2trace <- list(
556556
}
557557
L
558558
},
559+
jitter=function(data, params){
560+
L <- list(x=data$x,
561+
y=data$y,
562+
name=params$name,
563+
text=data$text,
564+
type="scatter",
565+
mode="markers",
566+
marker=paramORdefault(params, aes2marker, marker.defaults))
567+
if("size" %in% names(data)){
568+
L$text <- paste("size:", data$size)
569+
L$marker$sizeref <- default.marker.sizeref
570+
# Make sure sizes are passed as a list even when there is only one element.
571+
s <- data$size
572+
marker.size <- 5 * (s - params$sizemin)/(params$sizemax - params$sizemin) + 0.25
573+
marker.size <- marker.size * marker.size.mult
574+
L$marker$size <- if (length(s) > 1) marker.size else list(marker.size)
575+
L$marker$line$width <- 0
576+
}
577+
if (!is.null(params$shape) && params$shape %in% c(21:25)) {
578+
L$marker$color <- ifelse(!is.null(params$fill), toRGB(params$fill), "rgba(0,0,0,0)")
579+
if (!is.null(params$colour))
580+
L$marker$line$color <- toRGB(params$colour)
581+
L$marker$line$width <- 1
582+
}
583+
if (!is.null(params$shape) && params$shape %in% c(32)) {
584+
L$visible <- FALSE
585+
}
586+
L
587+
},
559588
text=function(data, params){
560589
L <- list(x=data$x,
561590
y=data$y,

0 commit comments

Comments
 (0)