plot_utils: add the unit to the title of the histogram plot
Xin requested units in the mean calculated in the title of the
histogram. Pass the unit as a string explicitly to plot_hist() and let
that function add it to the xlabel and the title.
Change-Id: If617d91617dc2cabf0ce43795581a6240ca40e4e
diff --git a/cr2/plot_utils.py b/cr2/plot_utils.py
index fc01329..2b2cc87 100644
--- a/cr2/plot_utils.py
+++ b/cr2/plot_utils.py
@@ -140,12 +140,13 @@
post_plot_setup(ax, title="Temperature", ylim=ylim)
plt.legend(loc="best")
-def plot_hist(data, ax, title, bins, xlabel, xlim, ylim):
+def plot_hist(data, ax, title, unit, bins, xlabel, xlim, ylim):
"""Plot a histogram"""
mean = data.mean()
std = data.std()
- title += " (mean = {:.2f}, std = {:.2f})".format(mean, std)
+ title += " (mean = {:.2f}{}, std = {:.2f})".format(mean, unit, std)
+ xlabel += " ({})".format(unit)
data.hist(ax=ax, bins=bins)
post_plot_setup(ax, title=title, xlabel=xlabel, ylabel="count", xlim=xlim,