Skip to content

Commit 54c36b7

Browse files
authored
CI: Improve example dataset usage (#3020)
* Convert regression plot docstrings to notebooks * Convert matrix API exapmles to notebooks * Remove dataset cache from test workflow and cache using git clone in doc build
1 parent 9aca86c commit 54c36b7

File tree

8 files changed

+930
-352
lines changed

8 files changed

+930
-352
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
env:
1313
NB_KERNEL: python
1414
MPLBACKEND: Agg
15+
SEABORN_DATA: ~/seaborn-data
1516

1617
jobs:
1718
build-docs:
@@ -34,7 +35,8 @@ jobs:
3435
sudo apt-get install pandoc
3536
3637
- name: Cache datasets
37-
run: python ci/cache_datasets.py
38+
run: |
39+
git clone https://github.com/mwaskom/seaborn-data.git
3840
3941
- name: Build docs
4042
env:
@@ -80,9 +82,6 @@ jobs:
8082
if [[ ${{matrix.deps }} == 'pinned' ]]; then DEPS='-r ci/deps_pinned.txt'; fi
8183
pip install .[dev$EXTRAS] $DEPS
8284
83-
- name: Cache datasets
84-
run: python ci/cache_datasets.py
85-
8685
- name: Run tests
8786
run: make ${{ matrix.target }}
8887

doc/_docstrings/clustermap.ipynb

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "ffc1e1d9-fa74-4121-aa87-e1a8665e4c2b",
7+
"metadata": {
8+
"tags": [
9+
"hide"
10+
]
11+
},
12+
"outputs": [],
13+
"source": [
14+
"import seaborn as sns\n",
15+
"sns.set_theme()"
16+
]
17+
},
18+
{
19+
"cell_type": "raw",
20+
"id": "41b4f602-32af-44f8-bf1a-0f1695c9abbb",
21+
"metadata": {},
22+
"source": [
23+
"Plot a heatmap with row and column clustering:"
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"id": "c715bd8f-cf5d-4caa-9244-336b3d0248a8",
30+
"metadata": {},
31+
"outputs": [],
32+
"source": [
33+
"iris = sns.load_dataset(\"iris\")\n",
34+
"species = iris.pop(\"species\")\n",
35+
"sns.clustermap(iris)"
36+
]
37+
},
38+
{
39+
"cell_type": "raw",
40+
"id": "1cc3134c-579a-442a-97d8-a878651ce90a",
41+
"metadata": {},
42+
"source": [
43+
"Change the size and layout of the figure:"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"id": "fd33cf4b-9589-4b9a-a246-0b95bad28c51",
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"sns.clustermap(\n",
54+
" iris,\n",
55+
" figsize=(7, 5),\n",
56+
" row_cluster=False,\n",
57+
" dendrogram_ratio=(.1, .2),\n",
58+
" cbar_pos=(0, .2, .03, .4)\n",
59+
")"
60+
]
61+
},
62+
{
63+
"cell_type": "raw",
64+
"id": "c5d3408d-f5d6-4045-9d61-15573a981587",
65+
"metadata": {},
66+
"source": [
67+
"Add colored labels to identify observations:"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"id": "79d3fe52-6146-4f33-a39a-1d4a47243ea5",
74+
"metadata": {},
75+
"outputs": [],
76+
"source": [
77+
"lut = dict(zip(species.unique(), \"rbg\"))\n",
78+
"row_colors = species.map(lut)\n",
79+
"sns.clustermap(iris, row_colors=row_colors)"
80+
]
81+
},
82+
{
83+
"cell_type": "raw",
84+
"id": "f2f944e2-36cd-4653-86b4-6d2affec13d6",
85+
"metadata": {},
86+
"source": [
87+
"Use a different colormap and adjust the limits of the color range:"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": null,
93+
"id": "6137c7ad-db92-47b8-9d00-3228c4e1f7df",
94+
"metadata": {},
95+
"outputs": [],
96+
"source": [
97+
"sns.clustermap(iris, cmap=\"mako\", vmin=0, vmax=10)"
98+
]
99+
},
100+
{
101+
"cell_type": "raw",
102+
"id": "93f96d1c-9d04-464f-93c9-4319caa8504a",
103+
"metadata": {},
104+
"source": [
105+
"Use differente clustering parameters:"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": null,
111+
"id": "f9e76bde-a222-4eca-971f-54f56ad53281",
112+
"metadata": {},
113+
"outputs": [],
114+
"source": [
115+
"sns.clustermap(iris, metric=\"correlation\", method=\"single\")"
116+
]
117+
},
118+
{
119+
"cell_type": "raw",
120+
"id": "ea6ed3fd-188d-4244-adac-ec0169c02205",
121+
"metadata": {},
122+
"source": [
123+
"Standardize the data within the columns:"
124+
]
125+
},
126+
{
127+
"cell_type": "code",
128+
"execution_count": null,
129+
"id": "e5f744c4-b959-4ed1-b2cf-6046c9214568",
130+
"metadata": {},
131+
"outputs": [],
132+
"source": [
133+
"sns.clustermap(iris, standard_scale=1)"
134+
]
135+
},
136+
{
137+
"cell_type": "raw",
138+
"id": "7ca72242-4eb0-4f8e-b0c0-d1ef7166b738",
139+
"metadata": {},
140+
"source": [
141+
"Normalize the data within rows:"
142+
]
143+
},
144+
{
145+
"cell_type": "code",
146+
"execution_count": null,
147+
"id": "33815c4c-9bae-4226-bd11-3dfdb7ecab2b",
148+
"metadata": {},
149+
"outputs": [],
150+
"source": [
151+
"sns.clustermap(iris, z_score=0, cmap=\"vlag\", center=0)"
152+
]
153+
},
154+
{
155+
"cell_type": "code",
156+
"execution_count": null,
157+
"id": "0f37d57a-b049-4665-9c24-4d5fbbca00ba",
158+
"metadata": {},
159+
"outputs": [],
160+
"source": []
161+
}
162+
],
163+
"metadata": {
164+
"kernelspec": {
165+
"display_name": "py310",
166+
"language": "python",
167+
"name": "py310"
168+
},
169+
"language_info": {
170+
"codemirror_mode": {
171+
"name": "ipython",
172+
"version": 3
173+
},
174+
"file_extension": ".py",
175+
"mimetype": "text/x-python",
176+
"name": "python",
177+
"nbconvert_exporter": "python",
178+
"pygments_lexer": "ipython3",
179+
"version": "3.10.0"
180+
}
181+
},
182+
"nbformat": 4,
183+
"nbformat_minor": 5
184+
}

0 commit comments

Comments
 (0)