.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/intermediate/99.inset.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_intermediate_99.inset.py: ===== Inset ===== You can have an inset by adding another `TernaryAxes`. .. GENERATED FROM PYTHON SOURCE LINES 7-41 .. image-sg:: /gallery/intermediate/images/sphx_glr_99.inset_001.svg :alt: 99.inset :srcset: /gallery/intermediate/images/sphx_glr_99.inset_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 fig = plt.figure() fig.subplots_adjust(left=-0.1) ax = fig.add_subplot(projection="ternary") ax.scatter(t0, l0, r0, alpha=0.5) ax.scatter(t1, l1, r1, alpha=0.5) # Plot the triangle region for the inset. ax.fill([0.4, 0.3, 0.3], [0.3, 0.4, 0.3], [0.3, 0.3, 0.4], fc="none", ec="k") # Create a new `TernaryAxes` for the inset with specifying a rectangle in the # figure coordinates. axins = fig.add_axes([0.625, 0.525, 0.30, 0.30], projection="ternary") # Limit the ploting range to be consistent with the above plotted triangle. axins.set_ternary_min(0.3, 0.3, 0.3) axins.scatter(t0, l0, r0, alpha=0.5) axins.scatter(t1, l1, r1, alpha=0.5) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.371 seconds) .. _sphx_glr_download_gallery_intermediate_99.inset.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 99.inset.ipynb <99.inset.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 99.inset.py <99.inset.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_