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
1a30f390
Verified
Commit
1a30f390
authored
Jul 20, 2020
by
Renato Alves
🌱
Browse files
Include density cumulative function
parent
9b5a6eef
Changes
5
Hide whitespace changes
Inline
Side-by-side
_episodes/03-plotting.md
View file @
1a30f390
...
...
@@ -600,7 +600,7 @@ plt.title(f"Normal distribution - mean={mean}, stdev={stdev}, samples={samples},
> to have a nicely typeset `μ` character in the title.
> Doing full stylization with LaTeX we could use:
> ~~~
> plt.title(f"$X \\sim \\mathcal{
N
}(\\mu,\\,\\sigma^{
2
})$ - $\\mu$={mean}, $\\sigma^{
2
}$={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 }
>
...
...
@@ -615,10 +615,42 @@ plt.title(f"Normal distribution - mean={mean}, stdev={stdev}, samples={samples},
> by prefixing it with `r`, becoming `r"\alpha"`.
{: .callout }
## Scatter
> ## A Dense Histogram
>
> Exploring the [documentation of `plt.hist()`][matplotlib-hist], find how to add
> a *probability density* projection of the plot above.
>
> When plotting as density, the values in the `Y` axis change.
> Is this representation easier to understand than the default histogram with counts?
> What if in addition the histogram is made cumulative?
>
> > ## Solution
> >
> > The `plt.hist()` function accepts a `density=True` and a `cumulative=True` option.
> > Although the `Y` axis values change, the bars should have the same visual representation
> > (unless a new random sample was generated).
> >
> > A density plot transforms the `Y` scale such that the area under the histogram
> > adds to `1`.
> > A value of `0.40` implies that the area occupied by the central bar represents 40% of the points.
> > ~~~
> > plt.hist(normal_dist, bins, density=True)
> > ~~~
> > {: .language-python }
> > 
> >
> > A perhaps more intuitive plot, is represented by the cumulative density, which
> > as previously described should add to `1`.
> > ~~~
> > plt.hist(normal_dist, bins, density=True, cumulative=True)
> > ~~~
> > {: .language-python }
> > 
> >
> {: .solution }
{: .challenge }
## Bar
## Histograms
## Subplots
-
the next exercise assumes an example of subplots arranged in a single row or column
...
...
fig/normal-hist-cumuldensity.png
0 → 100644
View file @
1a30f390
32.3 KB
fig/normal-hist-density.png
0 → 100644
View file @
1a30f390
38.8 KB
fig/normal-hist-latex.png
View replaced file @
9b5a6eef
View file @
1a30f390
37.1 KB
|
W:
|
H:
36.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
fig/normal-hist.png
View replaced file @
9b5a6eef
View file @
1a30f390
40 KB
|
W:
|
H:
39 KB
|
W:
|
H:
2-up
Swipe
Onion skin
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