Skip to content

Missing labels when using subplot with geom_tile #599

Closed
@talgalili

Description

@talgalili

Self contained example:

library(ggplot2)
# If you want to draw arbitrary rectangles, use geom_tile() or geom_rect()
df <- data.frame(
  x = rep(c(2, 5, 7, 9, 12), 2),
  y = rep(c(1, 2), each = 5),
  z = factor(rep(1:5, each = 2)),
  w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
)
p <- ggplot(df, aes(x, y)) +
  geom_tile(aes(fill = z))

Using ggplotly works fine:

library(plotly)
ggplotly(p)

image

But using subplot makes the left labels disappear:

library(plotly)
subplot(plotly_empty(), p, nrows = 1, widths = c(.2,.8), margin = 0,
        shareX = TRUE, shareY = TRUE, titleX = FALSE, titleY = FALSE)

image

This bug is important for heatmaply, since we get truncated labels, for example:

devtools::install_github("ropensci/plotly")
devtools::install_github('talgalili/heatmaply')
library(heatmaply)
heatmaply(mtcars, k_row = 3, k_col = 2)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions