.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/map_plots/overlay_fc_contour_scatter.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_map_plots_overlay_fc_contour_scatter.py: Overlay: filled contour + contour + scatter =========================================== Demonstrates layering multiple EMCPy map types. .. GENERATED FROM PYTHON SOURCE LINES 7-55 .. image-sg:: /examples/map_plots/images/sphx_glr_overlay_fc_contour_scatter_001.png :alt: Overlay: filled contour + contour + categorical scatter :srcset: /examples/map_plots/images/sphx_glr_overlay_fc_contour_scatter_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from emcpy.plots.map_plots import MapFilledContour, MapContour, MapScatter from emcpy.plots.create_plots import CreatePlot, CreateFigure # Field (centers) lon = np.linspace(-100, -80, 121) lat = np.linspace(30, 45, 91) LON, LAT = np.meshgrid(lon, lat) Z = np.cos(np.radians(LON)) * np.sin(np.radians(LAT * 2)) # Random stations rng = np.random.default_rng(2) n = 180 slat = rng.uniform(32, 44, n) slon = rng.uniform(-98, -82, n) cat = rng.integers(0, 5, n) # categories for scatter p = CreatePlot(projection="plcarr", domain="conus") # 1) Filled background cf = MapFilledContour(LAT, LON, Z) cf.cmap = "viridis" cf.levels = np.linspace(Z.min(), Z.max(), 13) # 2) Thin contour lines c = MapContour(LAT, LON, Z) c.levels = np.linspace(Z.min(), Z.max(), 13) c.colors = "black" c.linewidths = 0.6 # 3) Categorical scatter on top ms = MapScatter(slat, slon, data=cat) ms.integer_field = True ms.cmap = "tab10" ms.markersize = 12 ms.edgecolors = "k" ms.linewidths = 0.5 p.plot_layers = [cf, c, ms] p.add_map_features(["states", "coastline"]) p.add_colorbar(label="Z") p.add_title("Overlay: filled contour + contour + categorical scatter") fig = CreateFigure(1, 1, figsize=(9.5, 5.4)) fig.plot_list = [p] fig.create_figure() fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.155 seconds) .. _sphx_glr_download_examples_map_plots_overlay_fc_contour_scatter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: overlay_fc_contour_scatter.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: overlay_fc_contour_scatter.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: overlay_fc_contour_scatter.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_