File: spreadsheet_heatmap.py

package info (click to toggle)
seaborn 0.13.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,608 kB
  • sloc: python: 37,241; makefile: 182; javascript: 45; sh: 15
file content (19 lines) | stat: -rw-r--r-- 471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Annotated heatmaps
==================

"""
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme()

# Load the example flights dataset and convert to long-form
flights_long = sns.load_dataset("flights")
flights = (
    flights_long
    .pivot(index="month", columns="year", values="passengers")
)

# Draw a heatmap with the numeric values in each cell
f, ax = plt.subplots(figsize=(9, 6))
sns.heatmap(flights, annot=True, fmt="d", linewidths=.5, ax=ax)