Skip to content

editing output of scanpy dotplot and other figures #979

Closed

Description

@dylkot

In the scanpy documentation for sc.pl.dotplot, it indicates that it returns a list of matplotlib.axes.Axes

However, this is not true, it returns a gridspec object instead.

I noticed this because I wanted to make some subtle edits to the results to enhance the figure such as changing axis labels, adding overlapping lines to delineate the marker genes for each cell type, etc. But I am struggling to do so.

I am wondering how the API intends for us to interact with the gridspec object returned to modify the figure. If I edit the code to return the figure object as well as the gridspec, I can access the axis like so

ax = fig.add_subplot(gs[1,0])

but I can't seem to overwrite the default axis labels or add new lines as commands like

ax.set_ylabel('new label')

Don't change the figure at all.

This is all Scanpy 1.4.5.post1 but it was the same for 1.4.4.post1

Thanks!

Versions:

scanpy==1.4.5.post1 anndata==0.6.22.post1 umap==0.4.0 numpy==1.17.2 scipy==1.3.1 pandas==0.25.1 scikit-learn==0.21.3 statsmodels==0.10.1 python-igraph==0.7.1 louvain==0.6.1

but the same things happened with scanpy==1.4.4.post1

...

Activity

  1. atarashansky commented on Feb 21, 2020

    @atarashansky

    Just opened a PR to fix this. Quoting from the PR (#1069):

    Note that if you wish to modify the figure in the same jupyter notebook cell in which the plotting function is called, you should set show=False:

    fig,ax = sc.pl.dotplot(adata,var_names,show=False)
    ax.set_xlabel('test')
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions