mirror of
https://github.com/pim-n/pg-rad
synced 2026-06-17 15:59:35 +02:00
add uncertainty bands in plot for sqrt(N) counting statistics
This commit is contained in:
@ -98,13 +98,26 @@ class ResultPlotter:
|
|||||||
def _draw_counts(self, ax):
|
def _draw_counts(self, ax):
|
||||||
x = self.count_rate_res.distance[1:]
|
x = self.count_rate_res.distance[1:]
|
||||||
y = self.count_rate_res.integrated_counts[1:]
|
y = self.count_rate_res.integrated_counts[1:]
|
||||||
|
|
||||||
|
yerr = np.sqrt(y)
|
||||||
|
peak_idx = y.argmax()
|
||||||
|
|
||||||
|
ax.fill_between(
|
||||||
|
x,
|
||||||
|
y - yerr,
|
||||||
|
y + yerr,
|
||||||
|
color='red',
|
||||||
|
alpha=0.15,
|
||||||
|
)
|
||||||
|
|
||||||
ax.plot(
|
ax.plot(
|
||||||
x, y, color='r', linestyle='--',
|
x, y,
|
||||||
alpha=0.2, label=f'max(counts) = {y.max():.2f}'
|
color='r', linestyle='--', alpha=0.2,
|
||||||
|
label=rf'max(counts)={y[peak_idx]:.2f} $\pm$ {yerr[peak_idx]:.2f}'
|
||||||
)
|
)
|
||||||
ax.legend(handlelength=0, handletextpad=0, fancybox=True)
|
ax.legend(handlelength=0, handletextpad=0, fancybox=True)
|
||||||
ax.scatter(x, y, color='r', marker='x')
|
ax.scatter(x, y, color='r', marker='x')
|
||||||
ax.set_title('Integrated counts')
|
ax.set_title('Counts')
|
||||||
ax.set_xlabel('Arc length s [m]')
|
ax.set_xlabel('Arc length s [m]')
|
||||||
ax.set_ylabel('N')
|
ax.set_ylabel('N')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user