def hide_axis(where, ax=None):
ax = ax or plt.gca()
if type(where) == str:
_w = [where]
else:
_w = where
[sk.set_color('None') for k, sk in ax.spines.items() if k in _w ]
if 'top' in _w and 'bottom' in _w:
ax.xaxis.set_ticks_position('none')
elif 'top' in _w:
ax.xaxis.set_ticks_position('bottom')
elif 'bottom' in _w:
ax.xaxis.set_ticks_position('top')
if 'left' in _w and 'right' in _w:
ax.yaxis.set_ticks_position('none')
elif 'left' in _w:
ax.yaxis.set_ticks_position('right')
elif 'right' in _w:
ax.yaxis.set_ticks_position('left')
plt.draw_if_interactive()
评论列表
文章目录