Verified Commit c1a151a5 authored by Renato Alves's avatar Renato Alves 🌱
Browse files

Add description of hist

parent 51cc6eff
......@@ -556,6 +556,14 @@ Given `plot(X, Y)` it then takes a pair of coordinates from both variables as wi
### Histograms
Another very common type of plot is the `histogram` which can be produced using
the [`plt.hist()` function][matplotlib-hist].
A `histogram` is a bar-plot where one axis represents the range of values in the data being plotted,
and the other axis, a count of the values in the interval defined by the bar.
The width of the bars is determined by the `bins` attribute which specifies
how many bars should be displayed.
~~~
import numpy as np
import matplotlib.pyplot as plt
......@@ -570,10 +578,10 @@ normal_dist = np.random.normal(mean, stdev, samples)
# Create a histogram with the sampled values
plt.hist(normal_dist, bins)
# Add a dotted thin line grid on both axis
plt.grid(linestyle="dotted", linewidth=1)
plt.title(f"Normal distribution - mean={mean}, stdev={stdev}, samples={samples}, binning={1/bins}")
plt.title(f"$X \\sim \\mathcal{N}(\\mu,\\,\\sigma^{2})$ - $\\mu$={mean}, $\\sigma^{2}$={stdev}, samples={samples}, binning={1/bins}")
~~~
{: .language-python }
......
......@@ -94,6 +94,7 @@
[matplotlib-home]: https://matplotlib.org/
[matplotlib-linestyle]: https://matplotlib.org/3.2.2/gallery/lines_bars_and_markers/linestyles.html
[matplotlib-markerstyle]: https://matplotlib.org/3.2.2/api/markers_api.html
[matplotlib-hist]: https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.hist.html
[matplotlib-plot]: https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.plot.html
[matplotlib-scatter]: https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.scatter.html
[matplotlib-scatter-examples]: https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.scatter.html#examples-using-matplotlib-pyplot-scatter
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment