plotly / plotly/plotly.py

[BUG]: contours.size initialization does not apply the specified value, but updates via dropdown work correctly

Aperta
#5,613 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug good first issue good for agent P3 size: 1
Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Descrizione

Description

When initializing a go.Contour trace with a specific contours.size value (e.g., 0.25), the setting is ignored on the initial render, and Plotly defaults to an automatically calculated contour step size.

Interestingly, if the exact same parameter ("contours.size") is later updated dynamically via a layout updatemenus dropdown using the "restyle" method, the chart correctly updates and respects the specified size.

Screenshots/Video
  • Initial Render (Buggy): The contours are spaced at default intervals despite contours.size=0.25 being passed to the constructor.
Image
  • After Selecting Dropdown (Expected): Selecting "Contour Size: 0.25" from the dropdown forces the chart to restyle, properly displaying the dense 0.25-step contour lines.
Image
Steps to reproduce
  1. Run the provided Python snippet using plotly.py.
  2. Observe the initial plot render: notice that the contour lines do not match a step size of 0.25.
  3. Click the dropdown menu at the top left of the figure.
  4. Select the "Contour Size: 0.25" option.
  5. Notice that the plot immediately visualizes a much denser set of contours, behaving as it should have upon initialization.
import plotly
import plotly.graph_objects as go

print(f"Plotly version: {plotly.__version__}")

z_data = [
    [10, 10.625, 12.5, 15.625, 20],
    [5.625, 6.25, 8.125, 11.25, 15.625],
    [2.5, 3.125, 5.0, 8.125, 12.5],
    [0.625, 1.25, 3.125, 6.25, 10.625],
    [0, 0.625, 2.5, 5.625, 10],
]

fig = go.Figure(
    data=go.Contour(
        z=z_data,
        contours=dict(size=0.25),
        colorbar=dict(
            title=dict(
                text="Color bar title",
                side="right",
                font=dict(size=14, family="Arial, sans-serif"),
            )
        ),
    )
)

# This assertion passes, proving the property is registered in python-land
assert fig.data[0].contours.size == 0.25

fig.update_layout(
    updatemenus=[
        dict(
            type="dropdown",
            buttons=[
                dict(
                    label="Contour Size: 0.25",
                    method="restyle",
                    args=[{"contours.size": 0.25}],
                ),
                dict(
                    label="Contour Size: 1.0",
                    method="restyle",
                    args=[{"contours.size": 1.0}],
                ),
                dict(
                    label="Contour Size: 2.0",
                    method="restyle",
                    args=[{"contours.size": 2.0}],
                ),
            ],
        )
    ]
)

fig.show()

Notes
  • The internal Python object structure correctly holds the contours.size value (as verified by the passing assert fig.data[0].contours.size == 0.25 statement).
  • The version of plotly.py is 6.8.0.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione Python fornita, in particolare go.Contour e l’assegnazione di contours.size, quindi confronta il rendering iniziale con il percorso restyle di layout updatemenus. Traccia il punto in cui il valore del costruttore viene passato al rendering e verifica che un contours.size iniziale di 0.25 produca la stessa spaziatura dei contorni della selezione dell’opzione dal menu a discesa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
plotly, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.