.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/introductory/legend.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_legend.py: ====== Legend ====== The legend can be put using ``ax.legend`` in the same way as Matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 8-24 .. image-sg:: /gallery/introductory/images/sphx_glr_legend_001.svg :alt: legend :srcset: /gallery/introductory/images/sphx_glr_legend_001.svg :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt import mpltern ax = plt.subplot(projection="ternary") np.random.seed(19680801) for i in range(4): t, l, r = np.random.dirichlet(alpha=(2.0, 2.0, 2.0), size=10).T ax.scatter(t, l, r, alpha=0.5, label=i) ax.legend() plt.show() .. _sphx_glr_download_gallery_introductory_legend.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: legend.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: legend.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_