Skip to content

feat: add dotplot variant#3890

Merged
flying-sheep merged 11 commits into
scverse:mainfrom
VladimirShitov:main
Nov 12, 2025
Merged

feat: add dotplot variant#3890
flying-sheep merged 11 commits into
scverse:mainfrom
VladimirShitov:main

Conversation

@VladimirShitov
Copy link
Copy Markdown
Contributor

@VladimirShitov VladimirShitov commented Nov 11, 2025

I recently noticed a major issue with scanpy that somehow persisted for a very long time. scanpy.plotting is missing a dogplot, a well-known best practice in data visualisation, supported e.g., in seaborn. This PR closes this issue and makes sure scanpy keeps providing the best tools (and mood) to its users.

  • Closes #
  • Tests included

Here's an example output:
image

Images are compressed and size is reduced, so each of them now takes half the storage space as this scanpy logo.

The path to images is inferred dynamically, but perhaps we can change it later to a github link, similarly to seaborn.

Oh, and here is the signed consent from the data contributor:
image

Thank you very much, I'd be glad to incorporate any suggestions. I acknowledge Helmholtz Munich for providing enough budget for this little piece of software (it was spent on cheese for the data contributor).

And huge thanks to Daria Romanovskaya @dariarom94, who transferred the data from the contributor.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.82%. Comparing base (b722d8a) to head (55f7d71).
⚠️ Report is 38 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3890      +/-   ##
==========================================
+ Coverage   76.79%   76.82%   +0.02%     
==========================================
  Files         115      116       +1     
  Lines       12383    12398      +15     
==========================================
+ Hits         9510     9525      +15     
  Misses       2873     2873              
Flag Coverage Δ
hatch-test.pre 76.82% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/plotting/__init__.py 100.00% <100.00%> (ø)
src/scanpy/plotting/_easter_egg.py 100.00% <100.00%> (ø)

@flying-sheep
Copy link
Copy Markdown
Member

flying-sheep commented Nov 12, 2025

Great job!

The scanpy logo doesn’t end up in the package at all, just in the docs. That being said, scanpy is currently a 2.1MB download, so I’ll think about this. Maybe I can save space more easily elsewhere. /edit: no, but read on

You have the original pics, right? Can you try using an image format that isn’t older than you? Matplotlib uses Pillow, which supports JPEG 2000 and WebP, both of which run laps around JPEG.

Comment thread src/scanpy/plotting/_easter_egg.py Outdated
def dogplot(*_, **__) -> None:
"""Shows who's a good boy"""
pic = np.random.randint(1, 4)
pic_path = HERE / "dogplot_images" / f"doggo_{pic}.jpg"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use importlib.resources instead, something like:

with read_binary("scanpy.plotting", "dogplot_images", f"doggo_{pic}.jpg") as f:
    img = plt.imread(f)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Did it, using importlib.resources.files though

@VladimirShitov
Copy link
Copy Markdown
Contributor Author

Thanks @flying-sheep ! I reduced the image size a bit and used the webp format. The images now take 17 KB in total. In my humble opinion, any user with a computer younger than me can survive this overhead in exchange for a smile

@flying-sheep flying-sheep added this to the 1.12.0 milestone Nov 12, 2025
@flying-sheep flying-sheep changed the title Add a dogplot easter egg feat: add a dogplot easter egg Nov 12, 2025
@flying-sheep flying-sheep changed the title feat: add a dogplot easter egg feat: add dotplot variant Nov 12, 2025
@flying-sheep
Copy link
Copy Markdown
Member

I changed the PR title for more sneakiness

@flying-sheep flying-sheep enabled auto-merge (squash) November 12, 2025 14:54
@flying-sheep flying-sheep merged commit 10fe134 into scverse:main Nov 12, 2025
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants