plotly / plotly/plotly.R

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

Ouverte
#2,413 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par les appels à ggplotly() et subplot() reproduits dans l’issue, en comparant leur sortie avec grid.arrange(). Suivez la manière dont subplot() gère plusieurs titres de graphiques, les axes partagés et les titres des axes. C’est terminé lorsque les quatre graphiques convertis conservent les titres et les axes attendus dans une disposition interactive à deux lignes, ou lorsque le comportement est documenté comme une limitation.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
r
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.