Skip to content
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

Converting geom_tile's stroke #699

Open
talgalili opened this issue Aug 31, 2016 · 6 comments
Open

Converting geom_tile's stroke #699

talgalili opened this issue Aug 31, 2016 · 6 comments
Labels

Comments

@talgalili
Copy link
Contributor

talgalili commented Aug 31, 2016

While this bug is "small", it is effecting heatmaply behavior so a fix would be very helpful.

Following is a reproducible example with the plots of ggplot2 and plotly:


df <- data.frame(
  x = rep(c(2, 5, 7, 9, 12), 2),
  y = rep(c(1, 2), each = 5),
  w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
)
p <- ggplot(df, aes(x, y)) +
  geom_tile(aes(fill = w), colour = "grey50", size = 2) +
  theme_bw()
p


ggplotly(p)

ggplot2:

image

plotly (notice the grey borders are missing)

image

@cpsievert
Copy link
Collaborator

cpsievert commented Sep 2, 2016

Unfortunately, heatmap traces in plotly.js don't currently support specification of a "stroke" around cells. For now, if you want to mimic that first plot, you'll have to use geom_rect()

@cpsievert cpsievert changed the title Using ggplotly with ggplot2::theme_bw() ignores the grid of ggplot2::geom_tile Converting geom_tile's stroke Sep 2, 2016
@talgalili
Copy link
Contributor Author

Thanks @cpsievert.
I hope the plotly.js will be updated so that this could be resolved.

@talgalili
Copy link
Contributor Author

Hi @cpsievert any news regarding this issue?

Thanks.

@geotheory
Copy link

Still not fixed 5 years later. I think plotly must have a singe developer who does about 1 small fix per month.

@talgalili
Copy link
Contributor Author

talgalili commented Oct 29, 2021 via email

@rjake
Copy link

rjake commented Mar 24, 2023

Friends, I found a workaround. It's not great if you have a lot of tiles because it makes a whole additional layer but this seems to work geom_tile(fill = NA, color = "white")

library(tidyverse)
library(plotly)

({
  diamonds |> 
    count(clarity, color) |> 
    ggplot(aes(clarity, color, fill = n)) +
    geom_tile() +
    geom_tile(fill = NA, color = "white", size = 1)  # <--- here
}) |>
  ggplotly()

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants