8000 Merge pull request #26607 from meeseeksmachine/auto-backport-of-pr-26… · matplotlib/matplotlib@1d854b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d854b3

Browse files
authored
Merge pull request #26607 from meeseeksmachine/auto-backport-of-pr-26606-on-v3.8.x
Backport PR #26606 on branch v3.8.x ([Doc] Revise histogram features example (Closes #26604))
2 parents 76b727d + 19b1ce6 commit 1d854b3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

galleries/examples/statistics/histogram_features.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import matplotlib.pyplot as plt
2121
import numpy as np
2222

23-
np.random.seed(19680801)
23+
rng = np.random.default_rng(19680801)
2424

2525
# example data
26-
mu = 100 # mean of distribution
27-
sigma = 15 # standard deviation of distribution
28-
x = mu + sigma * np.random.randn(437)
26+
mu = 106 # mean of distribution
27+
sigma = 17 # standard deviation of distribution
28+
x = rng.normal(loc=mu, scale=sigma, size=420)
2929

30-
num_bins = 50
30+
num_bins = 42
3131

3232
fig, ax = plt.subplots()
3333

@@ -38,9 +38,10 @@
3838
y = ((1 / (np.sqrt(2 * np.pi) * sigma)) *
3939
np.exp(-0.5 * (1 / sigma * (bins - mu))**2))
4040
ax.plot(bins, y, '--')
41-
ax.set_xlabel('Smarts')
41+
ax.set_xlabel('Value')
4242
ax.set_ylabel('Probability density')
43-
ax.set_title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')
43+
ax.set_title('Histogram of normal distribution sample: '
44+
fr'$\mu={mu:.0f}$, $\sigma={sigma:.0f}$')
4445

4546
# Tweak spacing to prevent clipping of ylabel
4647
fig.tight_layout()

0 commit comments

Comments
 (0)
0