def despine(fig=None, ax=None, top=True, right=True,
left=False, bottom=False):
"""Remove the top and right spines from plot(s).
fig : matplotlib figure
figure to despine all axes of, default uses current figure
ax : matplotlib axes
specific axes object to despine
top, right, left, bottom : boolean
if True, remove that spine
"""
if fig is None and ax is None:
axes = plt.gcf().axes
elif fig is not None:
axes = fig.axes
elif ax is not None:
axes = [ax]
for ax_i in axes:
for side in ["top", "right", "left", "bottom"]:
ax_i.spines[side].set_visible(not locals()[side])
评论列表
文章目录