.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/statistics/hexbin.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_gallery_statistics_hexbin.py: ====== HexBin ====== `ax.hexbin` is a 2D histogram plot, in which the bins are hexagons and the color represents the number of data points within each bin. Unlike Matplotlib, `gridsize` (by default 100) can be only a single int. .. note:: Available with ``mpltern>=0.5.0`` .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt import mpltern np.random.seed(19680801) t, l, r = np.random.dirichlet(alpha=(2.0, 4.0, 8.0), size=100000).T .. GENERATED FROM PYTHON SOURCE LINES 23-30 .. code-block:: Python ax = plt.subplot(projection="ternary") # If "edgecolors=face" (default), small hexagons look overlapping. ax.hexbin(t, l, r, edgecolors="none") plt.show() .. image-sg:: /gallery/statistics/images/sphx_glr_hexbin_001.svg :alt: hexbin :srcset: /gallery/statistics/images/sphx_glr_hexbin_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 31-36 .. code-block:: Python ax = plt.subplot(projection="ternary") ax.hexbin(t, l, r, bins="log", edgecolors="none") plt.show() .. image-sg:: /gallery/statistics/images/sphx_glr_hexbin_002.svg :alt: hexbin :srcset: /gallery/statistics/images/sphx_glr_hexbin_002.svg :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.274 seconds) .. _sphx_glr_download_gallery_statistics_hexbin.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hexbin.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hexbin.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_