.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_frontpage_contour.py: ========================= Frontpage contour example ========================= This example reproduces the frontpage contour example. .. image:: /gallery/frontpage/images/sphx_glr_contour_001.png :alt: contour :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt import numpy as np from matplotlib import cm extent = (-3, 3, -3, 3) delta = 0.5 x = np.arange(-3.0, 4.001, delta) y = np.arange(-4.0, 3.001, delta) X, Y = np.meshgrid(x, y) Z1 = np.exp(-X**2 - Y**2) Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2) Z = Z1 - Z2 norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max()) fig, ax = plt.subplots() cset1 = ax.contourf( X, Y, Z, 40, norm=norm) ax.set_xlim(-2, 2) ax.set_ylim(-2, 2) ax.set_xticks([]) ax.set_yticks([]) fig.savefig("contour_frontpage.png", dpi=25) # results in 160x120 px image plt.show() .. _sphx_glr_download_gallery_frontpage_contour.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: contour.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: contour.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_