.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/limits/00.triangular_limits.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_limits_00.triangular_limits.py: ================= Triangular limits ================= Suppose we would like to crop or expand the following gray-shaded region. .. plot:: :context: reset :include-source: false import matplotlib.pyplot as plt from mpltern.datasets import get_spiral ax = plt.subplot(projection='ternary') ax.plot(*get_spiral(), color="k") ax.fill([0.5, 0.1, 0.1], [0.2, 0.6, 0.2], [0.3, 0.3, 0.7], color="0.6") ax.set_tlabel("T") ax.set_llabel("L") ax.set_rlabel("R") The region is defined as the intersect of :math:`t \in [0.1, 0.5]`, :math:`l \in [0.2, 0.6]`, :math:`r \in [0.3, 0.7]`. .. plot:: :context: :include-source: false ax.axtspan(0.1, 0.5, color="C0", fc="none", hatch="....") ax.axlspan(0.2, 0.6, color="C1", fc="none", hatch="....") ax.axrspan(0.3, 0.7, color="C2", fc="none", hatch="....") .. GENERATED FROM PYTHON SOURCE LINES 35-43 To do this, we can use one of the following approaches. 1. `set_ternary_lim` 2. `set_ternary_min` and `set_ternary_max` 3. `set_tlim`, `set_llim`, `set_rlim` Using `set_ternary_lim`, we explicitly specify the min and the max values for all the ternary axes. .. GENERATED FROM PYTHON SOURCE LINES 43-53 .. code-block:: Python import matplotlib.pyplot as plt from mpltern.datasets import get_spiral ax = plt.subplot(projection='ternary') ax.plot(*get_spiral(), color="k") ax.set_ternary_lim( 0.1, 0.5, # tmin, tmax 0.2, 0.6, # lmin, lmax 0.3, 0.7, # rmin, rmax ) .. image-sg:: /gallery/limits/images/sphx_glr_00.triangular_limits_001.svg :alt: 00.triangular limits :srcset: /gallery/limits/images/sphx_glr_00.triangular_limits_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 54-56 We can also use `ternary_min` and `ternary_max`. The max and the min values of the ternary axes are automatically determined to have a triangle region. .. GENERATED FROM PYTHON SOURCE LINES 56-59 .. code-block:: Python ax = plt.subplot(projection='ternary') ax.plot(*get_spiral(), color="k") ax.set_ternary_min(0.1, 0.2, 0.3) .. image-sg:: /gallery/limits/images/sphx_glr_00.triangular_limits_002.svg :alt: 00.triangular limits :srcset: /gallery/limits/images/sphx_glr_00.triangular_limits_002.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python ax = plt.subplot(projection='ternary') ax.plot(*get_spiral(), color="k") ax.set_ternary_max(0.5, 0.6, 0.7) .. image-sg:: /gallery/limits/images/sphx_glr_00.triangular_limits_003.svg :alt: 00.triangular limits :srcset: /gallery/limits/images/sphx_glr_00.triangular_limits_003.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 64-66 The last way is to specify the min and the max values of each ternary axis one by one. .. GENERATED FROM PYTHON SOURCE LINES 66-71 .. code-block:: Python ax = plt.subplot(projection='ternary') ax.plot(*get_spiral(), color="k") ax.set_tlim(0.1, 0.5) ax.set_llim(0.2, 0.6) ax.set_rlim(0.3, 0.7) .. image-sg:: /gallery/limits/images/sphx_glr_00.triangular_limits_004.svg :alt: 00.triangular limits :srcset: /gallery/limits/images/sphx_glr_00.triangular_limits_004.svg :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.387 seconds) .. _sphx_glr_download_gallery_limits_00.triangular_limits.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00.triangular_limits.ipynb <00.triangular_limits.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00.triangular_limits.py <00.triangular_limits.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_