Bugger_man
Bugger_man

Reputation: 25

How to change treemap color scale on "Dash example - modal treemap"

I try to change color scale on example (modal treemap).

https://dash-example-index.herokuapp.com/modal-treemap

I added color definition to treemap call but it does not change the color. Where I need to put my modification to make it active.

fig = px.treemap(
            dff, path=[px.Constant("all"), "Segment", "Region"], 
            values="profit_derived", 
            **color_continuous_scale=px.colors.diverging.RdYlGn[::-1]**
            
                )

Example of dff:

,profit_derived,Segment,Region,ship_date
0,5.4,Corporate,North Asia,2014-08-19
1,2.3616,Consumer,South,2014-04-17
2,3.401,Consumer,West,2012-10-17
3,22.92,Consumer,Caribbean,2013-06-15
4,6.9,Corporate,North Asia,2014-09-18
5,42.3,Home Office,EMEA,2013-10-27
6,101.64,Consumer,North,2011-08-15

Upvotes: 1

Views: 251

Answers (1)

Hamzah Al-Qadasi
Hamzah Al-Qadasi

Reputation: 9786

You should use color_continuous_scale along with color to be able to see the impact of the colors. You can use the following:

fig = px.treemap(
            dff, path=[px.Constant("all"), "Segment", "Region"], 
            values="profit_derived", 
            color="profit_derived",
            color_continuous_scale="RdYlGn"
            
                )
fig.show()

Output:

enter image description here

Upvotes: 1

Related Questions