Note

Go to the endto download the full example code.

Dropped spines#

Demo of spines offset from the axes (a.k.a. "dropped spines").

spines dropped
importmatplotlib.pyplotaspltimportnumpyasnpdefadjust_spines(ax,visible_spines):ax.label_outer(remove_inner_ticks=True)ax.grid(color='0.9')forloc,spineinax.spines.items():iflocinvisible_spines:spine.set_position(('outward',10))# outward by 10 pointselse:spine.set_visible(False)x=np.linspace(0,2*np.pi,100)fig,axs=plt.subplots(2,2)axs[0,0].plot(x,np.sin(x))axs[0,1].plot(x,np.cos(x))axs[1,0].plot(x,-np.cos(x))axs[1,1].plot(x,-np.sin(x))adjust_spines(axs[0,0],['left'])adjust_spines(axs[0,1],[])adjust_spines(axs[1,0],['left','bottom'])adjust_spines(axs[1,1],['bottom'])plt.show()

Gallery generated by Sphinx-Gallery