@@ -6375,10 +6375,11 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6375
6375
"""
6376
6376
Plot a histogram.
6377
6377
6378
- Compute and draw the histogram of *x*. The return value is a
6379
- tuple (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
6380
- [*patches0*, *patches1*,...]) if the input contains multiple
6381
- data.
6378
+ Compute and draw the histogram of *x*. The return value is a tuple
6379
+ (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*, [*patches0*,
6380
+ *patches1*,...]) if the input contains multiple data. See the
6381
+ documentation of the *weights* parameter to draw a histogram of
6382
+ already-binned data.
6382
6383
6383
6384
Multiple data can be provided via *x* as a list of datasets
6384
6385
of potentially different length ([*x0*, *x1*, ...]), or as
@@ -6452,7 +6453,16 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6452
6453
the weights are normalized, so that the integral of the density
6453
6454
over the range remains 1.
6454
6455
6455
- Default is ``None``
6456
+ Default is ``None``.
6457
+
6458
+ This parameter can be used to draw a histogram of data that has
6459
+ already been binned, e.g. using `np.histogram` (by treating each
6460
+ bin as a single point with a weight equal to its count) ::
6461
+
6462
+ counts, bins = np.histogram(data)
6463
+ plt.hist(bins[:-1], bins, weights=counts)
6464
+
6465
+ (or you may alternatively use `~.bar()`).
6456
6466
6457
6467
cumulative : bool, optional
6458
6468
If ``True``, then a histogram is computed where each bin gives the
0 commit comments