Subplot panel height not consistent

Aberta
#2,144 4 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
r

Direção de pesquisa

Comece executando o exemplo fornecido de generate_subplot para 2, 4 e 8 linhas e compare as alturas dos painéis e dos eixos x nas figuras renderizadas. Rastreie como subplot() combina os objetos plot_ly repetidos e seus valores de altura; considera-se concluído quando cada painel tem a altura consistente solicitada e a altura total da figura escala conforme esperado.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

There doesn't seem to be a way to set the total figure size for subplot().
Individual panel height can be specified in the call to plot_ly and (as i understand it) that height is scaled with the number of panels to become the total figure size.

I tried using this by passing to each subplot the individual plotheight multiplied with the number of subplots (nrows) so the total height of the total figure would be plotheight * nrows.
It turns out the heights aren't strictly adhered too.
Comparing the total height of the first two panels you can clearly see the x axes are at different heights:

subplot height mismatch

generate_subplot <- function(nrows, margin = NULL){

  if(is.null(margin)) margin = c(0,0,0,0)

  p <- plotly::plot_ly(mtcars, 
    x = ~cyl, y = ~mpg, 
    color = ~rownames(.data), 
    type = "bar",
    height = 150 * nrows
  ) %>% plotly::layout(
    showlegend = FALSE,
    shapes = list(
      list(
        type = 'rect',
        fillcolor = "gray", 
        line = list(color = "gray"), 
        opacity = 0.05,
        x0 = 0, x1 = 1,
        y0 = 0, y1 = 1,
        xref = 'paper',
        yref = 'paper'
      )
    )
  )
  
  plotly::subplot(
    rep_len(list(p), nrows),
    nrows = nrows,
    margin = margin
  )

}

generate_subplot(2)
generate_subplot(4)
generate_subplot(8)
Linguagem predominante
R
Estrelas
2.7k
Forks
641
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de plotly/plotly.R

Todas as issues de plotly/plotly.R

Issues semelhantes

Mais issues de R

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.