plotly / plotly/plotly.py

`plotly.colors.validate_colors` fails for valid colors and passes for invalid colors

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

还没有人认领这个 Issue。

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

描述

This function raises a PlotlyError for color formats that are valid within traces, but also does not raise errors for color formats that are not valid.

Example of a valid color string that does not pass: color = 'hsl(290, 100%, 50%)'. This works perfectly fine if you construct a trace with it, but fails the validation test because it does not contain "rgb" or "#".

import plotly.graph_objects as go
import plotly.colors as pc

color = 'hsl(290, 100%, 50%)'

# this works
trace = go.Scatter(x=[0], y=[0], marker=dict(color=color))
fig = go.Figure(trace)
fig.show()

# this does not
pc.validate_colors(color)  # this throws an error

Other cases:

  • A valid, named color string throws an error
  • The same named color within a list does not throw an error
  • An invalid named color within a list does not throw an error, but it should

Examples below

import plotly.colors as pc

pc.validate_colors('red')  # throws PlotlyError

pc.validate_colors(['red'])
>>> ['red']

pc.validate_colors(['asdflkjlaskdg'])
>>> ['asdflkjlaskdg']

Perhaps this function is not meant to be used in this way? If so then more information in the docstrings could be helpful.

Plotly version 5.24.1.

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 plotly.colors.validate_colors 入口开始,复现 issue 中的 HSL、named-color、valid-list 和 invalid-list 示例。跟踪标量输入和列表输入的验证方式。当支持 trace 的有效颜色能够被接受、无效颜色能够被一致地拒绝,并且函数的预期用法在文档中清晰明确时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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