.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/subplots_axes_and_figures/axis_labels_demo.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_subplots_axes_and_figures_axis_labels_demo.py: =================== Axis Label Position =================== Choose axis label position when calling `~.Axes.set_xlabel` and `~.Axes.set_ylabel` as well as for colorbar. .. GENERATED FROM PYTHON SOURCE LINES 10-21 .. image-sg:: /gallery/subplots_axes_and_figures/images/sphx_glr_axis_labels_demo_001.png :alt: axis labels demo :srcset: /gallery/subplots_axes_and_figures/images/sphx_glr_axis_labels_demo_001.png, /gallery/subplots_axes_and_figures/images/sphx_glr_axis_labels_demo_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt fig, ax = plt.subplots() sc = ax.scatter([1, 2], [1, 2], c=[1, 2]) ax.set_ylabel('YLabel', loc='top') ax.set_xlabel('XLabel', loc='left') cbar = fig.colorbar(sc) cbar.set_label("ZLabel", loc='top') plt.show() .. _sphx_glr_download_gallery_subplots_axes_and_figures_axis_labels_demo.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: axis_labels_demo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: axis_labels_demo.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_