From d52f41e8d95fb8d9c73d230c1fdcdecf409776b8 Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 14:29:32 +0900 Subject: [PATCH 1/9] update the side_by_side example --- docs/advanced/other_advanced.rst | 29 ++++++++++- docs/examples/advanced/1d_side_by_side.py | 61 ++++++----------------- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/docs/advanced/other_advanced.rst b/docs/advanced/other_advanced.rst index 5db05ba..76a316a 100644 --- a/docs/advanced/other_advanced.rst +++ b/docs/advanced/other_advanced.rst @@ -60,7 +60,7 @@ Compare data and stacked histogram for a flatten 2D variable: Side-by-side categorical histograms =================================== -Here is an example to put three histograms side by side with a categorical axis and boost-histogram: +Here is an example to put three histograms side by side with a categorical axis and boost-histogram. It shows a specificity of ``matplotlib`` when plotting a list of histograms: .. image:: ../img/1d_side_by_side.svg :alt: Side by side histograms @@ -69,3 +69,30 @@ Here is an example to put three histograms side by side with a categorical axis .. literalinclude:: ../examples/advanced/1d_side_by_side.py :language: python :start-after: ### + +To also add the number of entries on top of each bar, you can use the following code: + +.. code-block:: python + + # Get the correct shift in x-axis for each bar + def calculate_shifts(width, n_bars): + half_width = width / 2 + shift = np.linspace(-half_width, half_width, n_bars, endpoint=False) + shift += width / (2 * n_bars) + return shift + + + bin_width = 0.8 + shift = calculate_shifts(bin_width, len(histos)) + + # Loop over the histograms, add on top of each bar the number of entries + for i, histo in enumerate(histos): + for j, value in enumerate(histo.values()): + ax.text( + j + 0.5 + shift[i], + value, + int(value), # If weighted, f"{height:.1f}" can be used as a better representation of the bin content + color="black", + ha="center", + va="bottom", + ) \ No newline at end of file diff --git a/docs/examples/advanced/1d_side_by_side.py b/docs/examples/advanced/1d_side_by_side.py index 6542fdc..29a707b 100644 --- a/docs/examples/advanced/1d_side_by_side.py +++ b/docs/examples/advanced/1d_side_by_side.py @@ -9,18 +9,20 @@ import boost_histogram as bh import numpy as np import matplotlib.pyplot as plt -import plothist +from plothist import plot_hist rng = np.random.default_rng(8311311) # String categories categories = ["A", "B", "C"] -## Works also with integers -# categories = [-5, 10, 137] # Axis with the 3 bins axis = bh.axis.StrCategory(categories=categories) +## Works also with integers +# categories = [-5, 10, 137] +# axis = bh.axis.IntCategory(categories=categories) + # Generate data for 3 histograms data = [ rng.choice(categories, 20), @@ -32,53 +34,22 @@ histos = [bh.Histogram(axis, storage=bh.storage.Weight()) for _ in range(len(data))] histos = [histo.fill(data[i]) for i, histo in enumerate(histos)] -# Create an array for the x-coordinates of the bars -x = np.arange(len(axis)) - - -# Get the correct shift for each bar -def calculate_shifts(width, n_bars): - half_width = width / 2 - shift = np.linspace(-half_width, half_width, n_bars, endpoint=False) - shift += width / (2 * n_bars) - return shift - - -bin_width = 0.7 -n_bars = len(histos) -shift = calculate_shifts(bin_width, n_bars) - +# Plot the histogram fig, ax = plt.subplots() -# Plot the histograms side by side -for i, histo in enumerate(histos): - bars = ax.bar( - x + shift[i], - histo.values(), - width=bin_width / n_bars, - label=f"$\mathit{{h_{i}}}$", - ) +# Use a specificity of matplotlib: when a list of histograms is given, it will plot them side by side unless stacked=True or histtype is a "step" type. +plot_hist(histos, ax=ax, label=categories) - # Optional: Add the number on top of each bar (number of (weighted) entries for each bin for the (weighted) histograms) - for bar in bars: - height = bar.get_height() - ax.text( - bar.get_x() + bar.get_width() / 2, - height, - int( - height - ), # If weighted, f"{height:.1f}" can be used as a better representation of the bin content - ha="center", - va="bottom", - ) - -# Label the x-ticks with the categories -ax.set_xticks(x, axis) -ax.set_ylim(top=int(np.max([np.max(histo.values()) for histo in histos]) * 1.5)) +# Set the x-ticks to the middle of the bins and label them +ax.set_xlim(0, len(categories)) +ax.set_xticks([i + 0.5 for i in range(len(categories))]) +ax.set_xticklabels(categories) ax.minorticks_off() +# Get nice looking y-axis ticks +ax.set_ylim(top=int(np.max([np.max(histo.values()) for histo in histos]) * 1.5)) -ax.set_ylabel("Entries") ax.set_xlabel("Category") +ax.set_ylabel("Entries") ax.legend() -fig.savefig("1d_side_by_side.svg", bbox_inches="tight") +fig.savefig("1d_side_by_side.svg", bbox_inches="tight") \ No newline at end of file From c3e74d4e1e6e3b1f059e9862c71fa69a05c8520d Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 14:30:58 +0900 Subject: [PATCH 2/9] update fig --- docs/advanced/other_advanced.rst | 2 +- docs/examples/advanced/1d_side_by_side.py | 2 +- docs/img/1d_side_by_side.svg | 390 ++++------------------ 3 files changed, 66 insertions(+), 328 deletions(-) diff --git a/docs/advanced/other_advanced.rst b/docs/advanced/other_advanced.rst index 76a316a..cb46db4 100644 --- a/docs/advanced/other_advanced.rst +++ b/docs/advanced/other_advanced.rst @@ -95,4 +95,4 @@ To also add the number of entries on top of each bar, you can use the following color="black", ha="center", va="bottom", - ) \ No newline at end of file + ) diff --git a/docs/examples/advanced/1d_side_by_side.py b/docs/examples/advanced/1d_side_by_side.py index 29a707b..715af25 100644 --- a/docs/examples/advanced/1d_side_by_side.py +++ b/docs/examples/advanced/1d_side_by_side.py @@ -52,4 +52,4 @@ ax.set_ylabel("Entries") ax.legend() -fig.savefig("1d_side_by_side.svg", bbox_inches="tight") \ No newline at end of file +fig.savefig("1d_side_by_side.svg", bbox_inches="tight") diff --git a/docs/img/1d_side_by_side.svg b/docs/img/1d_side_by_side.svg index 16e520e..c485607 100644 --- a/docs/img/1d_side_by_side.svg +++ b/docs/img/1d_side_by_side.svg @@ -35,74 +35,74 @@ z " style="fill: #ffffff"/> - - - - - - - - - @@ -135,12 +135,12 @@ L 0 -6 " style="stroke: #1a1a1a; stroke-width: 0.8"/> - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - + + + + - - - - - - - - - + + + + From 430616270d35086497edcdfdba967445fdf49ab5 Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 14:35:15 +0900 Subject: [PATCH 3/9] 1d_side_by_side in 1D hist chapter --- docs/advanced/other_advanced.rst | 42 ------------------ docs/basics/1d_hist.rst | 43 +++++++++++++++++++ .../{advanced => 1d_hist}/1d_side_by_side.py | 0 3 files changed, 43 insertions(+), 42 deletions(-) rename docs/examples/{advanced => 1d_hist}/1d_side_by_side.py (100%) diff --git a/docs/advanced/other_advanced.rst b/docs/advanced/other_advanced.rst index cb46db4..8d82e4b 100644 --- a/docs/advanced/other_advanced.rst +++ b/docs/advanced/other_advanced.rst @@ -54,45 +54,3 @@ Compare data and stacked histogram for a flatten 2D variable: .. literalinclude:: ../examples/advanced/model_examples_flatten2D.py :language: python :start-after: ### - - - -Side-by-side categorical histograms -=================================== - -Here is an example to put three histograms side by side with a categorical axis and boost-histogram. It shows a specificity of ``matplotlib`` when plotting a list of histograms: - -.. image:: ../img/1d_side_by_side.svg - :alt: Side by side histograms - :width: 500 - -.. literalinclude:: ../examples/advanced/1d_side_by_side.py - :language: python - :start-after: ### - -To also add the number of entries on top of each bar, you can use the following code: - -.. code-block:: python - - # Get the correct shift in x-axis for each bar - def calculate_shifts(width, n_bars): - half_width = width / 2 - shift = np.linspace(-half_width, half_width, n_bars, endpoint=False) - shift += width / (2 * n_bars) - return shift - - - bin_width = 0.8 - shift = calculate_shifts(bin_width, len(histos)) - - # Loop over the histograms, add on top of each bar the number of entries - for i, histo in enumerate(histos): - for j, value in enumerate(histo.values()): - ax.text( - j + 0.5 + shift[i], - value, - int(value), # If weighted, f"{height:.1f}" can be used as a better representation of the bin content - color="black", - ha="center", - va="bottom", - ) diff --git a/docs/basics/1d_hist.rst b/docs/basics/1d_hist.rst index 2392db7..dbf2adb 100644 --- a/docs/basics/1d_hist.rst +++ b/docs/basics/1d_hist.rst @@ -265,3 +265,46 @@ String category .. image:: ../img/1d_str_category.svg :alt: String category plot :width: 500 + + +Using multiple histograms +------------------------- + +With multiple histograms, the :func:`plot_hist() ` function will correctly put them side by side: + +.. image:: ../img/1d_side_by_side.svg + :alt: Side by side histograms + :width: 500 + +.. literalinclude:: ../examples/1d_hist/1d_side_by_side.py + :language: python + :start-after: ### + +To also add the number of entries on top of each bar, you can use the following code: + +.. code-block:: python + + # Get the correct shift in x-axis for each bar + def calculate_shifts(width, n_bars): + half_width = width / 2 + shift = np.linspace(-half_width, half_width, n_bars, endpoint=False) + shift += width / (2 * n_bars) + return shift + + + bin_width = 0.8 + shift = calculate_shifts(bin_width, len(histos)) + + # Loop over the histograms, add on top of each bar the number of entries + for i, histo in enumerate(histos): + for j, value in enumerate(histo.values()): + ax.text( + j + 0.5 + shift[i], + value, + int( + value + ), # If weighted, f"{height:.1f}" can be used as a better representation of the bin content + color="black", + ha="center", + va="bottom", + ) diff --git a/docs/examples/advanced/1d_side_by_side.py b/docs/examples/1d_hist/1d_side_by_side.py similarity index 100% rename from docs/examples/advanced/1d_side_by_side.py rename to docs/examples/1d_hist/1d_side_by_side.py From afc711617e5d62975763f8cdf57ad213ed0aa621 Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 14:37:48 +0900 Subject: [PATCH 4/9] update legend --- docs/examples/1d_hist/1d_side_by_side.py | 2 +- docs/img/1d_side_by_side.svg | 76 +++++++++++++++++------- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/docs/examples/1d_hist/1d_side_by_side.py b/docs/examples/1d_hist/1d_side_by_side.py index 715af25..868d4d5 100644 --- a/docs/examples/1d_hist/1d_side_by_side.py +++ b/docs/examples/1d_hist/1d_side_by_side.py @@ -38,7 +38,7 @@ fig, ax = plt.subplots() # Use a specificity of matplotlib: when a list of histograms is given, it will plot them side by side unless stacked=True or histtype is a "step" type. -plot_hist(histos, ax=ax, label=categories) +plot_hist(histos, ax=ax, label=["$h_{0}$", "$h_{1}$", "$h_{2}$"], histtype="bar") # Set the x-ticks to the middle of the bins and label them ax.set_xlim(0, len(categories)) diff --git a/docs/img/1d_side_by_side.svg b/docs/img/1d_side_by_side.svg index c485607..ca42945 100644 --- a/docs/img/1d_side_by_side.svg +++ b/docs/img/1d_side_by_side.svg @@ -749,45 +749,79 @@ z - - - - + + + + + + + - - - - + + + + - - - - + + + + From 7d6c9493bef706e73b3beeefa69e65a94eba4a5d Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 17:23:46 +0900 Subject: [PATCH 5/9] moved adding numbers on bars to new section --- docs/advanced/other_advanced.rst | 14 + docs/basics/1d_hist.rst | 31 +- docs/examples/1d_hist/1d_side_by_side.py | 4 +- .../advanced/1d_side_by_side_with_numbers.py | 81 ++ docs/img/1d_side_by_side_with_numbers.svg | 1085 +++++++++++++++++ 5 files changed, 1184 insertions(+), 31 deletions(-) create mode 100644 docs/examples/advanced/1d_side_by_side_with_numbers.py create mode 100644 docs/img/1d_side_by_side_with_numbers.svg diff --git a/docs/advanced/other_advanced.rst b/docs/advanced/other_advanced.rst index 8d82e4b..cfcbab0 100644 --- a/docs/advanced/other_advanced.rst +++ b/docs/advanced/other_advanced.rst @@ -54,3 +54,17 @@ Compare data and stacked histogram for a flatten 2D variable: .. literalinclude:: ../examples/advanced/model_examples_flatten2D.py :language: python :start-after: ### + + +Multiple histograms, side by side, with numbers on top +====================================================== + +This example shows how to plot multiple 1D histograms side by side, with numbers on top of each bars. The code is similar to the one used in the :ref:`basics-1d_hist_side_by_side-label` section. + +.. image:: ../img/1d_side_by_side_with_numbers.svg + :alt: Multiple histograms side by side + :width: 500 + +.. literalinclude:: ../examples/advanced/1d_side_by_side_with_numbers.py + :language: python + :start-after: ### \ No newline at end of file diff --git a/docs/basics/1d_hist.rst b/docs/basics/1d_hist.rst index dbf2adb..44db6d2 100644 --- a/docs/basics/1d_hist.rst +++ b/docs/basics/1d_hist.rst @@ -209,7 +209,6 @@ To easily get the values and the uncertainties of the comparison, the :func:`get h1, h2, comparison="ratio" ) -.. _1d-profile-plot-label: Mean histogram (profile plot) ============================= @@ -267,6 +266,7 @@ String category :width: 500 +.. _basics-1d_hist_side_by_side-label: Using multiple histograms ------------------------- @@ -279,32 +279,3 @@ With multiple histograms, the :func:`plot_hist() ` .. literalinclude:: ../examples/1d_hist/1d_side_by_side.py :language: python :start-after: ### - -To also add the number of entries on top of each bar, you can use the following code: - -.. code-block:: python - - # Get the correct shift in x-axis for each bar - def calculate_shifts(width, n_bars): - half_width = width / 2 - shift = np.linspace(-half_width, half_width, n_bars, endpoint=False) - shift += width / (2 * n_bars) - return shift - - - bin_width = 0.8 - shift = calculate_shifts(bin_width, len(histos)) - - # Loop over the histograms, add on top of each bar the number of entries - for i, histo in enumerate(histos): - for j, value in enumerate(histo.values()): - ax.text( - j + 0.5 + shift[i], - value, - int( - value - ), # If weighted, f"{height:.1f}" can be used as a better representation of the bin content - color="black", - ha="center", - va="bottom", - ) diff --git a/docs/examples/1d_hist/1d_side_by_side.py b/docs/examples/1d_hist/1d_side_by_side.py index 868d4d5..1582a88 100644 --- a/docs/examples/1d_hist/1d_side_by_side.py +++ b/docs/examples/1d_hist/1d_side_by_side.py @@ -34,11 +34,13 @@ histos = [bh.Histogram(axis, storage=bh.storage.Weight()) for _ in range(len(data))] histos = [histo.fill(data[i]) for i, histo in enumerate(histos)] +labels = [f"$h_{{{i}}}$" for i in range(len(histos))] + # Plot the histogram fig, ax = plt.subplots() # Use a specificity of matplotlib: when a list of histograms is given, it will plot them side by side unless stacked=True or histtype is a "step" type. -plot_hist(histos, ax=ax, label=["$h_{0}$", "$h_{1}$", "$h_{2}$"], histtype="bar") +plot_hist(histos, ax=ax, label=labels) # Set the x-ticks to the middle of the bins and label them ax.set_xlim(0, len(categories)) diff --git a/docs/examples/advanced/1d_side_by_side_with_numbers.py b/docs/examples/advanced/1d_side_by_side_with_numbers.py new file mode 100644 index 0000000..62d554f --- /dev/null +++ b/docs/examples/advanced/1d_side_by_side_with_numbers.py @@ -0,0 +1,81 @@ +""" +Side-by-side categories +======================= + +Plot multiple 1D histograms with categories side by side. +""" + +### +import boost_histogram as bh +import numpy as np +import matplotlib.pyplot as plt +from plothist import plot_hist, get_color_palette + +rng = np.random.default_rng(83113111) + +# Integer categories +categories = [-137, 12, 1234] +axis = bh.axis.IntCategory(categories=categories) + +# Generate data for 3 histograms +data = [ + rng.choice(categories, 50), + rng.choice(categories, 30), + rng.choice(categories, 35), + rng.choice(categories, 30), +] + +# Create and fill the histograms +histos = [bh.Histogram(axis, storage=bh.storage.Weight()) for _ in range(len(data))] +histos = [histo.fill(data[i]) for i, histo in enumerate(histos)] + +labels = [f"$h_{{{i}}}$" for i in range(len(histos))] +colors = get_color_palette("ggplot", 5) +colors = colors[:3] + [colors[4]] + +# Plot the histogram +fig, ax = plt.subplots() + +# Use a specificity of matplotlib: when a list of histograms is given, it will plot them side by side unless stacked=True or histtype is a "step" type. +plot_hist(histos, ax=ax, label=labels, color=colors) + + +# Add the number of entries on top of each bar +# Get the correct shift in x-axis for each bar +def calculate_shifts(width, n_bars): + half_width = width / 2 + shift = np.linspace(-half_width, half_width, n_bars, endpoint=False) + shift += width / (2 * n_bars) + return shift + + +bin_width = 0.8 +shift = calculate_shifts(bin_width, len(histos)) + +# Loop over the histograms, add on top of each bar the number of entries +for i, histo in enumerate(histos): + for j, value in enumerate(histo.values()): + ax.text( + j + 0.5 + shift[i], + value, + int( + value + ), # If weighted, f"{height:.1f}" can be used as a better representation of the bin content + color="black", + ha="center", + va="bottom", + ) + +# Set the x-ticks to the middle of the bins and label them +ax.set_xlim(0, len(categories)) +ax.set_xticks([i + 0.5 for i in range(len(categories))]) +ax.set_xticklabels(categories) +ax.minorticks_off() +# Get nice looking y-axis ticks +ax.set_ylim(top=int(np.max([np.max(histo.values()) for histo in histos]) * 1.5)) + +ax.set_xlabel("Category") +ax.set_ylabel("Entries") +ax.legend() + +fig.savefig("1d_side_by_side_with_numbers.svg", bbox_inches="tight") diff --git a/docs/img/1d_side_by_side_with_numbers.svg b/docs/img/1d_side_by_side_with_numbers.svg new file mode 100644 index 0000000..cae0381 --- /dev/null +++ b/docs/img/1d_side_by_side_with_numbers.svg @@ -0,0 +1,1085 @@ + + + + + + + + + カリビアンカフェ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a247eb2dfee8c3f71278268bf00f5cb3164586b2 Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 17:25:30 +0900 Subject: [PATCH 6/9] fix label to doc --- docs/basics/1d_hist.rst | 1 + src/plothist/plotters.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/basics/1d_hist.rst b/docs/basics/1d_hist.rst index 44db6d2..b179402 100644 --- a/docs/basics/1d_hist.rst +++ b/docs/basics/1d_hist.rst @@ -209,6 +209,7 @@ To easily get the values and the uncertainties of the comparison, the :func:`get h1, h2, comparison="ratio" ) +.. _basics-1d_hist_profil_plot-label: Mean histogram (profile plot) ============================= diff --git a/src/plothist/plotters.py b/src/plothist/plotters.py index f7ba53d..108035c 100644 --- a/src/plothist/plotters.py +++ b/src/plothist/plotters.py @@ -366,7 +366,7 @@ def plot_error_hist(hist, ax, uncertainty_type="symmetrical", density=False, **k Asymmetrical uncertainties can only be computed for an unweighted histogram, because the bin contents of a weighted histogram do not follow a Poisson distribution. More information in :ref:`documentation-statistics-label`. The uncertainties are overwritten if the keyword argument yerr is provided. - In the case of a mean histogram, only symmetrical uncertainties are supported and correspond to the standard deviation of the sample and not to a Poisson standard deviation (see :ref:`1d-profile-plot-label`). + In the case of a mean histogram, only symmetrical uncertainties are supported and correspond to the standard deviation of the sample and not to a Poisson standard deviation (see :ref:`basics-1d_hist_profil_plot-label`). density : bool, optional Whether to normalize the histogram to unit area. Default is False. From 212871cf74bee00e3d73a74dbf91132557bae4cc Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 17:26:07 +0900 Subject: [PATCH 7/9] update fig --- docs/img/1d_side_by_side_with_numbers.svg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/img/1d_side_by_side_with_numbers.svg b/docs/img/1d_side_by_side_with_numbers.svg index cae0381..74b0126 100644 --- a/docs/img/1d_side_by_side_with_numbers.svg +++ b/docs/img/1d_side_by_side_with_numbers.svg @@ -112,7 +112,7 @@ L 149.62625 234.165469 L 149.62625 167.637469 L 127.30625 167.637469 z -" clip-path="url(#p1857f18e37)" style="fill: #777777"/> +" clip-path="url(#p1857f18e37)" style="fill: #fbc15e"/> +" clip-path="url(#p1857f18e37)" style="fill: #fbc15e"/> +" clip-path="url(#p1857f18e37)" style="fill: #fbc15e"/> +" style="fill: #fbc15e"/> From c2864339949715cf77b7a36569a722b3490791c8 Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 17:27:29 +0900 Subject: [PATCH 8/9] formatting --- docs/advanced/other_advanced.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/other_advanced.rst b/docs/advanced/other_advanced.rst index cfcbab0..c928589 100644 --- a/docs/advanced/other_advanced.rst +++ b/docs/advanced/other_advanced.rst @@ -67,4 +67,4 @@ This example shows how to plot multiple 1D histograms side by side, with numbers .. literalinclude:: ../examples/advanced/1d_side_by_side_with_numbers.py :language: python - :start-after: ### \ No newline at end of file + :start-after: ### From cc6b92474be51daffa4bc96b63f2a290d2b34951 Mon Sep 17 00:00:00 2001 From: Tristan Fillinger Date: Thu, 27 Jun 2024 18:03:31 +0900 Subject: [PATCH 9/9] doc fix --- docs/basics/1d_hist.rst | 4 ++-- docs/examples/advanced/1d_side_by_side_with_numbers.py | 6 +++--- src/plothist/plotters.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/basics/1d_hist.rst b/docs/basics/1d_hist.rst index b179402..251ca9d 100644 --- a/docs/basics/1d_hist.rst +++ b/docs/basics/1d_hist.rst @@ -209,7 +209,7 @@ To easily get the values and the uncertainties of the comparison, the :func:`get h1, h2, comparison="ratio" ) -.. _basics-1d_hist_profil_plot-label: +.. _basics-1d_hist_profile_plot-label: Mean histogram (profile plot) ============================= @@ -271,7 +271,7 @@ String category Using multiple histograms ------------------------- -With multiple histograms, the :func:`plot_hist() ` function will correctly put them side by side: +With multiple histograms, the :func:`plot_hist() ` function will correctly put them side by side, because it is a wrapper around the ``hist()`` function from ``matplotlib`` that provides this functionality. .. image:: ../img/1d_side_by_side.svg :alt: Side by side histograms diff --git a/docs/examples/advanced/1d_side_by_side_with_numbers.py b/docs/examples/advanced/1d_side_by_side_with_numbers.py index 62d554f..c5ff44e 100644 --- a/docs/examples/advanced/1d_side_by_side_with_numbers.py +++ b/docs/examples/advanced/1d_side_by_side_with_numbers.py @@ -1,8 +1,8 @@ """ -Side-by-side categories -======================= +Side-by-side categories, with numbers on top +============================================ -Plot multiple 1D histograms with categories side by side. +Plot multiple 1D histograms with categories side by side, and add the number of entries on top of each bar. """ ### diff --git a/src/plothist/plotters.py b/src/plothist/plotters.py index 108035c..7e1f165 100644 --- a/src/plothist/plotters.py +++ b/src/plothist/plotters.py @@ -366,7 +366,7 @@ def plot_error_hist(hist, ax, uncertainty_type="symmetrical", density=False, **k Asymmetrical uncertainties can only be computed for an unweighted histogram, because the bin contents of a weighted histogram do not follow a Poisson distribution. More information in :ref:`documentation-statistics-label`. The uncertainties are overwritten if the keyword argument yerr is provided. - In the case of a mean histogram, only symmetrical uncertainties are supported and correspond to the standard deviation of the sample and not to a Poisson standard deviation (see :ref:`basics-1d_hist_profil_plot-label`). + In the case of a mean histogram, only symmetrical uncertainties are supported and correspond to the standard deviation of the sample and not to a Poisson standard deviation (see :ref:`basics-1d_hist_profile_plot-label`). density : bool, optional Whether to normalize the histogram to unit area. Default is False.