Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Bug: leftover xaxis entries when toggling between buttons

Offen
#4,849 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

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

Rechercherichtung

Beginne damit, das bereitgestellte Python MWE auszuführen und in der Subplot-Abbildung zwischen den Schaltflächen option1 und option2 zu wechseln. Untersuche, wie gemeinsame x-Achsen-Einträge beibehalten werden, wenn traces ausgeblendet sind und die Optionen das Label B gemeinsam haben. Als erledigt gilt, dass beim Wechsel zu option2 der übrig gebliebene x-Achsen-Eintrag C aus option1 nicht mehr angezeigt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Minimum Working Example (MWE):

import plotly.graph_objects as go
from plotly.subplots import make_subplots

# Data
option1_x = ['A', 'B', 'C']
option1_y1 = [1, 3, 2]
option1_y2 = [2, 4, 3]

option2_x = ['B', 'D', 'E']
option2_y1 = [2, 1, 4]
option2_y2 = [3, 2, 5]

# Create subplots
fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=("y1", "y2"))

# Add traces for option1
fig.add_trace(go.Bar(x=option1_x, y=option1_y1, name="option1_y1"), row=1, col=1)
fig.add_trace(go.Bar(x=option1_x, y=option1_y2, name="option1_y2"), row=2, col=1)

# Add traces for option2
fig.add_trace(go.Bar(x=option2_x, y=option2_y1, name="option2_y1"), row=1, col=1)
fig.add_trace(go.Bar(x=option2_x, y=option2_y2, name="option2_y2"), row=2, col=1)

# Initially set option1 visible and option2 invisible
for trace in fig.data:
    trace.visible = False
fig.data[0].visible = True  # y1 option1
fig.data[1].visible = True  # y2 option1

# Add buttons
fig.update_layout(
    updatemenus=[
        {
            "type": "buttons",
            "buttons": [
                {
                    "label": "option1",
                    "method": "update",
                    "args": [
                        {"visible": [True, True, False, False]},  # Show only option1 traces
                    ]
                },
                {
                    "label": "option2",
                    "method": "update",
                    "args": [
                        {"visible": [False, False, True, True]},  # Show only option2 traces
                    ]
                }
            ],
            "showactive": True,
        }
    ],
)

fig.show()

Image

Toggling to option2, we can see the C xaxis entry (from option1) still showing (even with no data for it):

Image

This seems to only be an issue with subplots, and when the traces of different options have some xaxis labels in common (in this case B).

Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
13 Std. 28 Min.
Gemergte PRs (30 T.)
20

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus plotly/plotly.py

Alle Issues in plotly/plotly.py

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

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