mitra mirshafiee
mitra mirshafiee

Reputation: 503

ImportError: cannot import name 'Constant' from 'plotly.express'

I've been using treemap to plot some data and according to the main documentary there is something called Constant that you can add to the path of treemap. But unfortunately I couldn't import it or add it to my plot. Here is the code:

df = px.data.gapminder().query("year == 2007")
fig = px.treemap(df, path=[px.Constant('world'), 'continent', 'country'], 
                 values='pop',color='lifeExp', hover_data=['iso_alpha'])
fig.show()

When I run it I get the following error:

AttributeError: module 'plotly.express' has no attribute 'Constant'

Does anyone have any idea?

Upvotes: 1

Views: 918

Answers (1)

Starship
Starship

Reputation: 752

If you are using an old version of plotly, then running pip install --upgrade plotly should fix this issue.

Upvotes: 0

Related Questions