Skip to content

fix #537 #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build_site.R
todo.R
inst/examples/*/*.html
inst/examples/*/rsconnect/*
.Rproj.user
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: plotly
Title: Create Interactive Web Graphics via 'plotly.js'
Version: 3.4.12
Version: 3.4.13
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
email = "[email protected]"),
person("Chris", "Parmer", role = c("aut", "cph"),
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
3.4.13 -- 6 Apr 2016

BUGFIX:

In some cases, marker color was inheriting from the marker line color when
it shouldn't have. See ##537.

3.4.12 -- 5 Apr 2016

CHANGES:
Expand Down
12 changes: 6 additions & 6 deletions R/layers2traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ geom2trace.GeomPath <- function(data, params, p) {
#' @export
geom2trace.GeomPoint <- function(data, params, p) {
shape <- aes2plotly(data, params, "shape")
color <- aes2plotly(data, params, "colour")
L <- list(
x = data$x,
y = data$y,
Expand All @@ -404,21 +405,20 @@ geom2trace.GeomPoint <- function(data, params, p) {
mode = "markers",
marker = list(
autocolorscale = FALSE,
color = aes2plotly(data, params, "fill"),
color = color,
opacity = aes2plotly(data, params, "alpha"),
size = aes2plotly(data, params, "size"),
symbol = shape,
line = list(
width = aes2plotly(data, params, "stroke"),
color = aes2plotly(data, params, "colour")
color = color
)
)
)
# fill is irrelevant for pch %in% c(1, 15:20)
# fill is only relevant for pch %in% 21:25
pch <- uniq(data$shape) %||% params$shape %||% GeomPoint$default_aes$shape
if (any(pch %in% c(1, 15:20)) ||
all(grepl("open$", shape)) && all(L$marker$color %in% "transparent")) {
L$marker$color <- L$marker$line$color
if (any(idx <- pch %in% 21:25)) {
L$marker$color[idx] <- aes2plotly(data, params, "fill")[idx]
}
L
}
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-ggplot-point.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ test_that("marker color is non-transparent for open shapes", {
)
})

test_that("marker color inherits from fill, when appropriate", {
df_shapes <- data.frame(shape = factor(0:24))
p <- ggplot(df_shapes, aes(shape = shape)) +
geom_point(aes(shape = shape, x = 0, y = 0), size = 5, fill = "red") +
facet_wrap(~shape) +
scale_shape_manual(values = df_shapes$shape, guide = "none")
l <- save_outputs(p, "all-shapes")
expect_equal(length(l$data), 25)
markerColors <- sapply(l$data, function(x) x$marker$color)
lineColors <- sapply(l$data, function(x) x$marker$line$color)
expect_true(all(markerColors[1:20] == lineColors[1:20]))
expect_true(all(markerColors[21:25] != lineColors[21:25]))
})


test_that("can plot on sub-second time scale", {
d <- data.frame(
x = Sys.time() + 1e-3 * c(1:9, 5000),
Expand Down