scanpy
scanpy copied to clipboard
sc.pl.umap(... legend_loc='upper right') does not work
From the scanpy docs:
legend_loc : str (default: 'right margin')
Location of legend, either 'on data', 'right margin' or a valid keyword for the loc parameter of Legend.
From the matplotlib Legend
docs:
The strings 'upper left', 'upper right', 'lower left', 'lower right' place the legend at the corresponding corner of the axes/figure.
But
sc.pl.umap(adata, color='mouse.id', legend_loc='upper right')
does not work: the legend just disappears. When I go and inspect the legend, I find that ax.legend_._loc
is 0
Location String | Location Code |
---|---|
'best' | 0 |
'upper right' | 1 |
so it isn't being properly set.
It seems like the relevant function doesn't include a conditional branch for this case: https://github.com/scverse/scanpy/blob/11d0b8e992ad145eeb3f666aa4e006bd204272de/scanpy/plotting/_tools/scatterplots.py#L1069
This is probably addressed in #2267