px.area() ignores color_discrete_sequence or color_discrete_map when mode='none'
Aperta
@LiamConnors ci sta già lavorando.
Dal 4/7/2024.
bug
documentation
P3
- Lingua principale
- Python
- Stelle
- 18.8k
- Fork
- 2.8k
- Merge medio
- 16h 26m
- PR unite (30g)
- 21
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.