【问题标题】:Plotly AttributeError: 'Figure' object has no attribute 'show'Plotly AttributeError:“Figure”对象没有“show”属性
【发布时间】:2020-01-07 14:25:57
【问题描述】:

我正在尝试使用 Plotly 对过去一年的 Apple 股票回报率进行 Displot。

import plotly.figure_factory as ff

hist_data = [df['Return'][1:]] 
group_labels = ['Apple Return distplot'] 

fig = ff.create_distplot(hist_data, group_labels, bin_size=.1)
fig.show()

我收到以下错误消息:

AttributeError: 'Figure' 对象没有属性 'show'

我该如何解决上述问题?

【问题讨论】:

  • 您使用的是哪个版本的plotly?你能告诉我们print(plotly.__file__)的输出吗?
  • @JohnGordon 我收到了这条消息:/Users/jacquelinewong/anaconda3/lib/python3.6/site-packages/plotly/__init__.py
  • 他们已经彻底摧毁了阴谋。没有什么对我有用。

标签: python matplotlib plotly data-visualization


【解决方案1】:

如果您看到此错误,则说明您使用的 plotly 版本低于 4.x,您需要升级。我建议升级到最新版本,即 4.1.1

【讨论】:

  • 我升级到 4.1.1 但仍然收到此消息ImportError: The plotly.plotly module is deprecated, please install the chart-studio package and use the chart_studio.plotly module instead.
  • 是的,这是正确的。您是否也从 plotly.plotly 导入?在版本 4 中,这个包被移动了,但它也不再需要了,特别是因为 fig.show() 是显示数字的更好方法。
  • 对于那些无法升级他们的情节版本的人,有什么解决方法吗?
【解决方案2】:

这对我有用

!pip install plotly==4.1.1
from plotly import graph_objs as go

【讨论】:

    猜你喜欢
    • 2019-11-27
    • 1970-01-01
    • 1970-01-01
    • 2021-01-05
    • 2019-05-06
    • 2022-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多