.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gridded_plots/heatmap_basic.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_heatmap_basic.py: Heatmap ======= Categorical heatmap with a diverging colormap, cell annotations, and missing-data masking. .. GENERATED FROM PYTHON SOURCE LINES 8-41 .. image-sg:: /examples/gridded_plots/images/sphx_glr_heatmap_basic_001.png :alt: Observation Bias by Variable and Cycle :srcset: /examples/gridded_plots/images/sphx_glr_heatmap_basic_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from emcpy.plots.plots import HeatMap from emcpy.plots.create_plots import CreatePlot, CreateFigure cycles = ["00Z", "06Z", "12Z", "18Z", "00Z+1", "06Z+1"] variables = ["TEMP", "UWND", "VWND", "SPFH", "PRES"] rng = np.random.default_rng(42) data = rng.normal(0, 1.5, size=(len(variables), len(cycles))) data[1, 3] = np.nan # simulate a missing/quarantined cycle data[4, :2] = np.nan # variable not yet reporting at start of window p = CreatePlot() hm = HeatMap(cycles, variables, data) hm.cmap = "RdBu_r" hm.center = 0.0 hm.annotate = True hm.annotate_fmt = "{:.2f}" hm.mask_color = "lightgray" p.plot_layers = [hm] p.add_title("Observation Bias by Variable and Cycle") p.add_xlabel("Cycle") p.add_ylabel("Variable") p.add_colorbar(label="O-B bias") fig = CreateFigure(nrows=1, ncols=1, figsize=(8, 4.5)) 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.166 seconds) .. _sphx_glr_download_examples_gridded_plots_heatmap_basic.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: heatmap_basic.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: heatmap_basic.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: heatmap_basic.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_