Skip to content

Commit 6855232

Browse files
committed
feat(plotting): Add group_cmaps to sc.pl.dotplot for custom per-group coloring
- Adds the group_cmaps parameter to sc.pl.dotplot, allowing users to specify a unique colormap for each group. - Implements a corresponding stacked colorbar legend (_plot_stacked_colorbars) to display the multiple colormaps, with group labels for clarity. - Adds robust error handling, raising a ValueError if a plotted group is not defined in the group_cmaps dictionary. - Fixes a pre-existing layout bug (dots overlapping in size legend, especially when dendrogram=True) by setting the legends width to 2.0 (compared to DEFAULT_LEGENDS_WIDTH = 1.5) inside the dotplot wrapper function. - Refactors data preparation logic from DotPlot.__init__ into a new _prepare_dot_data helper method. This was done to improve code quality and resolve pre-commit linter errors related to complexity. - Includes comprehensive tests for the new functionality, swap-axis compatibility, and error conditions.
1 parent f5d5855 commit 6855232

File tree

17 files changed

+282
-77
lines changed

17 files changed

+282
-77
lines changed

docs/release-notes/3764.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- {func}`scanpy.pl.dotplot` now supports a `group_cmaps` parameter for custom per-group coloring.

src/scanpy/plotting/_dotplot.py

Lines changed: 228 additions & 77 deletions
Large diffs are not rendered by default.

tests/_images/dotplot/expected.png

-958 Bytes
Loading
-2.05 KB
Loading
-1.35 KB
Loading
-766 Bytes
Loading
-939 Bytes
Loading
16.2 KB
Loading
15.8 KB
Loading
-1.6 KB
Loading

0 commit comments

Comments
 (0)