MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / hexbin

Method hexbin

lib/matplotlib/axes/_axes.py:5473–5873  ·  view source on GitHub ↗

Make a 2D hexagonal binning plot of points *x*, *y*. If *C* is *None*, the value of the hexagon is determined by the number of points in the hexagon. Otherwise, *C* specifies values at the coordinate (x[i], y[i]). For each hexagon, these values are reduced u

(self, x, y, C=None, gridsize=100, bins=None,
               xscale='linear', yscale='linear', extent=None,
               cmap=None, norm=None, vmin=None, vmax=None,
               alpha=None, linewidths=None, edgecolors='face',
               reduce_C_function=np.mean, mincnt=None, marginals=False,
               colorizer=None, **kwargs)

Source from the content-addressed store, hash-verified

5471 @_preprocess_data(replace_names=["x", "y", "C"], label_namer="y")
5472 @_docstring.interpd
5473 def hexbin(self, x, y, C=None, gridsize=100, bins=None,
5474 xscale='linear', yscale='linear', extent=None,
5475 cmap=None, norm=None, vmin=None, vmax=None,
5476 alpha=None, linewidths=None, edgecolors='face',
5477 reduce_C_function=np.mean, mincnt=None, marginals=False,
5478 colorizer=None, **kwargs):
5479 """
5480 Make a 2D hexagonal binning plot of points *x*, *y*.
5481
5482 If *C* is *None*, the value of the hexagon is determined by the number
5483 of points in the hexagon. Otherwise, *C* specifies values at the
5484 coordinate (x[i], y[i]). For each hexagon, these values are reduced
5485 using *reduce_C_function*.
5486
5487 Parameters
5488 ----------
5489 x, y : array-like
5490 The data positions. *x* and *y* must be of the same length.
5491
5492 C : array-like, optional
5493 If given, these values are accumulated in the bins. Otherwise,
5494 every point has a value of 1. Must be of the same length as *x*
5495 and *y*.
5496
5497 gridsize : int or (int, int), default: 100
5498 If a single int, the number of hexagons in the *x*-direction.
5499 The number of hexagons in the *y*-direction is chosen such that
5500 the hexagons are approximately regular.
5501
5502 Alternatively, if a tuple (*nx*, *ny*), the number of hexagons
5503 in the *x*-direction and the *y*-direction. In the
5504 *y*-direction, counting is done along vertically aligned
5505 hexagons, not along the zig-zag chains of hexagons; see the
5506 following illustration.
5507
5508 .. plot::
5509
5510 import numpy
5511 import matplotlib.pyplot as plt
5512
5513 np.random.seed(19680801)
5514 n= 300
5515 x = np.random.standard_normal(n)
5516 y = np.random.standard_normal(n)
5517
5518 fig, ax = plt.subplots(figsize=(4, 4))
5519 h = ax.hexbin(x, y, gridsize=(5, 3))
5520 hx, hy = h.get_offsets().T
5521 ax.plot(hx[24::3], hy[24::3], 'ro-')
5522 ax.plot(hx[-3:], hy[-3:], 'ro-')
5523 ax.set_title('gridsize=(5, 3)')
5524 ax.axis('off')
5525
5526 To get approximately regular hexagons, choose
5527 :math:`n_x = \\sqrt{3}\\,n_y`.
5528
5529 bins : 'log' or int or sequence, default: None
5530 Discretization of the hexagon values.

Callers 15

hexbinFunction · 0.80
test_hexbinMethod · 0.80
test_hexbin_extentFunction · 0.80
test_hexbin_bad_extentsFunction · 0.80
test_hexbin_string_normFunction · 0.80
test_hexbin_emptyFunction · 0.80
test_hexbin_pickableFunction · 0.80
test_hexbin_logFunction · 0.80
test_hexbin_log_offsetsFunction · 0.80
test_hexbin_linearFunction · 0.80
test_hexbin_log_climFunction · 0.80

Calls 15

_process_unit_infoMethod · 0.80
sqrtMethod · 0.80
minMethod · 0.80
maxMethod · 0.80
set_xscaleMethod · 0.80
_internal_updateMethod · 0.80
add_collectionMethod · 0.80
set_yscaleMethod · 0.45
set_cmapMethod · 0.45
set_normMethod · 0.45

Tested by 14

test_hexbinMethod · 0.64
test_hexbin_extentFunction · 0.64
test_hexbin_bad_extentsFunction · 0.64
test_hexbin_string_normFunction · 0.64
test_hexbin_emptyFunction · 0.64
test_hexbin_pickableFunction · 0.64
test_hexbin_logFunction · 0.64
test_hexbin_log_offsetsFunction · 0.64
test_hexbin_linearFunction · 0.64
test_hexbin_log_climFunction · 0.64
test_pathological_hexbinFunction · 0.64