Created
May 5, 2020 01:26
-
-
Save dmyersturnbull/7fff6a1f9cad76bf8cb82772beb7cf8b to your computer and use it in GitHub Desktop.
Remove spines on a matplotlib figure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.axes import Axes | |
@classmethod | |
def despine(cls, ax: Axes) -> Axes: | |
""" | |
Removes all spines and ticks on an Axes. | |
""" | |
ax.set_yticks([]) | |
ax.set_yticks([]) | |
ax.set_xticklabels([]) | |
ax.set_yticklabels([]) | |
ax.spines['top'].set_visible(False) | |
ax.spines['bottom'].set_visible(False) | |
ax.spines['right'].set_visible(False) | |
ax.spines['left'].set_visible(False) | |
ax.get_xaxis().set_ticks([]) | |
ax.get_yaxis().set_ticks([]) | |
return ax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment