Set Color of Treemap Sectors
To change the color sector in treemap there are three different ways:
- marker.colors
- colorway
- colorscale
Example:
Python3
import plotly.graph_objects as go fig = go.Figure(go.Treemap( labels = [ "A" , "B" , "C" , "D" , "E" ], parents = [" ", " A ", " B ", " C ", " A"], marker_colors = [ "blue" , "pink" , "red" , "royalblue" , "lightgray" , ] )) fig.show() |
Output:
Treemap using graph_objects class in plotly
Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.