Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 433049c

Browse files
authored
Merge pull request #10171 from dstansby/normed-examples
Replace normed with density in examples
2 parents 58ddc36 + 5de94c3 commit 433049c

File tree

9 files changed

+13
-12
lines changed

9 files changed

+13
-12
lines changed

examples/frontpage/histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
X = random_state.randn(10000)
1515

1616
fig, ax = plt.subplots()
17-
ax.hist(X, bins=25, normed=True)
17+
ax.hist(X, bins=25, density=True)
1818
x = np.linspace(-5, 5, 1000)
1919
ax.plot(x, 1 / np.sqrt(2*np.pi) * np.exp(-(x**2)/2), linewidth=4)
2020
ax.set_xticks([])

examples/pyplots/pyplot_text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
x = mu + sigma * np.random.randn(10000)
1515

1616
# the histogram of the data
17-
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
17+
n, bins, patches = plt.hist(x, 50, density=True, facecolor='g', alpha=0.75)
1818

1919

2020
plt.xlabel('Smarts')

examples/statistics/histogram_cumulative.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
fig, ax = plt.subplots(figsize=(8, 4))
5050

5151
# plot the cumulative histogram
52-
n, bins, patches = ax.hist(x, n_bins, normed=1, histtype='step',
52+
n, bins, patches = ax.hist(x, n_bins, density=True, histtype='step',
5353
cumulative=True, label='Empirical')
5454

5555
# Add a line showing the expected distribution.
@@ -59,7 +59,7 @@
5959
ax.plot(bins, y, 'k--', linewidth=1.5, label='Theoretical')
6060

6161
# Overlay a reversed cumulative histogram.
62-
ax.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1,
62+
ax.hist(x, bins=bins, density=True, histtype='step', cumulative=-1,
6363
label='Reversed emp.')
6464

6565
# tidy up the figure

examples/statistics/histogram_histtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4))
2525

26-
ax0.hist(x, 20, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75)
26+
ax0.hist(x, 20, density=True, histtype='stepfilled', facecolor='g', alpha=0.75)
2727
ax0.set_title('stepfilled')
2828

2929
# Create a histogram by providing the bin edges (unequally spaced).
3030
bins = [100, 150, 180, 195, 205, 220, 250, 300]
31-
ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8)
31+
ax1.hist(x, bins, density=True, histtype='bar', rwidth=0.8)
3232
ax1.set_title('unequal bins')
3333

3434
fig.tight_layout()

examples/statistics/histogram_multihist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
ax0, ax1, ax2, ax3 = axes.flatten()
2929

3030
colors = ['red', 'tan', 'lime']
31-
ax0.hist(x, n_bins, normed=1, histtype='bar', color=colors, label=colors)
31+
ax0.hist(x, n_bins, density=True, histtype='bar', color=colors, label=colors)
3232
ax0.legend(prop={'size': 10})
3333
ax0.set_title('bars with legend')
3434

35-
ax1.hist(x, n_bins, normed=1, histtype='bar', stacked=True)
35+
ax1.hist(x, n_bins, density=True, histtype='bar', stacked=True)
3636
ax1.set_title('stacked bar')
3737

3838
ax2.hist(x, n_bins, histtype='step', stacked=True, fill=False)

examples/style_sheets/bmh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
def plot_beta_hist(ax, a, b):
2020
ax.hist(beta(a, b, size=10000), histtype="stepfilled",
21-
bins=25, alpha=0.8, normed=True)
21+
bins=25, alpha=0.8, density=True)
2222

2323

2424
fig, ax = plt.subplots()

examples/style_sheets/style_sheets_reference.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def plot_histograms(ax, prng, nb_samples=10000):
8888
params = ((10, 10), (4, 12), (50, 12), (6, 55))
8989
for a, b in params:
9090
values = prng.beta(a, b, size=nb_samples)
91-
ax.hist(values, histtype="stepfilled", bins=30, alpha=0.8, normed=True)
91+
ax.hist(values, histtype="stepfilled", bins=30,
92+
alpha=0.8, density=True)
9293
# Add a small annotation.
9394
ax.annotate('Annotation', xy=(0.25, 4.25), xycoords='data',
9495
xytext=(0.9, 0.9), textcoords='axes fraction',

examples/subplots_axes_and_figures/axes_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# this is an inset axes over the main axes
3030
a = plt.axes([.65, .6, .2, .2], facecolor='k')
31-
n, bins, patches = plt.hist(s, 400, normed=1)
31+
n, bins, patches = plt.hist(s, 400, density=True)
3232
plt.title('Probability')
3333
plt.xticks([])
3434
plt.yticks([])

examples/user_interfaces/histogram_demo_canvasagg_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
x = mu + sigma * np.random.randn(10000)
2727

2828
# the histogram of the data
29-
n, bins, patches = ax.hist(x, 50, normed=1)
29+
n, bins, patches = ax.hist(x, 50, density=True)
3030

3131
# add a 'best fit' line
3232
y = normpdf(bins, mu, sigma)

0 commit comments

Comments
 (0)