.. 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_waves.py: Filled contours --------------- An example of contourf on manufactured data. .. image:: /gallery/images/sphx_glr_waves_001.png :class: sphx-glr-single-img .. code-block:: python import matplotlib.pyplot as plt import numpy as np import cartopy.crs as ccrs def sample_data(shape=(73, 145)): """Return ``lons``, ``lats`` and ``data`` of some fake data.""" nlats, nlons = shape lats = np.linspace(-np.pi / 2, np.pi / 2, nlats) lons = np.linspace(0, 2 * np.pi, nlons) lons, lats = np.meshgrid(lons, lats) wave = 0.75 * (np.sin(2 * lats) ** 8) * np.cos(4 * lons) mean = 0.5 * np.cos(2 * lats) * ((np.sin(2 * lats)) ** 2 + 2) lats = np.rad2deg(lats) lons = np.rad2deg(lons) data = wave + mean return lons, lats, data def main(): fig = plt.figure(figsize=(10, 5)) ax = fig.add_subplot(1, 1, 1, projection=ccrs.Mollweide()) lons, lats, data = sample_data() ax.contourf(lons, lats, data, transform=ccrs.PlateCarree(), cmap='nipy_spectral') ax.coastlines() ax.set_global() plt.show() if __name__ == '__main__': main() **Total running time of the script:** ( 0 minutes 0.262 seconds) .. _sphx_glr_download_gallery_waves.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: waves.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: waves.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_