plotly / plotly/plotly.py

Missing colorscales in ui buttons

Offen
#5,189 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

In the following code I created a simple plot with a dropdown menu where each button is expected to modify the colorscale. However, some of these don't seem to work properly and when the corresponding button is clicked, a default colorscale is applied instead.


import plotly.graph_objects as go
import numpy as np

# Generate sample data
np.random.seed(42)
x = np.random.rand(100)
y = np.random.rand(100)
z = np.sqrt(x**2 + y**2)

# Available colormaps
colorscales = ['Viridis', 'Cividis', 'Plasma', 'Inferno', 'Magma']

# Create the initial figure with one colorscale
scatter = go.Scatter(
    x=x,
    y=y,
    mode='markers',
    marker=dict(
        size=10,
        color=z,
        colorscale=colorscales[0],
        colorbar=dict(title='Value'),
        showscale=True
    )
)

fig = go.Figure(data=[scatter])

# Add dropdown menu
fig.update_layout(
    updatemenus=[
        dict(
            buttons=[
                dict(
                    label=scale,
                    method='restyle',
                    args=[{'marker.colorscale': [scale]}]
                )
                for scale in colorscales
            ],
            direction='down',
            showactive=True,
            x=1.1,
            y=1
        )
    ],
    title="Scatter Plot with Colormap Dropdown",
    xaxis_title="X",
    yaxis_title="Y"
)

fig.show()

In this plot only 'Viridis' and 'Cividis' colorscales are supported. More in general it seems to me that the only supported ones are those defined in plotly.colors.plotlyjs (only the non-reversed ones).

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

Beginnen Sie, indem Sie die bereitgestellte Python-Reproduktion ausführen und das Dropdown-Verhalten mit den in plotly.colors.plotlyjs verfügbaren Namen vergleichen. Verfolgen Sie, wie die Plotly-Python-Figur colorscale-Werte für die Schaltflächen serialisiert; erledigt ist die Aufgabe, wenn die aufgelisteten colorscales beim Auswählen akzeptiert und konsistent angewendet werden.

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
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

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