.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/limits/02.fit.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_02.fit.py: ======================= Plotting region fitting ======================= When the ternary limits are modified, the plotting region can be expanded or cropped in a different way via the `fit` option in e.g. `set_ternary_lim`. - `'rectangle'` (default): Fitted to the original rectangle. - `'triangle'`: Fitted to the original triangle. - `'none'`: The plotting region is simply cropped (or expanded). .. GENERATED FROM PYTHON SOURCE LINES 13-69 .. image-sg:: /gallery/limits/images/sphx_glr_02.fit_001.svg :alt: fit='rectangle', fit='triangle', fit='none' :srcset: /gallery/limits/images/sphx_glr_02.fit_001.svg :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt from mpltern.datasets import get_spiral def set_labels(ax): """Set ternary-axis labels.""" ax.set_tlabel('Top') ax.set_llabel('Left') ax.set_rlabel('Right') ax.taxis.set_label_position("tick1") ax.laxis.set_label_position("tick1") ax.raxis.set_label_position("tick1") def plot_frame(ax): ax.fill( [0.0, 0.0, 1.0, 1.0], [0.0, 1.0, 1.0, 0.0], ec="r", fc="none", ls=":", transform=ax.transAxes, clip_on=False, zorder=1.0, ) ax.fill( [0.5, 0.0, 1.0], [1.0, 0.0, 0.0], ec="b", fc="none", ls=":", transform=ax.transAxes, clip_on=False, zorder=1.0, ) fig = plt.figure(figsize=(10.8, 4.8)) fig.subplots_adjust(left=0.075, right=0.925, wspace=0.25) fits = ["rectangle", "triangle", "none"] for i, fit in enumerate(fits): ax = fig.add_subplot(1, 3, i + 1, projection='ternary') ax.plot(*get_spiral(), c="k") ax.set_ternary_lim( 0.1, 0.7, # tmin, tmax 0.1, 0.7, # lmin, lmax 0.1, 0.7, # rmin, rmax fit=fit, ) set_labels(ax) ax.set_title(f"fit='{fit}'", pad=42) plot_frame(ax) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.543 seconds) .. _sphx_glr_download_gallery_limits_02.fit.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02.fit.ipynb <02.fit.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02.fit.py <02.fit.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_