
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "plot_types/stats/hexbin.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

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

        Click :ref:`here <sphx_glr_download_plot_types_stats_hexbin.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_plot_types_stats_hexbin.py:


===============
hexbin(x, y, C)
===============

See `~matplotlib.axes.Axes.hexbin`.

.. GENERATED FROM PYTHON SOURCE LINES 8-26



.. image-sg:: /plot_types/stats/images/sphx_glr_hexbin_001.png
   :alt: hexbin
   :srcset: /plot_types/stats/images/sphx_glr_hexbin_001.png, /plot_types/stats/images/sphx_glr_hexbin_001_2_0x.png 2.0x
   :class: sphx-glr-single-img





.. code-block:: default

    import matplotlib.pyplot as plt
    import numpy as np

    plt.style.use('_mpl-gallery-nogrid')

    # make data: correlated + noise
    np.random.seed(1)
    x = np.random.randn(5000)
    y = 1.2 * x + np.random.randn(5000) / 3

    # plot:
    fig, ax = plt.subplots()

    ax.hexbin(x, y, gridsize=20)

    ax.set(xlim=(-2, 2), ylim=(-3, 3))

    plt.show()


.. _sphx_glr_download_plot_types_stats_hexbin.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: hexbin.py <hexbin.py>`



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

     :download:`Download Jupyter notebook: hexbin.ipynb <hexbin.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>`_
