Get the Books
Enjoying these notebooks and want to support the work? Check out the practical books on Data Science, Visualisation, and Evolutionary Algorithms.
Get the books
Getting started with Plotapi Heat Map
Support this work
You can support this work by getting the e-books. This notebook will always be available for free in its online format.
Preamble¶
from plotapi import HeatMap
HeatMap.set_license("your username", "your license key")
Introduction¶
Our first Plotapi Heat Map Diagram! As we can see, we have set our license details in the preamble with HeatMap.set_license()
Dataset¶
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],
]
row_names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
col_names = ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
Optionally, we can include a list of row_names
and col_names
(list[str]
).
It may look more clear if we present this as a table with the columns and indices labelled. This is entirely optional.
import pandas as pd
pd.DataFrame(matrix, columns=col_names, index=row_names)
Visualisation¶
Creating our first Heat Map Diagram is as easy as calling Plotapi with our inputs.
Here we're using .show()
which outputs to a Jupyter Notebook cell, however, we may want to output to a HTML file with .to_html()
instead. More on the different output methods later!
Be sure to interact with the visualisation to see what the default settings can do!
HeatMap(matrix, row_names=row_names, col_names=col_names).show()
If we omit the row_names
and col_names
, Plotapi will auto-generate the names for us.
HeatMap(matrix).show()
You can do so much more than what's presented in this example, and we'll cover this in later sections. If you want to see the full list of growing features, check out the Plotapi Documentation. and the Plotapi Gallery.
Support this work
You can support this work by getting the e-books. This notebook will always be available for free in its online format.
Plotapi, beautiful by default.
Let plotapi do the heavy lifting – enabling beautiful interactive visualisations with a single line of code (instead of hundreds).
Get Plotapi