scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.89k stars 594 forks source link

PCA don't return `Axes` #1537

Open djbios opened 3 years ago

djbios commented 3 years ago

https://github.com/theislab/scanpy/blob/8d9eec4c4763edb4a522dbec3fa5ea48832ff0f8/scanpy/plotting/_tools/__init__.py#L139 Cant use mpl axis after pca_variance_ratio and other PCA plots in my code, because they never returns from function

ivirshup commented 3 years ago

@djbios you should be able to work around this by getting the current figures via plt.gca() (get current axis) and plt.gcf() (get current figure).

@fidelram, how should we handle this?

The documentation suggests that these functions will return Axes, though many of them don't operate on single Axes and instead have GridSpecs/ Figures.

Could we do a pass over all plotting functions and normalize the behaviour for these arguments?

djbios commented 3 years ago

@djbios you should be able to work around this by getting the current figures via plt.gca() (get current axis) and plt.gcf() (get current figure).

Thanks, thats works