.Heatmap()
Anonymous contributor
Published Jul 24, 2024
Contribute to Docs
The .Heatmap()
function in Plotly is utilized to generate heatmap visualizations, which are graphical representations of data where the individual values contained in a matrix are represented as colors.
Syntax
plotly.graph_objects.Heatmap(x=None, y=None, z=None, colorscale=None, ...)
x
: A list of values to be used as the x-axis labels.y
: A list of values to be used as the y-axis labels.z
: The data to be visualized as a heatmap.colorscale
: The color scale to be used for the heatmap. This can be an array of colors mapped to normalized values or a string representing a built-in color scale.
Note: The ellipsis in the syntax (…) indicates that there are additional optional parameters beyond those listed here to customize the heatmap.
Example
The following example showcases the use of the .Heatmap()
function:
import plotly.graph_objects as gofig = go.Figure(data=go.Heatmap(z=[[1, None, 30],[20, 1, 60],[30, 60, 1]],x=['Monday', 'Tuesday', 'Wednesday'],y=['Morning', 'Afternoon', 'Evening'],colorscale='Viridis'))fig.update_layout(title='Activity Heatmap')fig.show()
This example creates a heatmap representing hypothetical activity levels during different times of the day across three days of the week. The value None
is used to create a gap in the data and the value colorscale
is used to customize the color scheme of the heatmap.
The above code generates 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