.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "plot_types/statistical/hist2d.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. 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_plot_types_statistical_hist2d.py: 2D Histogram ============ Bivariate histogram using :class:`Hist2D` with a colorbar. .. GENERATED FROM PYTHON SOURCE LINES 7-35 .. image-sg:: /plot_types/statistical/images/sphx_glr_hist2d_001.png :alt: 2D Histogram :srcset: /plot_types/statistical/images/sphx_glr_hist2d_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from emcpy.plots.plots import Hist2D from emcpy.plots.create_plots import CreatePlot, CreateFigure rng = np.random.default_rng(7) x = rng.normal(size=6000) y = 0.8 * x + rng.normal(scale=0.6, size=x.size) p = CreatePlot() layers = [] h2 = Hist2D(x, y) h2.bins = (45, 45) h2.cmap = "magma" layers.append(h2) p.plot_layers = layers p.add_title("2D Histogram") p.add_xlabel("x") p.add_ylabel("y") p.add_grid(alpha=0.2) p.add_colorbar(label="count") fig = CreateFigure(1, 1, figsize=(6.8, 5.2)) fig.plot_list = [p] fig.create_figure() fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.100 seconds) .. _sphx_glr_download_plot_types_statistical_hist2d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hist2d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hist2d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: hist2d.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_