@@ -4496,63 +4496,60 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
4496
4496
reduce_C_function = np .mean , mincnt = None , marginals = False ,
4497
4497
** kwargs ):
4498
4498
"""
4499
- Make a hexagonal binning plot.
4499
+ Make a 2D hexagonal binning plot of points *x*, *y* .
4500
4500
4501
- Make a hexagonal binning plot of *x* versus *y*, where *x*,
4502
- *y* are 1-D sequences of the same length, *N*. If *C* is *None*
4503
- (the default), this is a histogram of the number of occurrences
4504
- of the observations at (x[i],y[i]).
4505
-
4506
- If *C* is specified, it specifies values at the coordinate
4507
- (x[i], y[i]). These values are accumulated for each hexagonal
4508
- bin and then reduced according to *reduce_C_function*, which
4509
- defaults to `numpy.mean`. (If *C* is specified, it must also
4510
- be a 1-D sequence of the same length as *x* and *y*.)
4501
+ If *C* is *None*, the value of the hexagon is determined by the number
4502
+ of points in the hexagon. Otherwise, *C* specifies values at the
4503
+ coordinate (x[i], y[i]). For each hexagon, these values are reduced
4504
+ using *reduce_C_function*.
4511
4505
4512
4506
Parameters
4513
4507
----------
4514
- x, y : array or masked array
4515
-
4516
- C : array or masked array, optional, default is *None*
4508
+ x, y : array-like
4509
+ The data positions. *x* and *y* must be of the same length.
4517
4510
4518
- gridsize : int or (int, int), optional, default is 100
4519
- The number of hexagons in the *x*-direction, default is
4520
- 100. The corresponding number of hexagons in the
4521
- *y*-direction is chosen such that the hexagons are
4522
- approximately regular. Alternatively, gridsize can be a
4523
- tuple with two elements specifying the number of hexagons
4524
- in the *x*-direction and the *y*-direction.
4511
+ C : array-like, optional
4512
+ If given, these values are accumulated in the bins. Otherwise,
4513
+ every point has a value of 1. Must be of the same length as *x*
4514
+ and *y*.
4525
4515
4526
- bins : 'log' or int or sequence, optional, default is *None*
4527
- If *None*, no binning is applied; the color of each hexagon
4528
- directly corresponds to its count value.
4516
+ gridsize : int or (int, int), default: 100
4517
+ If a single int, the number of hexagons in the *x*-direction.
4518
+ The number of hexagons in the *y*-direction is chosen such that
4519
+ the hexagons are approximately regular.
4529
4520
4530
- If 'log', use a logarithmic scale for the color
4531
- map. Internally, :math:`log_{10}(i+1)` is used to
4532
- determine the hexagon color.
4521
+ Alternatively, if a tuple (*nx*, *ny*), the number of hexagons
4522
+ in the *x*-direction and the *y*-direction.
4533
4523
4534
- If an integer, divide the counts in the specified number
4535
- of bins, and color the hexagons accordingly .
4524
+ bins : 'log' or int or sequence, default: *None*
4525
+ Discretization of the hexagon values .
4536
4526
4537
- If a sequence of values, the values of the lower bound of
4538
- the bins to be used.
4527
+ - If *None*, no binning is applied; the color of each hexagon
4528
+ directly corresponds to its count value.
4529
+ - If 'log', use a logarithmic scale for the color map.
4530
+ Internally, :math:`log_{10}(i+1)` is used to determine the
4531
+ hexagon color. This is equivalent to ``norm=LogNorm()``.
4532
+ - If an integer, divide the counts in the specified number
4533
+ of bins, and color the hexagons accordingly.
4534
+ - If a sequence of values, the values of the lower bound of
4535
+ the bins to be used.
4539
4536
4540
- xscale : {'linear', 'log'}, optional, default is 'linear'
4537
+ xscale : {'linear', 'log'}, default: 'linear'
4541
4538
Use a linear or log10 scale on the horizontal axis.
4542
4539
4543
- yscale : {'linear', 'log'}, optional, default is 'linear'
4540
+ yscale : {'linear', 'log'}, default: 'linear'
4544
4541
Use a linear or log10 scale on the vertical axis.
4545
4542
4546
- mincnt : int > 0, optional, default is *None*
4543
+ mincnt : int > 0, default: *None*
4547
4544
If not *None*, only display cells with more than *mincnt*
4548
- number of points in the cell
4545
+ number of points in the cell.
4549
4546
4550
- marginals : bool, optional, default is *False*
4551
- if marginals is *True*, plot the marginal density as
4547
+ marginals : bool, default: *False*
4548
+ If marginals is *True*, plot the marginal density as
4552
4549
colormapped rectangles along the bottom of the x-axis and
4553
- left of the y-axis
4550
+ left of the y-axis.
4554
4551
4555
- extent : scalar, optional, default is *None*
4552
+ extent : float, default: *None*
4556
4553
The limits of the bins. The default assigns the limits
4557
4554
based on *gridsize*, *x*, *y*, *xscale* and *yscale*.
4558
4555
@@ -4565,54 +4562,67 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
4565
4562
4566
4563
Other Parameters
4567
4564
----------------
4568
- cmap : object, optional, default is *None*
4569
- a :class:`matplotlib.colors. Colormap` instance. If *None*,
4570
- defaults to rc `` image.cmap` `.
4565
+ cmap : str or `~matplotlib.colors.Colormap`, optional
4566
+ The Colormap instance or registered colormap name used to map
4567
+ the bin values to colors. Defaults to :rc:` image.cmap`.
4571
4568
4572
- norm : object, optional, default is *None*
4573
- :class:`matplotlib.colors.Normalize` instance is used to
4574
- scale luminance data to (0, 1).
4569
+ norm : `~matplotlib.colors.Normalize`, optional
4570
+ The Normalize instance scales the bin values to the canonical
4571
+ colormap range [0, 1] for mapping to colors. By default, the data
4572
+ range is mapped to the colorbar range using linear scaling.
4575
4573
4576
- vmin, vmax : scalar , optional, default is * None*
4577
- *vmin* and *vmax* are used in conjunction with *norm* to
4578
- normalize luminance data. If *None*, the min and max of the
4579
- color array *C* are used. Note if you pass a norm instance
4580
- your settings for *vmin* and *vmax* will be ignored .
4574
+ vmin, vmax : float , optional, default: None
4575
+ The colorbar range. If *None*, suitable min/max values are
4576
+ automatically chosen by the `~.Normalize` instance (defaults to
4577
+ the respective min/max values of the bins in case of the default
4578
+ linear scaling). This is ignored if *norm* is given .
4581
4579
4582
- alpha : scalar between 0 and 1, optional, default is *None*
4583
- the alpha value for the patches
4580
+ alpha : float between 0 and 1, optional
4581
+ The alpha blending value, between 0 (transparent) and 1 (opaque).
4584
4582
4585
- linewidths : scalar, optional, default is *None*
4583
+ linewidths : float, default: *None*
4586
4584
If *None*, defaults to 1.0.
4587
4585
4588
- edgecolors : {'face', 'none', *None*} or color, optional
4586
+ edgecolors : {'face', 'none', *None*} or color, default: 'face'
4587
+ The color of the hexagon edges. Possible values are:
4589
4588
4590
- If 'face' (the default), draws the edges in the same color as the
4591
- fill color.
4589
+ - 'face': Draw the edges in the same color as the fill color.
4590
+ - 'none': No edges are drawn. This can sometimes lead to unsightly
4591
+ unpainted pixels between the hexagons.
4592
+ - *None*: Draw outlines in the default color.
4593
+ - An explicit matplotlib color.
4592
4594
4593
- If 'none', no edge is drawn; this can sometimes lead to unsightly
4594
- unpainted pixels between the hexagons.
4595
+ reduce_C_function : callable, default is `numpy.mean`
4596
+ The function to aggregate *C* within the bins. It is ignored if
4597
+ *C* is not given. This must have the signature::
4595
4598
4596
- If *None*, draws outlines in the default color.
4599
+ def reduce_C_function(C: array) -> float
4597
4600
4598
- If a matplotlib color arg, draws outlines in the specified color.
4601
+ Commonly used functions are:
4602
+
4603
+ - `numpy.mean`: average of the points
4604
+ - `numpy.sum`: integral of the point values
4605
+ - `numpy.max`: value taken from the largest point
4606
+
4607
+ **kwargs : `~matplotlib.collections.PolyCollection` properties
4608
+ All other keyword arguments are passed on to `.PolyCollection`:
4609
+
4610
+ %(PolyCollection)s
4599
4611
4600
4612
Returns
4601
4613
-------
4602
- polycollection
4603
- A `.PolyCollection` instance; use `.PolyCollection.get_array` on
4604
- this to get the counts in each hexagon.
4614
+ polycollection : `~matplotlib.collections.PolyCollection`
4615
+ A `.PolyCollection` defining the hexagonal bins.
4616
+
4617
+ - `.PolyCollection.get_offset` contains a Mx2 array containing
4618
+ the x, y positions of the M hexagon centers.
4619
+ - `.PolyCollection.get_array` contains the values of the M
4620
+ hexagons.
4605
4621
4606
4622
If *marginals* is *True*, horizontal
4607
4623
bar and vertical bar (both PolyCollections) will be attached
4608
4624
to the return collection as attributes *hbar* and *vbar*.
4609
4625
4610
- Notes
4611
- -----
4612
- The standard descriptions of all the
4613
- :class:`~matplotlib.collections.Collection` parameters:
4614
-
4615
- %(Collection)s
4616
4626
"""
4617
4627
self ._process_unit_info (xdata = x , ydata = y , kwargs = kwargs )
4618
4628
0 commit comments