I am a student and I want to use plotly.express to make a dashboard for my homework.I want to unify the colors of the company In every chart.So I use color_discrete_map to set color for each company.but it is not working in Treemap and sunburst chart.
For example:
#-----------------------------------------------------------------
df = pd.DataFrame({‘company’:[“Java”,“mongoDB”,“Python”,“C++”],
‘popularity’:[99,50,100,50]})
colors = {“Java”:‘orange’,“mongoDB”:“Red”,“Python”:“yellow”,“C++”:“green”}
px.treemap(df,path = [‘company’],values=“popularity”,color = “company”,color_discrete_map = colors).show()
px.bar(df,x = ‘company’,y=“popularity”,color = “company”,color_discrete_map = colors)
#-------------------------------------------------------------------------
In this code The color for each company of treemap does not followed color_discrete_map ,but color of bar chart has followed followed color_discrete_map
This problem has troubled me for several days.
Hope guys can help me. Thank you