.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "example_gallery/1d_hist/1d_comparison_efficiency.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_comparison_efficiency.py: Efficiency ========== Compare the ratio between two histograms h1 and h2 when the entries of h1 are a subset of the entries of h2. .. GENERATED FROM PYTHON SOURCE LINES 7-38 .. image-sg:: /example_gallery/1d_hist/images/sphx_glr_1d_comparison_efficiency_001.svg :alt: 1d comparison efficiency :srcset: /example_gallery/1d_hist/images/sphx_glr_1d_comparison_efficiency_001.svg :class: sphx-glr-single-img .. code-block:: Python from plothist_utils import get_dummy_data df = get_dummy_data() name = "variable_1" x_total = df[name][df["category"] == 2] x_sample = x_total[: int(len(x_total) * 0.75)] x_range = (min(x_total), max(x_total)) from plothist import make_hist h_sample = make_hist(x_sample, bins=50, range=x_range) h_total = make_hist(x_total, bins=50, range=x_range) ### from plothist import plot_two_hist_comparison fig, ax_main, ax_comparison = plot_two_hist_comparison( h_sample, h_total, xlabel=name, ylabel="Entries", h1_label=r"$\mathit{H}_{Sample}$", h2_label=r"$\mathit{H}_{Total}$", comparison="efficiency", # <-- ) fig.savefig("1d_comparison_efficiency.svg", bbox_inches="tight") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.988 seconds) .. _sphx_glr_download_example_gallery_1d_hist_1d_comparison_efficiency.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 1d_comparison_efficiency.ipynb <1d_comparison_efficiency.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 1d_comparison_efficiency.py <1d_comparison_efficiency.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 1d_comparison_efficiency.zip <1d_comparison_efficiency.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_