Skip to content

Better document legend_loc=None for embedding plots #1502

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

Closed
1 of 5 tasks
dagarfield opened this issue Nov 19, 2020 · 5 comments · Fixed by #1821
Closed
1 of 5 tasks

Better document legend_loc=None for embedding plots #1502

dagarfield opened this issue Nov 19, 2020 · 5 comments · Fixed by #1821
Labels
Area - Documentation 📒 good first issue easy first issue to get started in OSS community contribution!

Comments

@dagarfield
Copy link

dagarfield commented Nov 19, 2020

  • Additional function parameters / changed functionality / changed defaults?
  • New analysis tool: A simple analysis tool you have been using and are missing in sc.tools?
  • New plotting function: A kind of plot you would like to seein sc.pl?
  • External tools: Do you know an existing package that should go into sc.external.*?
  • Other?

It is a lovely tool, but it would be great to be able to not plot figure legends in, e.g. sc.pl.umap, so that all plots (regardless of what annotation is being colored) are exactly the same size. Perhaps there is already a way to do this, but I've yet to find it.

Thanks!

@ivirshup
Copy link
Member

You can pass legend_loc=None.

Thanks for noting this. Looking at the docs, I can definitely see how this isn't clear.

legend_loc : str, optional (default: 'right margin')
    Location of legend, either `'on data'`, `'right margin'` or a valid keyword
    for the `loc` parameter of :class:`~matplotlib.legend.Legend`.

@ivirshup ivirshup changed the title Do not show legend Better document legend_loc=None for embedding plots Nov 19, 2020
@dagarfield
Copy link
Author

Tada! Works perfectly.
Thanks for the tip, and may this GitHub comment serve as substrate to all future google searches on this issue.

@ivirshup ivirshup added the good first issue easy first issue to get started in OSS community contribution! label Nov 19, 2020
@dagarfield
Copy link
Author

So one small update here -- it works like a charm for categorical variables, but not for continuous variables.
e.g.

sc.pl.umap(testData, save = fileName, color='CCL5',s=50,frameon=False,legend_loc = None)

Still gives something like a legend:
image

Presumably this is because the color strip on the right is not actually a legend in the underlying matplotlib?

@aldakata
Copy link

This should be explicitly mentioned in the docs

@flying-sheep
Copy link
Member

agreed, I’m doing a PR for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Documentation 📒 good first issue easy first issue to get started in OSS community contribution!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants