.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gridded_plots/contourf_discrete_levels.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_discrete_levels.py: Discrete filled contours ======================== Use an explicit set of levels to control banding. .. GENERATED FROM PYTHON SOURCE LINES 7-38 .. image-sg:: /examples/gridded_plots/images/sphx_glr_contourf_discrete_levels_001.png :alt: Discrete filled contours :srcset: /examples/gridded_plots/images/sphx_glr_contourf_discrete_levels_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 from emcpy.plots.create_plots import CreatePlot, CreateFigure x = np.linspace(-4, 4, 181) y = np.linspace(-4, 4, 161) X, Y = np.meshgrid(x, y) R = np.sqrt(X**2 + Y**2) Z = np.cos(R) * np.exp(-0.15*R) levels = [-0.9, -0.6, -0.3, -0.15, 0.0, 0.15, 0.3, 0.6, 0.9] p = CreatePlot() cf = FilledContourPlot(X, Y, Z) cf.levels = levels cf.cmap = "Spectral_r" p.plot_layers = [cf] p.add_title("Discrete filled contours") p.add_xlabel("x") p.add_ylabel("y") p.add_grid() p.add_colorbar(label="Z") fig = CreateFigure(nrows=1, ncols=1, figsize=(7.6, 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.122 seconds) .. _sphx_glr_download_examples_gridded_plots_contourf_discrete_levels.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: contourf_discrete_levels.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: contourf_discrete_levels.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: contourf_discrete_levels.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_