plotly / plotly/plotly.py

px.area() ignores color_discrete_sequence or color_discrete_map when mode='none'

Offen
#3,709 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@LiamConnors arbeitet bereits daran.

Seit 04.7.2024.

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

Beschreibung

If I want to display just the shaded area in px.area(), without the top line, by specifying mode='none', the colors set with color_discrete_sequence or color_discrete_map are ignored. Instead, default colors of the template fig.layout.template.layout.colorway are used.

import plotly.express as px
import pandas as pd

fig = px.area(
    pd.DataFrame(
        index=[1,2,3],
        data={
            'x': [6,7,8],
            'y': [4,5,4],
        }
    ),
    color_discrete_map={
        'x': '#9467BD',
        'y': '#8C564B',
    },
)

fig.show()

1

If I add

fig.update_traces(
    mode='none',
)

I get wrong colors
2

I would expect px.area() to preserve the colors used for shading as they appear in fig.data:

     'line': {'color': '#9467BD'},
     'mode': 'none',
     'line': {'color': '#8C564B'},
     'mode': 'none',

Without this preservation, px.area() loses functionality for color mapping with color_discrete_map.

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.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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