python-3.x - plotly中的漏斗图
问题描述
我正在尝试使用 plotly 创建一个漏斗图并且没有任何运气。即使是来自 plotly 的罐头示例也不适合我,有人可以帮忙吗?
from plotly import graph_objects as go
fig = go.Figure(go.Funnel(
y = ["Website visit", "Downloads", "Potential customers", "Requested price", "invoice sent"],
x = [39, 27.4, 20.6, 11, 2]))
fig.show()
我得到这个巨大的回溯错误:
lueError:接收值的“数据”属性接收到的类型“plotly.graph_objs.Funnel”的无效值:Funnel({“x”:[39、27.4、20.6、11、2],“y”:[网站访问, 下载, 潜在客户, 要求的价格, 已发送发票] })
The 'data' property is a tuple of trace instances
that may be specified as:
- A list or tuple of trace instances
(e.g. [Scatter(...), Bar(...)])
- A list or tuple of dicts of string/value properties where:
- The 'type' property specifies the trace type
One of: ['area', 'bar', 'barpolar', 'box',
'candlestick', 'carpet', 'choropleth', 'cone',
'contour', 'contourcarpet', 'funnel',
'funnelarea', 'heatmap', 'heatmapgl',
'histogram', 'histogram2d',
'histogram2dcontour', 'isosurface', 'mesh3d',
'ohlc', 'parcats', 'parcoords', 'pie',
'pointcloud', 'sankey', 'scatter',
'scatter3d', 'scattercarpet', 'scattergeo',
'scattergl', 'scattermapbox', 'scatterpolar',
'scatterpolargl', 'scatterternary', 'splom',
'streamtube', 'sunburst', 'surface', 'table',
'violin', 'volume', 'waterfall']
- All remaining properties are passed to the constructor of
the specified trace type
(e.g. [{'type': 'scatter', ...}, {'type': 'bar, ...}])
解决方案
似乎您使用的是版本 3,在这种情况下您将需要使用go.Figure(data=[go.Funnel(...)])
(基本上将您的漏斗跟踪包装在一个数组中......仅在版本 4 中是可选的)
推荐阅读
- apache - .htaccess 防止 URL 中的循环和重复语言代码
- html - 如何破解禁用搜索控件的视频?
- java - 上面的代码给出了错误 Invalid character constant in selenium with java
- java - 如何在此程序中使用扫描仪关闭?
- python - 单击按钮时 Selenium webdriver 出错
- node.js - NodeJs Mongoose 更新分类产品
- android - 模拟器 Android_Accelerated_x86_Oreo 无法使用 Visual Stuido 启动
- c - 将 C 中的函数调用到程序集
- html - .load() 在 jQuery v3.0+ 中不工作/意外结果
- javascript - JS脚本的执行速度真的很慢......需要快一吨