python - Pandas:使用 plotly 作为后端时如何选择绘图元素颜色?
问题描述
我正在尝试将Plotly 作为 pandas plot backend。我按照这些说明成功配置了它,但是在配置图表元素颜色时遇到了麻烦。
这就是我想要做的。它使用 matplotlib 作为后端:
df.plot(kind='area',
color=['orange', 'lightslategray'],
backend='matplotlib' )
但是当我尝试使用 ploty 时,它失败并出现一个奇怪的错误:
df.plot(kind='area',
color=['orange', 'lightslategray'],
backend='plotly' )
错误:
ValueError: All arguments should have the same length. The length of argument `color` is 2, whereas the length of previously-processed arguments ['Dia', 'Alfa', 'Beta'] is 12
如果我不尝试设置任何颜色,该情节将起作用:
df.plot(kind='area', backend='plotly' )
解决方案
推荐阅读
- kubernetes - 这些 Kubernetes 健康检查来自哪里?
- java - Kafka 消费者手动提交偏移量
- asp.net-mvc-5 - 带有 ddl 和数量的 MVC 选择编辑器视图模型
- javascript - d3 中的工具提示在可缩放图形的矩形内不起作用
- vba - 如何为 Matomo 构建正确的 HTTP API 调用
- python - 尝试在 python 中打开和读取文件,但它会创建并打开一个空文件
- django - 过滤带有选项的字段
- html - 如何始终在 html 对象标签中显示 PDF 页码?
- python - 熊猫广泛的“描述”包括计算空值
- powershell - 使用 PoSh 和 7zip 将多个日志文件合并到存档