plotly / plotly/plotly.py

Certain padding values cause plots to overtake all other subplots

Offen
#4,144 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

Related to #4124 there is a set of padding values that will produce strange behavior such that a single subplot takes over all others.

Some setup:

import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
line_x = np.arange(10)
line_y = line_x**2

What works:

n_subplots = 6

full_fig = make_subplots(
    rows=n_subplots,
    cols=1,
)

for row_idx in range(1, n_subplots+1):
    full_fig.add_trace(go.Scatter(
            x=line_x,
            y=line_y,
            showlegend=False,
        ), row=row_idx, col=1)

This produces 6 different subplots of the same line.

What doesn't work:

line_x = np.arange(10)
line_y = line_x**2

n_subplots = 8
padding_size = 0.1

row_heights = [0.1]*n_subplots

specs = []
for _ in range(n_subplots):
    specs.append([{'b': padding_size/2., 't': padding_size/2.}])

full_fig = make_subplots(
    rows=n_subplots,
    cols=1,
    row_heights=row_heights,
    specs=specs,
)

for row_idx in range(1, n_subplots+1):
    full_fig.add_trace(go.Scatter(
            x=line_x,
            y=line_y,
            showlegend=False,
        ), row=row_idx, col=1)

Adding the padding and row heights now generates only a single plot.

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 damit, die bereitgestellten make_subplots-Beispiele auszuführen, und vergleiche den Fall mit sechs Zeilen mit dem Fall mit acht Zeilen unter Verwendung von row_heights und specs padding. Verfolge, wie make_subplots Zeilenhöhen sowie den oberen/unteren Abstand verarbeitet, und überprüfe anschließend den Fix anhand der reproduzierten Konfiguration. Als erledigt gilt dies, wenn alle acht Subplots separat gerendert werden, anstatt dass ein Subplot die Kontrolle übernimmt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

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