def hide_spines():
    """Hides the top and rightmost axis spines from view for all active
    figures and their respective axes."""
figures = [x for x in matplotlib._pylab_helpers.Gcf.get_all_fig_managers()]
for figure in figures:
    for ax in figure.canvas.figure.get_axes():
        ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
hide_spines()
show()
Setting spines in matplotlibrc