Skip to content

Commit 3e14801

Browse files
authored
Add colour and palettes tutorial (#4)
1 parent 3df9d61 commit 3e14801

8 files changed

Lines changed: 868 additions & 61 deletions

File tree

.github/workflows/execute.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ jobs:
7979
- name: Re-execute selected notebooks
8080
if: steps.pick.outputs.files != ''
8181
run: |
82+
# Pin kernel_name to python3 so notebooks committed with a
83+
# contributor-local kernel name (e.g. from a pixi `kernel-install`
84+
# task) still execute against CI's stock python3 kernel.
8285
while IFS= read -r nb; do
8386
[ -z "$nb" ] && continue
8487
echo "Executing $nb"
85-
jupyter nbconvert --to notebook --execute --inplace "$nb"
88+
jupyter nbconvert --to notebook --execute --inplace \
89+
--ExecutePreprocessor.kernel_name=python3 "$nb"
8690
done <<< "${{ steps.pick.outputs.files }}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ dist/
1515
env/
1616
venv/
1717
ENV/
18+
.pixi/
19+
pixi.lock
1820

1921
# Editors
2022
.idea/

examples/visium_mouse_brain.ipynb

Lines changed: 58 additions & 59 deletions
Large diffs are not rendered by default.

examples/visium_mouse_brain.png

395 KB
Loading

pyproject.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ authors = [{ name = "scverse" }]
1616
# the notebooks end-to-end.
1717
[project.optional-dependencies]
1818
exec = [
19-
"spatialdata-plot>=0.3",
19+
"spatialdata-plot>=0.3.4",
2020
"squidpy",
2121
"jupyter",
2222
"ipykernel",
@@ -35,6 +35,28 @@ Documentation = "https://spatialdata.scverse.org/projects/plot/en/latest/"
3535
[tool.hatch.build.targets.wheel]
3636
bypass-selection = true
3737

38+
# Pixi-managed environment for running and authoring the notebooks. After
39+
# `pixi install`, register the Jupyter kernel once with `pixi run
40+
# kernel-install`; the kernel will point at the pixi env's Python, so
41+
# `pixi run lab` (or any external Jupyter) can execute the notebooks
42+
# against the exact pinned dependencies.
43+
[tool.pixi]
44+
workspace.channels = ["conda-forge"]
45+
workspace.platforms = ["linux-64", "osx-arm64"]
46+
47+
dependencies.python = ">=3.11"
48+
dependencies.jupyterlab = "*"
49+
dependencies.ipykernel = "*"
50+
dependencies.nbconvert = "*"
51+
dependencies.watermark = "*"
52+
53+
pypi-dependencies.spatialdata-plot = ">=0.3"
54+
pypi-dependencies.squidpy = "*"
55+
56+
tasks.kernel-install = 'python -m ipykernel install --user --name sdata-plot-notebooks --display-name "sdata-plot-notebooks"'
57+
tasks.lab = "jupyter lab"
58+
tasks.execute = "jupyter nbconvert --to notebook --execute --inplace tutorials/*.ipynb examples/*.ipynb"
59+
3860
[tool.ruff]
3961
line-length = 120
4062
target-version = "py311"

tutorials/color_and_palette.ipynb

Lines changed: 769 additions & 0 deletions
Large diffs are not rendered by default.

tutorials/color_and_palette.png

50.2 KB
Loading

tutorials/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,22 @@ The fluent `.pl` API, layering, and styling on the in-memory `blobs`
1414
dataset. Ideal first read.
1515
:::
1616

17+
:::{grid-item-card} Colour and palettes
18+
:link: color_and_palette
19+
:link-type: doc
20+
:img-top: color_and_palette.png
21+
22+
How `color=` resolves, the v0.3.0 `groups` behaviour, and building
23+
perceptually well-spaced or colourblind-safe palettes with
24+
`make_palette` and `make_palette_from_data`.
25+
:::
26+
1727
::::
1828

1929
```{toctree}
2030
:hidden:
2131
:maxdepth: 1
2232
2333
getting_started
34+
color_and_palette
2435
```

0 commit comments

Comments
 (0)