Skip to content

Commit 5655851

Browse files
committed
Merge pull request #538 from ropensci/fix/shape
fix #537
2 parents d8d8d65 + 77943f0 commit 5655851

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ build_site.R
88
todo.R
99
inst/examples/*/*.html
1010
inst/examples/*/rsconnect/*
11+
.Rproj.user

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via 'plotly.js'
3-
Version: 3.4.12
3+
Version: 3.4.13
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]"),
66
person("Chris", "Parmer", role = c("aut", "cph"),

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
3.4.13 -- 6 Apr 2016
2+
3+
BUGFIX:
4+
5+
In some cases, marker color was inheriting from the marker line color when
6+
it shouldn't have. See ##537.
7+
18
3.4.12 -- 5 Apr 2016
29

310
CHANGES:

R/layers2traces.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ geom2trace.GeomPath <- function(data, params, p) {
395395
#' @export
396396
geom2trace.GeomPoint <- function(data, params, p) {
397397
shape <- aes2plotly(data, params, "shape")
398+
color <- aes2plotly(data, params, "colour")
398399
L <- list(
399400
x = data$x,
400401
y = data$y,
@@ -404,21 +405,20 @@ geom2trace.GeomPoint <- function(data, params, p) {
404405
mode = "markers",
405406
marker = list(
406407
autocolorscale = FALSE,
407-
color = aes2plotly(data, params, "fill"),
408+
color = color,
408409
opacity = aes2plotly(data, params, "alpha"),
409410
size = aes2plotly(data, params, "size"),
410411
symbol = shape,
411412
line = list(
412413
width = aes2plotly(data, params, "stroke"),
413-
color = aes2plotly(data, params, "colour")
414+
color = color
414415
)
415416
)
416417
)
417-
# fill is irrelevant for pch %in% c(1, 15:20)
418+
# fill is only relevant for pch %in% 21:25
418419
pch <- uniq(data$shape) %||% params$shape %||% GeomPoint$default_aes$shape
419-
if (any(pch %in% c(1, 15:20)) ||
420-
all(grepl("open$", shape)) && all(L$marker$color %in% "transparent")) {
421-
L$marker$color <- L$marker$line$color
420+
if (any(idx <- pch %in% 21:25)) {
421+
L$marker$color[idx] <- aes2plotly(data, params, "fill")[idx]
422422
}
423423
L
424424
}

tests/testthat/test-ggplot-point.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ test_that("marker color is non-transparent for open shapes", {
3434
)
3535
})
3636

37+
test_that("marker color inherits from fill, when appropriate", {
38+
df_shapes <- data.frame(shape = factor(0:24))
39+
p <- ggplot(df_shapes, aes(shape = shape)) +
40+
geom_point(aes(shape = shape, x = 0, y = 0), size = 5, fill = "red") +
41+
facet_wrap(~shape) +
42+
scale_shape_manual(values = df_shapes$shape, guide = "none")
43+
l <- save_outputs(p, "all-shapes")
44+
expect_equal(length(l$data), 25)
45+
markerColors <- sapply(l$data, function(x) x$marker$color)
46+
lineColors <- sapply(l$data, function(x) x$marker$line$color)
47+
expect_true(all(markerColors[1:20] == lineColors[1:20]))
48+
expect_true(all(markerColors[21:25] != lineColors[21:25]))
49+
})
50+
51+
3752
test_that("can plot on sub-second time scale", {
3853
d <- data.frame(
3954
x = Sys.time() + 1e-3 * c(1:9, 5000),

0 commit comments

Comments
 (0)