绘制漏斗​​图

时间:2019-07-28 05:03:41

标签: python-3.x 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”的值无效         收到的值:渠道({     '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, ...}])

1 个答案:

答案 0 :(得分:0)

您似乎正在使用版本3,在这种情况下,您将需要使用go.Figure(data=[go.Funnel(...)])(基本上将漏斗跟踪包装在数组中……仅在版本4中是可选的)