Skip to content

Commit 10fe134

Browse files
VladimirShitovpre-commit-ci[bot]flying-sheep
authored
feat: add dotplot variant (#3890)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Phil Schaf <flying-sheep@web.de>
1 parent b722d8a commit 10fe134

6 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/scanpy/plotting/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
violin,
1616
)
1717
from ._dotplot import DotPlot, dotplot
18+
from ._easter_egg import dogplot
1819
from ._matrixplot import MatrixPlot, matrixplot
1920
from ._preprocessing import filter_genes_dispersion, highly_variable_genes
2021
from ._qc import highest_expr_genes
@@ -63,6 +64,7 @@
6364
"correlation_matrix",
6465
"dendrogram",
6566
"diffmap",
67+
"dogplot",
6668
"dotplot",
6769
"dpt_groups_pseudotime",
6870
"dpt_timeseries",

src/scanpy/plotting/_easter_egg.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from __future__ import annotations
2+
3+
from importlib.resources import files
4+
5+
import numpy as np
6+
from matplotlib import pyplot as plt
7+
from matplotlib.image import imread
8+
9+
10+
def dogplot(*_, **__) -> None:
11+
"""Show who’s a good boy."""
12+
rng = np.random.default_rng()
13+
n = int(rng.integers(1, 4))
14+
img_path = files("scanpy.plotting") / f"dogplot_images/doggo_{n}.webp"
15+
with img_path.open("rb") as f:
16+
img = imread(f)
17+
18+
_, ax = plt.subplots(figsize=(3, 3))
19+
ax.imshow(img)
20+
ax.set_axis_off()
3.88 KB
Loading
6.7 KB
Loading
6.34 KB
Loading

tests/test_plotting.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,3 +1851,8 @@ def test_violin_scale_warning(monkeypatch):
18511851
monkeypatch.setattr(sc.pl.StackedViolin, "DEFAULT_SCALE", "count", raising=False)
18521852
with pytest.warns(FutureWarning, match="Don’t set DEFAULT_SCALE"):
18531853
sc.pl.StackedViolin(adata, adata.var_names[:3], groupby="louvain")
1854+
1855+
1856+
def test_dogplot() -> None:
1857+
"""Test that the dogplot function runs without errors."""
1858+
sc.pl.dogplot()

0 commit comments

Comments
 (0)