繁体   English   中英

AttributeError:模块“plotly.express”没有属性“sunburst”

[英]AttributeError: module 'plotly.express' has no attribute 'sunburst'

AttributeError:模块“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        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'

sunburst是在plotly的4.4.0版本中添加的,所以如果你有之前的版本需要更新模块

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM