Aspect ratio with small multiples / subplots
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
I would like to create small multiples with a fixed aspect ratio. However, there seems to be a but somewhere and only some plots retain the correct aspect ratio.
From what I gathered, setting a fixed aspect ratio with plotly is done as follows: layout(yaxis = list(scaleanchor = "x"))
Consider the follwing example:
df <- data_frame(
x = rep(1:5,25),
y = rep(1:5,25),
g = sort(rep(1:25,5))
)
plots <- df %>%
split(.$g) %>%
map(function(x){
plot_ly(data = x, x = ~x, y = ~y, type = "scatter",mode = "lines") %>% add_lines()
})
small_mulitples <- subplot(plots,nrows = 5) %>%
layout(yaxis = list(scaleanchor = "x")) %>%
hide_legend()
If I plot small_mulitples, only the first plot (row 1, column 1) has an aspect ratio of 1. The other have an arbitrary aspect ratio.

Here's the link to the interactive version of this plot: https://plot.ly/~rata_zhaw/1/
Interestingly, if I choose the option shareX = T in subplot(), the entire first column has the correct aspect ratio. Nothing changes if I choose shareY = T
small_mulitples <- subplot(plots,nrows = 5, shareX = T) %>%
layout(yaxis = list(scaleanchor = "x")) %>%
hide_legend()

And here's the link to the interactive version of the second plot: https://plot.ly/~rata_zhaw/3/
If I plot any of the plots individually, the aspect ratio is correct:
plots[[10]] %>%
layout(yaxis = list(scaleanchor = "x")) %>%
hide_legend()
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
Inizia riproducendo l’esempio R fornito con subplot(), nrows = 5 e layout(yaxis = list(scaleanchor = "x")); confrontalo con i casi shareX = T e del grafico singolo. Traccia il modo in cui subplot() combina i layout dei grafici e considera il problema risolto quando ogni small multiple mantiene il rapporto di aspetto fisso senza richiedere assi condivisi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- plotly, r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100