属性错误:模块'plotly.express'没有属性'sunburst'。

问题描述 投票:-1回答:1

属性错误:模块'plotly.express'没有属性'sunburst'。

我的错误代码。

import plotly.express as px
import numpy as np
df = px.data.gapminder().query("year == 1957")
fig = px.sunburst(df, path=['continent', 'country'], values='pop',
                  color='gdpPercap', hover_data=['iso_alpha'],
                  color_continuous_scale='gdpPercap',
                  color_continuous_midpoint=np.average(df['gdpPercap'], weights=df['pop']))
fig.show()

错误信息:AttributeError: module 'plotly.express' has no attribute 'sunburst' My wrong code: import plotly.express as px import numpy as np df = px.express:

AttributeError        Traceback (most recent call last

<ipython-input-25-228e1998d41a> in <module>()
      2 import numpy as np
      3 df = px.data.gapminder().query("year == 1957")
----> 4 fig = px.sunburst(df, path=['continent', 'country'], values='pop',
      5                   color='gdpPercap', hover_data=['iso_alpha'],
      6                   color_continuous_scale='gdpPercap', ```

AttributeError: module 'plotly.express' has no attribute 'sunburst'
python plotly data-visualization
1个回答
0
投票

sunburst 是在版本中加入的 4.4.0 的版本,所以如果您有一个旧的版本,您需要更新模块

© www.soinside.com 2019 - 2024. All rights reserved.