Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow both 'on data' legend together with legend on righ-hand side of plot #3401

Open
mumichae opened this issue Dec 13, 2024 · 1 comment
Open

Comments

@mumichae
Copy link
Contributor

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:

elif legend_loc not in {None, "none"}:
for label in cats:
ax.scatter([], [], c=palette[label], label=label)
if legend_loc == "right margin":

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.

@mumichae mumichae added Enhancement ✨ Triage 🩺 This issue needs to be triaged by a maintainer labels Dec 13, 2024
@flying-sheep flying-sheep added Area - Plotting 🌺 Area – API API design and removed Enhancement ✨ Triage 🩺 This issue needs to be triaged by a maintainer labels Dec 16, 2024
@flying-sheep
Copy link
Member

I think the best way to do this is to switch this plot type to an object-oriented API (like E.g. DotPlot) and call add_legend twice with different arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants