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

Skip to content

Commit 7ce6a69

Browse files
committed
Added test for hexbin mincnt consistency upon C param
1 parent fcda8c8 commit 7ce6a69

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,45 @@ def test_hexbin_log_clim():
999999
assert h.get_clim() == (2, 100)
10001000

10011001

1002+
@check_figures_equal(extensions=['png'])
1003+
def test_hexbin_mincnt_behavior_upon_C_parameter(fig_test, fig_ref):
1004+
# see: gh:12926
1005+
datapoints = [
1006+
# list of (x, y)
1007+
(0, 0),
1008+
(0, 0),
1009+
(6, 0),
1010+
(0, 6),
1011+
]
1012+
X, Y = zip(*datapoints)
1013+
C = [1] * len(X)
1014+
extent = [-10., 10, -10., 10]
1015+
gridsize = (7, 7)
1016+
1017+
ax_test = fig_test.subplots()
1018+
ax_ref = fig_ref.subplots()
1019+
1020+
# without C parameter
1021+
ax_ref.hexbin(
1022+
X, Y,
1023+
extent=extent,
1024+
gridsize=gridsize,
1025+
mincnt=1,
1026+
)
1027+
ax_ref.set_facecolor("green") # for contrast of background
1028+
1029+
# with C parameter
1030+
ax_test.hexbin(
1031+
X, Y,
1032+
C=[1] * len(X),
1033+
reduce_C_function=lambda v: sum(v),
1034+
mincnt=1,
1035+
extent=extent,
1036+
gridsize=gridsize,
1037+
)
1038+
ax_test.set_facecolor("green")
1039+
1040+
10021041
def test_inverted_limits():
10031042
# Test gh:1553
10041043
# Calling invert_xaxis prior to plotting should not disable autoscaling

0 commit comments

Comments
 (0)