.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/statistics/with_scatter.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_with_scatter.py: ================ Binned & scatter ================ A binned plot can be shown together with a scatter plot. .. GENERATED FROM PYTHON SOURCE LINES 8-38 .. image-sg:: /gallery/statistics/images/sphx_glr_with_scatter_001.svg :alt: hexbin, tribin :srcset: /gallery/statistics/images/sphx_glr_with_scatter_001.svg :class: sphx-glr-single-img .. 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, 2.0, 2.0), size=100).T fig = plt.figure(figsize=(10.8, 4.8)) fig.subplots_adjust(left=0.075, right=0.85, wspace=0.3) ax = fig.add_subplot(1, 2, 1, projection="ternary") ax.scatter(t, l, r, color="C3", marker="x") pc = ax.hexbin(t, l, r, gridsize=10, edgecolors="k", alpha=0.5, zorder=0.0) ax.set_title("hexbin") cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes) colorbar = fig.colorbar(pc, cax=cax) colorbar.set_label("Count", rotation=270, va="baseline") ax = fig.add_subplot(1, 2, 2, projection="ternary") ax.scatter(t, l, r, color="C3", marker="x") pc = ax.tribin(t, l, r, gridsize=10, edgecolors="k", alpha=0.5, zorder=0.0) ax.set_title("tribin") cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes) colorbar = fig.colorbar(pc, cax=cax) colorbar.set_label("Count", rotation=270, va="baseline") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.954 seconds) .. _sphx_glr_download_gallery_statistics_with_scatter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: with_scatter.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: with_scatter.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_