plotly::subplot with >= 3 rows/cols results in different sized plots for inner/boundary plots
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
As per title, when making a subplot with >= 3 rows or columns with a margin (default is 0.02 but the issue is easier to see with more plots/bigger margins)
library(magrittr)
p <- plotly::plot_ly(mtcars, x = ~cyl, y = ~mpg, color = ~rownames(.data), type = "bar") %>% plotly::layout(showlegend = FALSE)
plotly::subplot(p, p, p, p, p, p, p, p, p, nrows = 3, margin = 0.1)

There is a PR (#622) which aims to fix it, but the PR also does some extra things like make the margins fixed rather than scaled. I think it's possible to provide a much quicker & simpler fix as an alternative, given that this has been known about since 2016.
I think in a nutshell its due to the function get_domains & it's for loops:
https://github.com/plotly/plotly.R/blob/4bb1e44c5e27898bdf7ac45422564fa5200fb5f5/R/subplots.R#L385-L401
It's those if's that are the problem, can they be removed without causing too much trouble?
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
Beginne mit R/subplots.R, insbesondere mit get_domains und den Schleifen um die Zeilen 385–401. Führe das mitgelieferte R-Beispiel mit nrows = 3 und margin = 0.1 aus und vergleiche anschließend die Größen der Bereiche für innere und Randplots. Als erledigt gilt die Aufgabe, wenn die subplot-Panels konsistente Größen haben; prüfe vor dem Fortfahren PR #622 auf verwandte Arbeiten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100