.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/introductory/01.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_introductory_01.scatter.py: ======= Scatter ======= Scatter plots can be done using ``ax.scatter``. .. GENERATED FROM PYTHON SOURCE LINES 8-41 .. image-sg:: /gallery/introductory/images/sphx_glr_01.scatter_001.svg :alt: 01.scatter :srcset: /gallery/introductory/images/sphx_glr_01.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(seed=19) t0, l0, r0 = np.random.dirichlet(alpha=(2.0, 2.0, 2.0), size=100).T np.random.seed(seed=68) t1, l1, r1 = np.random.dirichlet(alpha=(2.0, 2.0, 2.0), size=100).T dt = t1 - t0 dl = l1 - l0 dr = r1 - r0 length = np.sqrt(dt**2 + dl**2 + dr**2) 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") pc = ax.scatter(t0, l0, r0) pc = ax.scatter(t1, l1, r1) ax = fig.add_subplot(1, 2, 2, projection="ternary") pc = ax.scatter(t0, l0, r0, c=length) cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes) colorbar = fig.colorbar(pc, cax=cax) colorbar.set_label("Length", rotation=270, va="baseline") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.399 seconds) .. _sphx_glr_download_gallery_introductory_01.scatter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01.scatter.ipynb <01.scatter.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01.scatter.py <01.scatter.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_