Skip to content

subplot() doesn't handle xsizemode/ysizemode properly #1493

@cpsievert

Description

@cpsievert

I'd expect this code example to create facet strips with a fixed height for each panel, but it currently doesn't:

library(plotly)
library(dplyr)

my_plot <- . %>% 
  plot_ly(x = ~date, y = ~value) %>%
  add_annotations(
    text = ~unique(variable),
    x = 0.5,
    y = 1,
    yref = "paper",
    xref = "paper",
    xanchor = "middle",
    yanchor = "bottom",
    showarrow = FALSE,
    font = list(size = 15)
  ) %>%
  layout(
    shapes = list(
      type = "rect",
      x0 = 0,
      x1 = 1,
      xref = "paper",
      y0 = 0, 
      y1 = 16,
      yanchor = 1,
      yref = "paper",
      ysizemode = "pixel",
      fillcolor = toRGB("gray80"),
      line = list(color = "transparent")
    )
  )

economics_long %>%
  group_by(variable) %>%
  do(p = my_plot(.)) %>%
  subplot(nrows = NROW(.), shareX = TRUE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions