Triangular limits#

Suppose we would like to crop or expand the following gray-shaded region.

../../_images/00-triangular_limits-1.svg

The region is defined as the intersect of \(t \in [0.1, 0.5]\), \(l \in [0.2, 0.6]\), \(r \in [0.3, 0.7]\).

../../_images/00-triangular_limits-2.svg

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.

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
)
00.triangular limits

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.

ax = plt.subplot(projection='ternary')
ax.plot(*get_spiral(), color="k")
ax.set_ternary_min(0.1, 0.2, 0.3)
00.triangular limits
ax = plt.subplot(projection='ternary')
ax.plot(*get_spiral(), color="k")
ax.set_ternary_max(0.5, 0.6, 0.7)
00.triangular limits

The last way is to specify the min and the max values of each ternary axis one by one.

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)
00.triangular limits

Total running time of the script: (0 minutes 4.564 seconds)

Gallery generated by Sphinx-Gallery