Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bio-IT Workshops
Intermediate Python
Commits
c1a151a5
Verified
Commit
c1a151a5
authored
Jul 20, 2020
by
Renato Alves
🌱
Browse files
Add description of hist
parent
51cc6eff
Changes
2
Hide whitespace changes
Inline
Side-by-side
_episodes/03-plotting.md
View file @
c1a151a5
...
...
@@ -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 }
...
...
_includes/links.md
View file @
c1a151a5
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment