Skip to content

Instantly share code, notes, and snippets.

@mxposed
Created May 16, 2022 20:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxposed/0322cdc7734e8e58dd33de8323a2e308 to your computer and use it in GitHub Desktop.
Save mxposed/0322cdc7734e8e58dd33de8323a2e308 to your computer and use it in GitHub Desktop.
fig, ax = plt.subplots(figsize=(8, 8))
sc.pl.umap(ds, color="cell_type", legend_loc="on data", size=10, ax=ax, show=False)
shrink_by = 0.1
xlim = ax.get_xlim()
ylim = ax.get_ylim()
xbound = xlim[0] + (xlim[1] - xlim[0]) * shrink_by
ybound = ylim[0] + (ylim[1] - ylim[0]) * shrink_by
b = ax.spines["bottom"]
b.set_bounds(xlim[0], xbound)
ax.set_xlabel(ax.get_xlabel(), x=0, ha="left")
ax.plot(xbound, 0, ">k", transform=ax.get_xaxis_transform(), clip_on=False)
b = ax.spines["left"]
b.set_bounds(ylim[0], ybound)
ax.set_ylabel(ax.get_ylabel(), y=0, ha="left")
ax.plot(0, ybound, "^k", transform=ax.get_yaxis_transform(), clip_on=False)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment