feat(plotting): Add group_cmaps parameter to sc.pl.dotplot to specify unique colormaps for each group #3764
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new feature to
sc.pl.dotplot
: thegroup_cmaps
parameter. This allows users to assign a unique colormap to each category in a dot plot, which is particularly useful for creating publication-ready figures that align with a paper's established color scheme for different cell types.Key Changes
group_cmaps
parameter: Added a new parameter tosc.pl.dotplot
and theDotPlot
class that accepts a dictionary mapping group names to colormap names.group_cmaps
is used. This legend clearly displays the colormap and for each group with corresponding label.ValueError
that is raised ifgroup_cmaps
is used but a group in the plot data is not defined in the dictionary.expected.png
) for several existing dotplot tests were updated to reflect the new, corrected layout.DotPlot.__init__
method was refactored into a smaller helper function (_prepare_dot_data) to improve readability and pass the automated code complexity checks by pre-commit.swap_axes
, and confirm that the correct errors and warnings are raised.Example Plot