File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -5014,7 +5014,7 @@ def reduce_C_function(C: array) -> float
50145014 if mincnt is None :
50155015 mincnt = 0
50165016 accum = np .array (
5017- [reduce_C_function (acc ) if len (acc ) > mincnt else np .nan
5017+ [reduce_C_function (acc ) if len (acc ) >= mincnt else np .nan
50185018 for Cs_at_i in [Cs_at_i1 , Cs_at_i2 ]
50195019 for acc in Cs_at_i [1 :]], # [1:] drops out-of-range points.
50205020 float )
Original file line number Diff line number Diff 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+
10021041def test_inverted_limits ():
10031042 # Test gh:1553
10041043 # Calling invert_xaxis prior to plotting should not disable autoscaling
You can’t perform that action at this time.
0 commit comments