.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/transforms/00.cartesian.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_transforms_00.cartesian.py: ===================== Cartesian coordinates ===================== In mpltern, the x- and y-limits are initially [−3\ :sup:`−1/2`, +3\ :sup:`−1/2`] and [0, 1], respectively. The triangle vertices are, by default, (0, 1), (−3\ :sup:`−1/2`, 0), (+3\ :sup:`−1/2`, 0). In most methods, we can still plot in Cartesian coordinates rather than in ternary coordinates by using `Matplotlib transforms `__ like `ax.transData`, `ax.transAxes`, `fig.transFigure`. .. GENERATED FROM PYTHON SOURCE LINES 16-38 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt import mpltern def plot_frame(ax): """Plot frame of the original Axes.""" ax.fill( [0, 0, 1, 1], [0, 1, 1, 0], ec="k", fc="none", ls=":", clip_on=False, transform=ax.transAxes, ) ax = plt.subplot(projection='ternary') plot_frame(ax) .. image-sg:: /gallery/transforms/images/sphx_glr_00.cartesian_001.svg :alt: 00.cartesian :srcset: /gallery/transforms/images/sphx_glr_00.cartesian_001.svg :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-41 This may be useful to plot e.g. the subfigure label as well as to understand the legend position. .. GENERATED FROM PYTHON SOURCE LINES 41-62 .. code-block:: Python fig = plt.figure(figsize=(10.8, 4.8)) fig.subplots_adjust(wspace=0.3) ax = fig.add_subplot(1, 2, 1, projection='ternary') plot_frame(ax) x = [-1.0 / np.sqrt(3.0), +0.5 / np.sqrt(3.0)] y = [0.0, 0.5] ax.plot(x, y, label="a", transform=ax.transData) ax.legend(loc=1) ax.text(0.02, 0.94, "(a)", ha="left", transform=ax.transAxes) ax = fig.add_subplot(1, 2, 2, projection='ternary') plot_frame(ax) x = [+1.0 / np.sqrt(3.0), -0.5 / np.sqrt(3.0)] y = [0.0, 0.5] ax.plot(x, y, label="b", transform=ax.transData) ax.legend(loc=2) ax.text(0.98, 0.94, "(b)", ha="right", transform=ax.transAxes) plt.show() .. image-sg:: /gallery/transforms/images/sphx_glr_00.cartesian_002.svg :alt: 00.cartesian :srcset: /gallery/transforms/images/sphx_glr_00.cartesian_002.svg :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.889 seconds) .. _sphx_glr_download_gallery_transforms_00.cartesian.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00.cartesian.ipynb <00.cartesian.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00.cartesian.py <00.cartesian.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_