.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gridded_plots/contourf_with_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_examples_gridded_plots_contourf_with_contour.py: Filled contours with line overlays ================================== Discrete filled contours with contour-line overlays sharing the same levels. .. GENERATED FROM PYTHON SOURCE LINES 7-44 .. image-sg:: /examples/gridded_plots/images/sphx_glr_contourf_with_contour_001.png :alt: Filled contours + line overlays :srcset: /examples/gridded_plots/images/sphx_glr_contourf_with_contour_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from emcpy.plots.plots import FilledContourPlot, ContourPlot from emcpy.plots.create_plots import CreatePlot, CreateFigure x = np.linspace(-3, 3, 200) y = np.linspace(-2, 2, 160) X, Y = np.meshgrid(x, y) Z = np.exp(-(X**2 + (Y*1.5)**2)) * np.cos(3*X) * np.sin(3*Y) levels = np.linspace(-0.8, 0.8, 17) p = CreatePlot() cf = FilledContourPlot(X, Y, Z) cf.levels = levels cf.cmap = "RdBu_r" p.plot_layers = [cf] cl = ContourPlot(X, Y, Z) cl.levels = levels cl.colors = "k" cl.linewidths = 0.6 p.plot_layers.append(cl) p.add_title("Filled contours + line overlays") p.add_xlabel("x") p.add_ylabel("y") p.add_grid() p.add_colorbar(label="Z") fig = CreateFigure(nrows=1, ncols=1, figsize=(7.8, 4.6)) fig.plot_list = [p] fig.create_figure() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.129 seconds) .. _sphx_glr_download_examples_gridded_plots_contourf_with_contour.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: contourf_with_contour.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: contourf_with_contour.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: contourf_with_contour.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_