.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/introductory/02.contour.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_introductory_02.contour.py: ======= Contour ======= Contour plots can be done using ``ax.tricontour`` or ``ax.tricontourf``. .. GENERATED FROM PYTHON SOURCE LINES 8-43 .. image-sg:: /gallery/introductory/images/sphx_glr_02.contour_001.svg :alt: tricontour, tricontourf :srcset: /gallery/introductory/images/sphx_glr_02.contour_001.svg :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mpltern.datasets import get_shanon_entropies t, l, r, v = get_shanon_entropies() fig = plt.figure(figsize=(10.8, 4.8)) fig.subplots_adjust(left=0.075, right=0.85, wspace=0.3) # These values are for controlling the color-bar scale, and here they are # explicitly given just to make the same color-bar scale for all the plots. # In general, you may not need to explicitly specify them. vmin = 0.0 vmax = 1.2 levels = np.linspace(vmin, vmax, 7) ax = fig.add_subplot(1, 2, 1, projection='ternary') cs = ax.tricontour(t, l, r, v, levels=levels) ax.clabel(cs) ax.set_title("tricontour") cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes) colorbar = fig.colorbar(cs, cax=cax) colorbar.set_label('Entropy', rotation=270, va='baseline') ax = fig.add_subplot(1, 2, 2, projection='ternary') cs = ax.tricontourf(t, l, r, v, levels=levels) ax.set_title("tricontourf") cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes) colorbar = fig.colorbar(cs, cax=cax) colorbar.set_label('Entropy', rotation=270, va='baseline') plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.037 seconds) .. _sphx_glr_download_gallery_introductory_02.contour.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02.contour.ipynb <02.contour.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02.contour.py <02.contour.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_