@@ -4675,26 +4675,14 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
4675
4675
if C is None :
4676
4676
lattice1 = np .zeros ((nx1 , ny1 ))
4677
4677
lattice2 = np .zeros ((nx2 , ny2 ))
4678
-
4679
- cond1 = (0 <= ix1 ) * (ix1 < nx1 ) * (0 <= iy1 ) * (iy1 < ny1 )
4680
- cond2 = (0 <= ix2 ) * (ix2 < nx2 ) * (0 <= iy2 ) * (iy2 < ny2 )
4681
-
4682
- cond1 *= bdist
4683
- cond2 *= np .logical_not (bdist )
4684
- ix1 , iy1 = ix1 [cond1 ], iy1 [cond1 ]
4685
- ix2 , iy2 = ix2 [cond2 ], iy2 [cond2 ]
4686
-
4687
- for ix , iy in zip (ix1 , iy1 ):
4688
- lattice1 [ix , iy ] += 1
4689
- for ix , iy in zip (ix2 , iy2 ):
4690
- lattice2 [ix , iy ] += 1
4691
-
4692
- # threshold
4678
+ c1 = (0 <= ix1 ) & (ix1 < nx1 ) & (0 <= iy1 ) & (iy1 < ny1 ) & bdist
4679
+ c2 = (0 <= ix2 ) & (ix2 < nx2 ) & (0 <= iy2 ) & (iy2 < ny2 ) & ~ bdist
4680
+ np .add .at (lattice1 , (ix1 [c1 ], iy1 [c1 ]), 1 )
4681
+ np .add .at (lattice2 , (ix2 [c2 ], iy2 [c2 ]), 1 )
4693
4682
if mincnt is not None :
4694
4683
lattice1 [lattice1 < mincnt ] = np .nan
4695
4684
lattice2 [lattice2 < mincnt ] = np .nan
4696
- accum = np .hstack ((lattice1 .ravel (),
4697
- lattice2 .ravel ()))
4685
+ accum = np .concatenate ([lattice1 .ravel (), lattice2 .ravel ()])
4698
4686
good_idxs = ~ np .isnan (accum )
4699
4687
4700
4688
else :
@@ -4751,9 +4739,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
4751
4739
offsets = offsets [good_idxs , :]
4752
4740
accum = accum [good_idxs ]
4753
4741
4754
- polygon = np .zeros ((6 , 2 ), float )
4755
- polygon [:, 0 ] = sx * np .array ([0.5 , 0.5 , 0.0 , - 0.5 , - 0.5 , 0.0 ])
4756
- polygon [:, 1 ] = sy * np .array ([- 0.5 , 0.5 , 1.0 , 0.5 , - 0.5 , - 1.0 ]) / 3.0
4742
+ polygon = [sx , sy / 3 ] * np .array (
4743
+ [[.5 , - .5 ], [.5 , .5 ], [0. , 1. ], [- .5 , .5 ], [- .5 , - .5 ], [0. , - 1. ]])
4757
4744
4758
4745
if linewidths is None :
4759
4746
linewidths = [1.0 ]
0 commit comments