plotly / plotly/plotly.R

subplot() fails to plot 6 plots in a 2 rows x 4 columns grid

Offen Anfängerfreundlich
#2,400 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

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 want to use subplot function to plot 6 ggplots in a 2 rows x 4 columns grid.

Here is a reproducible example:

figlist <- list()
for (i in 1:6) figlist[[i]] <- ggplot(data.frame(a = 1:3,b = 4:6), aes(a,b)) + geom_point()
subplot(figlist, nrows = 2, widths = rep(0.25,4))

This generates "Error: The length of the widths argument must be equal to the number of columns"

Looking into the code of subplots.R, the subplot function accepts arguments nrows, widths and heights, which appear to be passed through to get_domains.

The problem is that get_domains calculates ncols ignoring length(widths) and then generates an error when these don't match.

I would have expected get_domains to calculate ncols only if widths was not supplied.

I hope this helps.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in subplots.R und verfolge, wie subplot() nrows, widths und heights an get_domains() übergibt. Führe das reproduzierbare Beispiel mit sechs Plots aus dem Issue aus und überprüfe anschließend, dass ein Layout mit 2 Zeilen und 4 Spalten, bei dem widths angegeben wird, nicht mehr den Fehler zur Spaltenlänge auslöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
62/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.