@@ -6410,10 +6410,11 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6410
6410
"""
6411
6411
Plot a histogram.
6412
6412
6413
- Compute and draw the histogram of *x*. The return value is a
6414
- tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
6415
- [*patches0*, *patches1*,...]) if the input contains multiple
6416
- data.
6413
+ Compute and draw the histogram of *x*. The return value is a tuple
6414
+ (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*, [*patches0*,
6415
+ *patches1*,...]) if the input contains multiple data. See the
6416
+ documentation of the *weights* parameter to draw a histogram of
6417
+ already-binned data.
6417
6418
6418
6419
Multiple data can be provided via *x* as a list of datasets
6419
6420
of potentially different length ([*x0*, *x1*, ...]), or as
@@ -6487,7 +6488,16 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6487
6488
the weights are normalized, so that the integral of the density
6488
6489
over the range remains 1.
6489
6490
6490
- Default is ``None``
6491
+ Default is ``None``.
6492
+
6493
+ This parameter can be used to draw a histogram of data that has
6494
+ already been binned, e.g. using `np.histogram` (by treating each
6495
+ bin as a single point with a weight equal to its count) ::
6496
+
6497
+ counts, bins = np.histogram(data)
6498
+ plt.hist(bins[:-1], bins, weights=counts)
6499
+
6500
+ (or you may alternatively use `~.bar()`).
6491
6501
6492
6502
cumulative : bool, optional
6493
6503
If ``True``, then a histogram is computed where each bin gives the
0 commit comments