Continuous color scale not appearing in treemap

Hereā€™s the code and example data.

Iā€™ve tried different data and different color scales.

I canā€™t figure out what the issue here is.

Iā€™ve multiple locations, and the color scheme is based on when the first location was established in the country. The size of the treemap is created from the count of locations.

Iā€™ve running the code in pycharm


data_treemap['world'] = 'world'											
fig = px.treemap(data_treemap, path=['world','continent','country.name', 'city.state','city.name'], values='count',											
                 color='established', color_continuous_scale='RdBu',hover_data=['1'], maxdepth=3)											
											
											
plotly.offline.plot(fig)	

 world	continent	country.name	city.state	city.name	count	established				
0	world	North America	United States	California	San Francisco	1	1982				
1	world	North America	United States	California	San Francisco	1	1982				
2	world	Europe	Germany	Baden-WƃĀ¼rttemberg	Mannheim	1	1984				
3	world	Europe	Germany	Bavaria	Munich	1	1984				
4	world	Europe	Poland	Masovian Voivodeship	Warsaw	1	1987				
5	world	Europe	Czech Republic	HlavnƃĀ­ Mesto Praha	Prague	1	1993				
6	world	Europe	Austria	Vienna	Vienna	1	1991				
7	world	Europe	Romania	None	Bucharest	1	1999				
8	world	Asia	Russia	Moscow	Moscow	1	1991				
9	world	Asia	Estonia	Tartumaa	Tartu	1	1999				
10	world	Europe	Finland	Southern Finland	HƃĀ¤meenlinna	1	1984	```

Are you running the latest version of Plotly? Itā€™s 4.8.2.

Hi, yep running the latest version

Name: plotly
Version: 4.8.2

I ran the code in idle to check if the issue was related to pycharm but the issue persists.

OK, in this case I suspect there are some non-numerical values in your established column, which is causing Plotly Express to read this as a categorical column rather than a continuous one.

Thanks for the reply.

I double-checked the data. Looks ok.

2037 non-null int64

I tried the code with a subset of the data, and Iā€™m still having the same issu

This example works fine though.

df = px.data.gapminder().query(ā€œyear == 2007ā€)
df[ā€œworldā€] = ā€œworldā€ # in order to have a single root node
fig = px.treemap(df, path=[ā€˜worldā€™, ā€˜continentā€™, ā€˜countryā€™], values=ā€˜popā€™,
color=ā€˜lifeExpā€™, hover_data=[ā€˜iso_alphaā€™],
color_continuous_scale=ā€˜RdBuā€™,
color_continuous_midpoint=np.average(df[ā€˜lifeExpā€™], weights=df[ā€˜popā€™]))

plotly.offline.plot(fig)

It must be some other issue with my data. Iā€™ll keep investigating.

I did pd.to_numeric and itā€™s working now.

Thanks, good to know in future that thatā€™s something to check.

Not sure why I was getting that it was 2037 non-null int64 in my previous post!