Skip to content

ggplotly fails to convert geom_tile element with no fill aesthetic. #1562

Closed
@bedantaguru

Description

@bedantaguru

The ggplotly fails to convert geom_tile element with no fill aesthetic.

Ref : stackoverflow question

library(ggplot2)

set.seed(1503)

df <- data.frame(x = rep(1:3, 3),
                 y = rep(1:3, 3),
                 z = sample(c("A","B"), 9,replace = TRUE), 
                 stringsAsFactors = F)

p1 <- ggplot(df)+
  geom_tile(aes(x=x,y=y, fill="grey"), color = "black")

p2 <- ggplot(df)+
  geom_tile(aes(x=x,y=y),fill="grey", color = "black")

class(plotly::ggplotly(p1))
#> [1] "plotly"     "htmlwidget"
class(plotly::ggplotly(p2))
#> Error in `[.data.frame`(g, , c("fill_plotlyDomain", "fill")): undefined columns selected

Details:
looks like the code is breaking here
https://github.com/ropensci/plotly/blob/2cc296de6f77515003378a64b9fbdc93298ab45b/R/layers2traces.R#L849

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions