feat: add dotplot variant#3890
Conversation
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
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. |
| def dogplot(*_, **__) -> None: | ||
| """Shows who's a good boy""" | ||
| pic = np.random.randint(1, 4) | ||
| pic_path = HERE / "dogplot_images" / f"doggo_{pic}.jpg" |
There was a problem hiding this comment.
please use importlib.resources instead, something like:
with read_binary("scanpy.plotting", "dogplot_images", f"doggo_{pic}.jpg") as f:
img = plt.imread(f)There was a problem hiding this comment.
Thanks! Did it, using importlib.resources.files though
|
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 |
|
I changed the PR title for more sneakiness |
I recently noticed a major issue with scanpy that somehow persisted for a very long time.
scanpy.plottingis missing adogplot, 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.Here's an example output:

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:

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.