Visualizations
Heat Map
Everything you need to create beautiful, engaging, and interactive Heat Map visualizations.
Importing PlotAPI Heat Map
Let's import HeatMap
from the PlotAPI package.
from plotapi import HeatMap
We've already activated our license with the license activation instructions.
Data structure
PlotAPI Heat Map expects a matrix (list[list[float]]
) as input.
matrix = [
[0, 5, 6, 4, 7, 4],
[5, 0, 5, 4, 6, 5],
[6, 5, 0, 4, 5, 5],
[4, 4, 4, 0, 5, 5],
[7, 6, 5, 5, 0, 4],
[4, 5, 5, 5, 4, 0],
]
Optionally, we can include a list of row_names
and col_names
(list[str]
).
row_names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
col_names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
Action | Adventure | Comedy | Drama | Fantasy | Thriller | |
---|---|---|---|---|---|---|
Action | 0 | 5 | 6 | 4 | 7 | 4 |
Adventure | 5 | 0 | 5 | 4 | 6 | 5 |
Comedy | 6 | 5 | 0 | 4 | 5 | 5 |
Drama | 4 | 4 | 4 | 0 | 5 | 5 |
Fantasy | 7 | 6 | 5 | 5 | 0 | 4 |
Thriller | 4 | 5 | 5 | 5 | 4 | 0 |
Default visualization
Creating our first Heat Map Diagram is as easy as calling PlotAPI with our inputs.
Be sure to interact with the visualisation to see what the default settings can do!
With row and column names
HeatMap(matrix, row_names=row_names, col_names=col_names).show()
Without row and column names
If we omit the row_names
and col_names
, PlotAPI will auto-generate the names for us.
HeatMap(matrix).show()