.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/spines/spines_dropped.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_spines_spines_dropped.py: ============== Dropped spines ============== Demo of spines offset from the axes (a.k.a. "dropped spines"). .. GENERATED FROM PYTHON SOURCE LINES 8-38 .. image-sg:: /gallery/spines/images/sphx_glr_spines_dropped_001.png :alt: spines dropped :srcset: /gallery/spines/images/sphx_glr_spines_dropped_001.png, /gallery/spines/images/sphx_glr_spines_dropped_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np def adjust_spines(ax, visible_spines): ax.label_outer(remove_inner_ticks=True) ax.grid(color='0.9') for loc, spine in ax.spines.items(): if loc in visible_spines: spine.set_position(('outward', 10)) # outward by 10 points else: 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() .. _sphx_glr_download_gallery_spines_spines_dropped.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: spines_dropped.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: spines_dropped.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_