plotly / plotly/plotly.py

Missing colorscales in ui buttons

未关闭
#5,189 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

In the following code I created a simple plot with a dropdown menu where each button is expected to modify the colorscale. However, some of these don't seem to work properly and when the corresponding button is clicked, a default colorscale is applied instead.


import plotly.graph_objects as go
import numpy as np

# Generate sample data
np.random.seed(42)
x = np.random.rand(100)
y = np.random.rand(100)
z = np.sqrt(x**2 + y**2)

# Available colormaps
colorscales = ['Viridis', 'Cividis', 'Plasma', 'Inferno', 'Magma']

# Create the initial figure with one colorscale
scatter = go.Scatter(
    x=x,
    y=y,
    mode='markers',
    marker=dict(
        size=10,
        color=z,
        colorscale=colorscales[0],
        colorbar=dict(title='Value'),
        showscale=True
    )
)

fig = go.Figure(data=[scatter])

# Add dropdown menu
fig.update_layout(
    updatemenus=[
        dict(
            buttons=[
                dict(
                    label=scale,
                    method='restyle',
                    args=[{'marker.colorscale': [scale]}]
                )
                for scale in colorscales
            ],
            direction='down',
            showactive=True,
            x=1.1,
            y=1
        )
    ],
    title="Scatter Plot with Colormap Dropdown",
    xaxis_title="X",
    yaxis_title="Y"
)

fig.show()

In this plot only 'Viridis' and 'Cividis' colorscales are supported. More in general it seems to me that the only supported ones are those defined in plotly.colors.plotlyjs (only the non-reversed ones).

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行提供的 Python 重现代码,并将下拉菜单的行为与 plotly.colors.plotlyjs 中可用的名称进行比较。跟踪 Plotly Python figure 如何为按钮序列化 colorscale 值;当列出的 colorscales 在选中时能够被接受并一致地应用,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

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