Mark
Mark

Reputation: 2899

Size of middle column plots in plotly subplot

I've seen this question / issue on plotly forums as well, but no answer to be found there so I am posting it here.

Does anyone have a clue how to get the middle plot the same size as the others? It also happens to the middle row when making a plot of 3 x 3 panels

The middle plot column ends up narrower than the outer columns:

library(plotly)
library(purrr)


# using lapply
mtcars %>% 
  split(mtcars$cyl) %>% 
  lapply(function(x) {
    plot_ly(data = x, 
            x = rownames(x), 
            y = ~mpg, 
            type = "bar")
  }) %>% 
  subplot(margin = .05)

Upvotes: 1

Views: 1434

Answers (1)

Tung
Tung

Reputation: 28441

Not really a solution to your question but we can make the middle plot a bit bigger by setting widths in subplot

mtcars %>% 
  split(mtcars$cyl) %>% 
  purrr::map(., function(x) {
    plot_ly(data = x, 
            x = rownames(x), 
            y = ~mpg, 
            type = "bar")
  }) %>% 
  subplot(nrows = 1, margin = 0.03, widths = c(0.3, 0.35, 0.3))

enter image description here

Upvotes: 1

Related Questions