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

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


.. GENERATED FROM PYTHON SOURCE LINES 23-28

.. tags::

   component: axis
   styling: position
   level: beginner


.. _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 <axis_labels_demo.ipynb>`

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

      :download:`Download zipped: axis_labels_demo.zip <axis_labels_demo.zip>`


.. only:: html

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

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
