Allow both 'on data' legend together with legend on righ-hand side of plot
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
What kind of feature would you like to request?
Additional function parameters / changed functionality / changed defaults?
Please describe your wishes
When plotting with "on data" legends, it's not always easy to see which label belongs to which color in the plot. Including the right-hand legend together with the "on data" labels could be a simple fix to improve readability.
I suggest to change the following lines:
as follows:
if legend_loc not in {None, "none"}:
for label in cats:
ax.scatter([], [], c=palette[label], label=label)
if legend_loc in {"on data", "right margin"}:
Note: I didn't consider any flexibility in preserving the old behaviour and/or extending the parameters to a new legend location descriptor. Personally I feel that would unnecessarily complicate the setting, but I also understand if defaults shouldn't change.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/scanpy/plotting/_tools/scatterplots.py around lines 1141-1144 and trace how legend_loc controls the plotted legend. The change is complete when using "on data" can also display the legend on the right-hand side without changing the intended behavior of other legend locations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100