Plot histograms

master
Dan Howe 3 years ago
parent 68c128ebe2
commit b3b69c7933

@ -122,4 +122,42 @@ if PLOT:
ax.spines['right'].set_visible(False)
plt.show()
# Show histgrams with values clipped to our specific range
if PLOT:
for i, row in dff[::4].iterrows():
fig, ax = plt.subplots(1, 1, figsize=(10, 2))
# Generate random samples in Cauchy distribution
r = stats.cauchy(loc=row['loc'], scale=row['scale']).rvs(1000000)
# Clip to our range
x_min = row[5] + (row[5] - row[50])
x_max = row[95] + (row[95] - row[50])
rc = np.clip(r, a_min=x_min, a_max=x_max)
f = (r != rc).sum() / len(r) # Fraction outside range
ax.hist(rc, 100)
ym = ax.get_ylim()[1] # Maximum y value
ax.axvline(x=x_min, c='C3')
ax.axvline(x=row[5], c='C3')
ax.axvline(x=row[50], c='C3')
ax.axvline(x=row[95], c='C3')
ax.axvline(x=x_max, c='C3')
ax.annotate(' P0', (x_min, ym))
ax.annotate(' P5', (row[5], ym))
ax.annotate(' P50', (row[50], ym))
ax.annotate(' P95', (row[95], ym))
ax.annotate(' P100', (x_max, ym))
ax.annotate(f' Samples clipped = {100 * f:0.1f}%', (x_max, ym / 2))
ax.set_title(row.name, x=0)
ax.set_yticks([])
ax.set_xlabel('SLR (m)', labelpad=10)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.show()

Loading…
Cancel
Save