.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "plot_types/stats/hist2d.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_plot_types_stats_hist2d.py: ============ hist2d(x, y) ============ See `~matplotlib.axes.Axes.hist2d`. .. GENERATED FROM PYTHON SOURCE LINES 8-26 .. image-sg:: /plot_types/stats/images/sphx_glr_hist2d_001.png :alt: hist2d :srcset: /plot_types/stats/images/sphx_glr_hist2d_001.png, /plot_types/stats/images/sphx_glr_hist2d_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.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1))) ax.set(xlim=(-2, 2), ylim=(-3, 3)) plt.show() .. _sphx_glr_download_plot_types_stats_hist2d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hist2d.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hist2d.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_