Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit653be4e

Browse files
committed
Add description about density and tests
1 parentd063002 commit653be4e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6878,6 +6878,9 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None,
68786878
keyword argument. Likewise, power-law normalization (similar
68796879
in effect to gamma correction) can be accomplished with
68806880
`.colors.PowerNorm`.
6881+
- Numpy 1.15 introduced a 'density' kwarg to hist2d. Even though
6882+
Numpy 1.15 isn't required, 'density' kwarg is introduced
6883+
and passed as 'normed' to ``hist2d``.
68816884
"""
68826885

68836886
ifdensityisnotNoneandnormedisnotNone:

‎lib/matplotlib/tests/test_axes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,30 @@ def test_hist2d():
16721672
ax.hist2d("x","y",bins=10,data=data,rasterized=True)
16731673

16741674

1675+
@pytest.mark.parametrize('density', [False,True])
1676+
deftest_hist2d_density(density):
1677+
# Test density kwarg
1678+
x=np.random.randn(100)*2+5
1679+
y=np.random.randn(100)-2
1680+
fig=plt.figure()
1681+
ax=fig.add_subplot(111)
1682+
ax.hist2d(x,y,bins=10,rasterized=True,density=density)
1683+
1684+
1685+
@pytest.mark.parametrize('normed', [False,True])
1686+
@pytest.mark.parametrize('density', [False,True])
1687+
deftest_hist2d_normed_density(density,normed):
1688+
# Normed and density should not be used simultaneously
1689+
x=np.random.randn(100)*2+5
1690+
y=np.random.randn(100)-2
1691+
fig=plt.figure()
1692+
ax=fig.add_subplot(111)
1693+
# test that kwargs normed and density cannot be set both.
1694+
withpytest.raises(ValueError,match="kwargs 'density' and 'normed'"):
1695+
ax.hist2d(x,y,bins=10,rasterized=True,
1696+
density=density,normed=normed)
1697+
1698+
16751699
@image_comparison(baseline_images=['hist2d_transpose'],
16761700
remove_text=True,style='mpl20')
16771701
deftest_hist2d_transpose():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp