.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_advanced_advanced_numpy_auto_examples_plot_maskedstats.py: Example: Masked statistics ========================== Plot a masked statistics .. image:: /advanced/advanced_numpy/auto_examples/images/sphx_glr_plot_maskedstats_001.png :class: sphx-glr-single-img .. code-block:: python import numpy as np import matplotlib.pyplot as plt data = np.loadtxt('../../../../data/populations.txt') populations = np.ma.masked_array(data[:,1:]) year = data[:, 0] bad_years = (((year >= 1903) & (year <= 1910)) | ((year >= 1917) & (year <= 1918))) populations[bad_years, 0] = np.ma.masked populations[bad_years, 1] = np.ma.masked plt.plot(year, populations, 'o-') plt.show() **Total running time of the script:** ( 0 minutes 0.016 seconds) .. _sphx_glr_download_advanced_advanced_numpy_auto_examples_plot_maskedstats.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_maskedstats.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_maskedstats.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_