.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "example_gallery/1d_hist/1d_profile.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_example_gallery_1d_hist_1d_profile.py: Mean histogram (profile) ======================== Plot a 1D mean histogram (profile). .. GENERATED FROM PYTHON SOURCE LINES 7-34 .. image-sg:: /example_gallery/1d_hist/images/sphx_glr_1d_profile_001.svg :alt: 1d profile :srcset: /example_gallery/1d_hist/images/sphx_glr_1d_profile_001.svg :class: sphx-glr-single-img .. code-block:: Python ### import boost_histogram as bh import matplotlib.pyplot as plt from plothist import plot_error_hist # Regular axis with 3 bins from -1 to 1 axis = bh.axis.Regular(3, -1, 1) # 6 data points, two in each bin data = [-0.5, -0.5, 0.0, 0.0, 0.5, 0.5] sample = [0, 100, 40, 60, 0, 20] weights = [1, 1, 1, 1, 1, 1] h = bh.Histogram(axis, storage=bh.storage.WeightedMean()) h.fill(data, weight=weights, sample=sample) fig, ax = plt.subplots() plot_error_hist(h, ax=ax) ax.set_xlabel("Variable") ax.set_ylabel("Mean") ax.set_xlim(-1, 1) fig.savefig("1d_profile.svg", bbox_inches="tight") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.300 seconds) .. _sphx_glr_download_example_gallery_1d_hist_1d_profile.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 1d_profile.ipynb <1d_profile.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 1d_profile.py <1d_profile.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 1d_profile.zip <1d_profile.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_