plotly / plotly/plotly.py

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

未关闭
#3,709 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@LiamConnors 已经在做这个了。

开始于 2024年7月4日。

bug documentation P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。