.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_pyplots_whats_new_99_spines.py: ===================== Whats New 0.99 Spines ===================== .. code-block:: default import matplotlib.pyplot as plt import numpy as np def adjust_spines(ax,spines): for loc, spine in ax.spines.items(): if loc in spines: spine.set_position(('outward', 10)) # outward by 10 points else: spine.set_color('none') # don't draw spine # turn off ticks where there is no spine if 'left' in spines: ax.yaxis.set_ticks_position('left') else: # no yaxis ticks ax.yaxis.set_ticks([]) if 'bottom' in spines: ax.xaxis.set_ticks_position('bottom') else: # no xaxis ticks ax.xaxis.set_ticks([]) fig = plt.figure() x = np.linspace(0,2*np.pi,100) y = 2*np.sin(x) ax = fig.add_subplot(2,2,1) ax.plot(x,y) adjust_spines(ax,['left']) ax = fig.add_subplot(2,2,2) ax.plot(x,y) adjust_spines(ax,[]) ax = fig.add_subplot(2,2,3) ax.plot(x,y) adjust_spines(ax,['left','bottom']) ax = fig.add_subplot(2,2,4) ax.plot(x,y) adjust_spines(ax,['bottom']) plt.show() .. image:: /gallery/pyplots/images/sphx_glr_whats_new_99_spines_001.png :class: sphx-glr-single-img ------------ References """""""""" The use of the following functions, methods, classes and modules is shown in this example: .. code-block:: default import matplotlib matplotlib.axis.Axis.set_ticks matplotlib.axis.XAxis.set_ticks_position matplotlib.axis.YAxis.set_ticks_position matplotlib.spines matplotlib.spines.Spine matplotlib.spines.Spine.set_color matplotlib.spines.Spine.set_position .. _sphx_glr_download_gallery_pyplots_whats_new_99_spines.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: whats_new_99_spines.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: whats_new_99_spines.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_