px.area() ignores color_discrete_sequence or color_discrete_map when mode='none'
Offen
@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()

If I add
fig.update_traces(
mode='none',
)
I get wrong colors

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
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.