
.. 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

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_gallery_subplots_axes_and_figures_axis_labels_demo.py>`
        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:: /gallery/subplots_axes_and_figures/images/sphx_glr_axis_labels_demo_001.png
    :alt: axis labels demo
    :class: sphx-glr-single-img





.. code-block:: default

    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
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: axis_labels_demo.py <axis_labels_demo.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: axis_labels_demo.ipynb <axis_labels_demo.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
