【问题标题】:PlotlyRequestError: Authentication credentials were not provided pythonPlotlyRequestError:未提供身份验证凭据 python
【发布时间】:2020-08-13 11:35:18
【问题描述】:

我正在尝试使用 plotly 进行一些可视化。 但是当我尝试进行可视化时,我总是会收到以下错误。

以下是我的代码。

#Boxplot and histogram of Total Direct Variable Cost grouped by with or with Financial Class
import chart_studio.plotly as py

from  plotly.offline import iplot
trace0 = go.Box(
    y=healthcare.loc[healthcare['A'] == 'Inpatient']['B'],
    name = 'Inpatient',
    marker = dict(
        color = 'rgb(214, 12, 140)',
    )
)
trace1 = go.Box(
    y=healthcare.loc[healthcare['A'] == 'InBorn']['B'],
    name = 'InBorn',
    marker = dict(
        color = 'rgb(0, 128, 128)',
    )
)
data = [trace0, trace1]
layout = go.Layout(
    title = "CCCCCCCCCCCC"
)

fig = go.Figure(data=data,layout=layout)
py.iplot(fig)

【问题讨论】:

  • 您介意添加完整的mcve吗?
  • 那你还在用python2吗?考虑到从 4.0 版开始,plotly 仅离线,因此您无需再致电 plotly.offline

标签: python plotly


【解决方案1】:

我遇到了同样的问题,所以我把py.iplot(fig)改成了fig.show()

【讨论】:

    【解决方案2】:

    阅读:https://plotly.com/python/troubleshooting/

    对于 Jupyter 经典笔记本:

    import plotly.io as pio
    pio.renderers.default='notebook'
    

    然后如上所述使用 fig.show()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-28
      • 2020-07-22
      • 2021-11-29
      • 2019-04-26
      • 2020-01-11
      • 2019-07-29
      • 2019-06-11
      • 2019-05-25
      相关资源
      最近更新 更多