plotly / plotly/plotly.R

subplot() not producing the interactive equivalent of gridExtra::grid.arrange()

Abierto
#2,413 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
R
Estrellas
2.7k
Forks
641
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Given:

    library(ggplot2)
    library(gridExtra)
    library(plotly)
    library(colorRamps)
    
    d <- data.frame(x=sample(1:10)/10, y=sample(1:10)/10, z=sample(1:10)/10, c=sample(LETTERS[1:5],size=10,replace=TRUE))
    g1 <- ggplot(d) +
      geom_point(aes(x=x, y=y, fill = z),
                 pch=21,size=4) +
      facet_wrap(~c,labeller = label_both) +
      scale_fill_gradientn(colors = matlab.like2(16),limits=c(0, 100)) +
      xlim(c(0,1)) + ylim(c(0,1)) +
      coord_fixed(ratio = 1) +
      theme(legend.position=c(0.85,0.2), legend.background=element_blank()) +
      labs(fill = "%")
    
    g2<- g1+ggtitle("Plot 2")
    g3<- g1+gtitle("Plot 3")
    g4<- g1+ggtitle("Plot 4")
    g1<- g1+ggtitle("Plot 1")
    p = list(g1,g2,g3,g4) %>% map(~.x + labs(x=NULL, y=NULL))
    yleft= "X"
    xbottom= "Y"
    grid.arrange(grobs=p,bottom = xbottom, left = yleft,nrow=2)

Image

I want to get the same plot but with interactive browsing of the values. I try:

pg1 <- ggplotly(g1)
pg2 <- ggplotly(g2)
pg3 <- ggplotly(g3)
pg4 <- ggplotly(g4)

Individual plots are ok:

pg1

Image

But

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=FALSE, shareY=FALSE,titleX=TRUE,titleY=TRUE)

or

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=FALSE, shareY=FALSE,titleX=FALSE,titleY=FALSE)

result into:

Image

Which is almost good but displays only 1 title (and in the wrong place) and no axes titles.

I try

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=TRUE, shareY=TRUE,titleX=FALSE,titleY=FALSE)

and

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=TRUE, shareY=TRUE,titleX=TRUE,titleY=TRUE)

and the result is even worse:

Image

Is this a bug or am I doing something wrong? Is there an alternative way to get the interactive version of the grid?

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con las llamadas a ggplotly() y subplot() reproducidas en el issue y compara su salida con grid.arrange(). Rastrea cómo subplot() gestiona varios títulos de gráficos, los ejes compartidos y los títulos de los ejes. Se considera terminado cuando los cuatro gráficos convertidos conservan los títulos y ejes esperados en una disposición interactiva de dos filas, o cuando el comportamiento se documenta como una limitación.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
r
Área
data-visualization
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.