ggplotly() unable to fit 4 plots in 3 columns using a "ggplot() + facet_wrap()" object
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hi,
It turns out that ggplotly() is unable to fit 4 plots in 3columns when the ggplot object to be converted was designed using this structure ggplot(df, aes(x,y) + facet_wrap(~ var, ncol = 3). It does not matter which example you use.
Let's use this example from the plotly community website, see section "labels":
https://plotly.com/ggplot2/facet_wrap/#labels
df <- diamonds[sample(1:nrow(diamonds), size = 1000), ]
# Create labels
labs <- c("Best","Second best","Third best","Average", "Average","Third Worst","Second Worst","Worst")
levels(df$clarity) <- rev(labs)
# filter variable "clarity" to get 4 plots in the facet
df <- df %>%
filter(clarity %in% c("Worst", "Average", "Third best", "Best"))
p <- ggplot(df, aes(carat, price)) +
geom_point() +
facet_wrap(~ clarity, ncol = 3) # make clear that 3 columns are needed
fig <- ggplotly(p)
fig
I will attach the outputs so you can see the bug:




It is easy tu bypass this issue, just changing the number of columns. Nevertheless, it would be great if this didn't happen.
Kind regards,
Sergi
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con l’esempio diamonds della pagina Plotly «facet_wrap labels», usando ggplot() con facet_wrap(~ clarity, ncol = 3) e convertendolo con ggplotly(). Esamina la conversione di facet_wrap e confronta il risultato renderizzato con il ggplot originale. Il lavoro è completato quando quattro grafici rientrano correttamente in tre colonne nella figura convertita.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100