Aspect ratio with small multiples / subplots
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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()
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie damit, das bereitgestellte R-Beispiel mit subplot(), nrows = 5 und layout(yaxis = list(scaleanchor = "x")) zu reproduzieren; vergleichen Sie es mit den Fällen shareX = T und eines einzelnen Plots. Verfolgen Sie, wie subplot() die Plot-Layouts kombiniert, und betrachten Sie das Problem als abgeschlossen, wenn jedes Small Multiple das feste Seitenverhältnis beibehält, ohne gemeinsam genutzte Achsen zu erfordern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- plotly, r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100