.icicle()
Anonymous contributor
Published Feb 21, 2025
Contribute to Docs
In Plotly, the .icicle()
function under the plotly.express
module is used to create icicle charts, which are hierarchical visualizations similar to sunburst charts and treemaps. Icicle charts display hierarchical data with nested rectangles, where each level of the hierarchy is represented as a segment. This chart type is useful for visualizing multi-level categorical data in a structured and intuitive way.
Syntax
plotly.express.icicle(data_frame=None, path=None, values=None, color=None, color_continuous_scale=None, title=None, ...)
data_frame
: The Pandas DataFrame containing hierarchical data.path
: A list of column names representing different levels of the hierarchy.values
(Optional): The column that defines the values of the segments.color
(Optional): The column used for segment coloring.color_continuous_scale
(Optional): A color scale for continuous data.title
(Optional): The title of the icicle chart.
Note: The ellipsis (…) indicates that there can be additional optional parameters beyond those listed here.
Example
The following example demonstrates the usage of the .icicle()
function:
import plotly.express as pximport pandas as pd# Create a sample hierarchical datasetdata = pd.DataFrame({"Region": ["World", "World", "World", "Asia", "Asia", "Europe", "Europe"],"Country": ["Asia", "Europe", "America", "China", "India", "Germany", "France"],"Population": [4600, 750, 1000, 1400, 1300, 83, 67]})# Create an icicle chartchart = px.icicle(data_frame=data,path=["Region", "Country"],values="Population",color="Population",color_continuous_scale="Viridis",title="Population Distribution in Different Regions")# Display the icicle chartchart.show()
The above code produces the following output:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python:Plotly on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours