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