plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.56k stars 627 forks source link

Converting geom_tile's stroke #699

Open talgalili opened 8 years ago

talgalili commented 8 years ago

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 commented 8 years ago

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()

talgalili commented 8 years ago

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

talgalili commented 8 years ago

Hi @cpsievert any news regarding this issue?

Thanks.

geotheory commented 3 years ago

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

talgalili commented 3 years ago

It is indeed a shame. Then again, it's open source, it's how it is sometimes...

On Tue, Oct 26, 2021 at 11:21 AM Robin Edwards @.***> wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/plotly/plotly.R/issues/699#issuecomment-951695664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHOJBVFHFRGAPO6Q6O6XRDUIZXIVANCNFSM4COHP7GQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rjake commented 1 year ago

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