.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/miscellaneous/plot_histogram_2D.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_auto_examples_miscellaneous_plot_histogram_2D.py: =================== Make a 2D Histogram =================== .. GENERATED FROM PYTHON SOURCE LINES 7-28 .. image-sg:: /auto_examples/miscellaneous/images/sphx_glr_plot_histogram_2D_001.png :alt: plot histogram 2D :srcset: /auto_examples/miscellaneous/images/sphx_glr_plot_histogram_2D_001.png :class: sphx-glr-single-img .. code-block:: Python import timeit import tttrlib import numpy as np import pylab as p def histogram2d(data, bins): h = tttrlib.doubleHistogram() h.set_axis(0, "x", -3, 3, bins, 'lin') h.set_axis(1, "y", -3, 3, bins, 'lin') h.update(data.T) return h.get_histogram().reshape((bins, bins)) x = np.random.randn(10000) y = 0.2 * np.random.randn(10000) data = np.vstack([x, y]) bins = 100 hist2d = histogram2d(data, 100) p.imshow(hist2d) p.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.100 seconds) .. _sphx_glr_download_auto_examples_miscellaneous_plot_histogram_2D.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_histogram_2D.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_histogram_2D.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_