plotly / plotly/plotly.py

`labelalias` in `Scatter.marker.colorbar` can't handle negative values

Offen
#4,924 4 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

I am building a line-chart, which uses a colorgradient. The values of the line chart can be negative and positive. I want to add a colorbar to explain the meaning of the colors in the gradient. For this I use labelalias. The labels only appear for ticks >= 0.

Example

trace = go.Scatter(
  x = x,
  y = y,
  marker = dict(
    color=y,
    colorscale=[(0.0, "royalblue"), (0.5, "rgba(230, 230,230,0.5)"), (1.0, "orange") ]
    colorbar=dict(
                title="Score",
                tickmode="array",
                tickvals=[-10, 0, 10],
                labelalias={-10: "Negative", "0": "Neutral", 10: "Positive"},
                ticks="",
    )
  )
)

The output looks like this:
Image

Expected behavior

The label -10 is replaced by Negative

Context
  • python==3.11
  • plotly==5.24.1

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, das Python-Beispiel aus dem Issue mit Scatter.marker.colorbar, tickvals=[-10, 0, 10] und der bereitgestellten labelalias-Zuordnung zu reproduzieren. Verfolge, wie negative Tick-Aliase verarbeitet werden, und überprüfe, dass die abgeschlossene Änderung die Beschriftung des -10-Ticks durch "Negative" ersetzt und dabei die anderen Beschriftungen beibehält.

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
42/100

Neue Issues direkt in Ihr Postfach

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