Skip to content

MEP12 improvments for statistics plots #7331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2016

Conversation

phobson
Copy link
Member

@phobson phobson commented Oct 22, 2016

This isn't ready yet -- but I noticed a lot of MEP12 PRs, so I wanted to get this up sooner to avoid duplicate efforts

@phobson phobson added Documentation MEP: MEP12 gallery and examples improvements labels Oct 22, 2016
@phobson phobson added this to the 2.0.1 (next bug fix release) milestone Oct 22, 2016
@phobson phobson self-assigned this Oct 22, 2016
@NelleV
Copy link
Member

NelleV commented Oct 22, 2016

I've added those as being "done" on #7206.

@phobson
Copy link
Member Author

phobson commented Oct 22, 2016

@NelleV cool, I'll update it as I go.

@phobson phobson force-pushed the MEP12-statistic-plots branch from 5aadd99 to bb8143a Compare October 22, 2016 19:26
@phobson phobson changed the title (WIP) MEP12 improvments for statistics plots MEP12 improvments for statistics plots Oct 22, 2016
@QuLogic
Copy link
Member

QuLogic commented Oct 22, 2016

Can you add the titling =s while you're here?

@phobson
Copy link
Member Author

phobson commented Oct 22, 2016

@QuLogic I don't follow.

@NelleV
Copy link
Member

NelleV commented Oct 22, 2016

@phobson if the title is written in restructured text format, it will be rendered as so with sphinx-gallery. It is not requirement for the examples to be parsed properly, but it does look much nicer.

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the plots PEP8-good now?

mean is the only value not shown by default). The second
figure demonstrates how the styles of the artists of can
be customized. It also demonstrates how to set the limit
if the whiskers to specific percentiles (lower right axes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if -> of.
Missing period at end of sentence.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there a reason for wrapping lines so early?

statistics to the box plot drawer. The first figure demostrates
how to remove and add individual components (note that the
mean is the only value not shown by default). The second
figure demonstrates how the styles of the artists of can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove second 'of'.

The first plot shows the default style by providing only
the data. The second plot first limits what matplotlib draws
with additional kwargs. Then a simplified representation of
a box plot in drawn on top. Lastly, the styles of arists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arists -> artists

for ax in [ax1, ax2]:
ax.get_xaxis().set_tick_params(direction='out')
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks([x + 1 for x in range(len(lab))])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could maybe replace this with np.arange(1, ...) instead.

Demo of the errorbar function
=============================

This exhibits the most basic use of of the error bar method.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double 'of'.

Demo of how to produce multiple histograms side by side
=======================================================

This example plots horizonal histograms of different samples along
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

horizonal -> horizontal

Violin plots are similar to histograms and box plots in that they show
an abstract representation of the probability distribution of the
sample. Rather than showing counts of data points that fall into bins
or order statistics, violin plots use kernal density estimation (KDE) to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kernal -> kernel

or order statistics, violin plots use kernal density estimation (KDE) to
compute an emperical distribution of the sample. That computation
is controlled by several parameters. This example demostrates how to
modify the number of points at the KDE is evaluated (``points``) and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at -> at which (or maybe "for which", depending on the exact meaning.)

compute an emperical distribution of the sample. That computation
is controlled by several parameters. This example demostrates how to
modify the number of points at the KDE is evaluated (``points``) and
how to modify the band-width of the kde (``bw_method``).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kde -> KDE
for consistency.

an abstract representation of the probability distribution of the
sample. Rather than showing counts of data points that fall into bins
or order statistics, violin plots use kernal density estimation (KDE) to
compute an emperical distribution of the sample. That computation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emperical -> empirical

Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.
I've underlined a couple of typos, but this is a huge improvements in our examples. Thanks for the work put into this!

=========================================

This example demonstrates how to use the various kwargs
to fully customize box plots. The first figure demostrates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: demostrates -> demonstrates

to fully customize box plots. The first figure demostrates
how to remove and add individual components (note that the
mean is the only value not shown by default). The second
figure demonstrates how the styles of the artists of can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type: there is an extra of

===================================

This example demonstrates how to pass pre-computed box plot
statistics to the box plot drawer. The first figure demostrates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: demostrates -> demonstrates

The first plot shows the default style by providing only
the data. The second plot first limits what matplotlib draws
with additional kwargs. Then a simplified representation of
a box plot in drawn on top. Lastly, the styles of the artists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: in -> is

called `make_error_boxes`. Close inspection of this function will reveal
the preferred pattern in writing functions for matplotlib:

1. an `Axes` object is passed directly to the function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

A couple of other options to the ``hist`` function are demonstrated.
Namely, we use the ``normed`` parameter to normalize the histogram and
a couple of different options to the `cumulative` parameter. Normalizing
a histogram means that the heights bins are scaled such that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"heights bins" or "height bins"? I never know…

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither: "bin heights"

modify the number of points at which the KDE is evaluated (``points``)
and how to modify the band-width of the KDE (``bw_method``).

For more information on violin plots and KDE, the scikit-learn docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 (I am of course totally biased…)

for ax in [ax1, ax2]:
ax.get_xaxis().set_tick_params(direction='out')
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks([x for x in np.arange(1, len(lab) + 1)])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the list comprehension now.

@phobson phobson force-pushed the MEP12-statistic-plots branch from 146a417 to a47556a Compare October 23, 2016 15:39
@phobson
Copy link
Member Author

phobson commented Oct 23, 2016

@QuLogic -- I never answered your question about PEP8. Yes. The pep8 that I ran locally w/o any exceptions didn't complain at all and Travis was happy with the last pass at them.

@phobson phobson force-pushed the MEP12-statistic-plots branch from 0a00e9a to 8e0323b Compare October 23, 2016 16:01
@phobson phobson changed the title MEP12 improvments for statistics plots [MRG+1]MEP12 improvments for statistics plots Oct 23, 2016
@QuLogic
Copy link
Member

QuLogic commented Oct 24, 2016

@phobson phobson changed the title from MEP12 improvments for statistics plots to [MRG+1]MEP12 improvments for statistics plots 2 hours ago

You can't +1 your own PR 😛

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor tweak.


A couple of other options to the ``hist`` function are demonstrated.
Namely, we use the ``normed`` parameter to normalize the histogram and
a couple of different options to the `cumulative` parameter. Normalizing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed on set of backticks.

Namely, we use the ``normed`` parameter to normalize the histogram and
a couple of different options to the `cumulative` parameter. Normalizing
a histogram means that the bin heights are scaled such that
the total area is 1. Since we're showing a normalized and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel there's one sentence missing between here explaining what the cumulative argument does, or maybe the "Since..." sentence can go after the next paragraph.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuLogic I took another stab at this. Let me know what you think.

@QuLogic QuLogic changed the title [MRG+1]MEP12 improvments for statistics plots [MRG]MEP12 improvments for statistics plots Oct 24, 2016
@NelleV NelleV changed the title [MRG]MEP12 improvments for statistics plots [MRG+1] MEP12 improvments for statistics plots Oct 24, 2016

Since we're showing a normalized and cumulative histogram, these curves
are effectively the cumulative distribution functions (CDFs) of the
samples. In engineering, empirical CDFs where are sometimes called
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra 'where' in this sentence.

@phobson
Copy link
Member Author

phobson commented Oct 25, 2016

Let me know if y'all want me to squash all of this (I'm inclined to do so).

@NelleV
Copy link
Member

NelleV commented Oct 25, 2016

@phobson Whatever you prefer. Let me know, else I am going to merge.

@phobson
Copy link
Member Author

phobson commented Oct 25, 2016

@NelleV I'll squash -- one sec

@phobson phobson force-pushed the MEP12-statistic-plots branch from 7c7d1c7 to 076b98c Compare October 25, 2016 15:38
@NelleV
Copy link
Member

NelleV commented Oct 25, 2016

I'll wait until the checks finish running before merging :)

@NelleV NelleV merged commit 3127815 into matplotlib:master Oct 25, 2016
@phobson
Copy link
Member Author

phobson commented Oct 25, 2016

Cool. I'll take a stab at that soon.

On Sunday, October 23, 2016, Elliott Sales de Andrade <
notifications@github.com> wrote:

@QuLogic commented on this pull request.

One minor tweak.

In examples/statistics/histogram_demo_cumulative.py
#7331 (review)
:

@@ -1,29 +1,72 @@
"""
-Demo of the histogram (hist) function used to plot a cumulative distribution.
+==========================================================
+Demo of using histograms to plot a cumulative distribution
+==========================================================
+
+This shows how to plot a cumulative, normalized histogram as a
+step function in order to visualize the empirical cumulative
+distribution function (CDF) of a sample. We also use the mlab
+module to show the theoretical CDF.
+
+A couple of other options to the hist function are demonstrated.
+Namely, we use the normed parameter to normalize the histogram and
+a couple of different options to the cumulative parameter. Normalizing

Missed on set of backticks.

In examples/statistics/histogram_demo_cumulative.py
#7331 (review)
:

@@ -1,29 +1,72 @@
"""
-Demo of the histogram (hist) function used to plot a cumulative distribution.
+==========================================================
+Demo of using histograms to plot a cumulative distribution
+==========================================================
+
+This shows how to plot a cumulative, normalized histogram as a
+step function in order to visualize the empirical cumulative
+distribution function (CDF) of a sample. We also use the mlab
+module to show the theoretical CDF.
+
+A couple of other options to the hist function are demonstrated.
+Namely, we use the normed parameter to normalize the histogram and
+a couple of different options to the cumulative parameter. Normalizing
+a histogram means that the bin heights are scaled such that
+the total area is 1. Since we're showing a normalized and

I still feel there's one sentence missing between here explaining what the
cumulative argument does, or maybe the "Since..." sentence can go after
the next paragraph.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7331 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABHCo7B8tmzPfT0-pZfu1-fH6khGRbC6ks5q2_6EgaJpZM4Kd5xr
.

Sent from my sorry. Sorry about the typos.

@phobson
Copy link
Member Author

phobson commented Oct 25, 2016

Ha. Sorry. That was a response to the approval.

On Sunday, October 23, 2016, Elliott Sales de Andrade <
notifications@github.com> wrote:

@phobson https://github.com/phobson phobson changed the title from
MEP12 improvments for statistics plots to [MRG+1]MEP12 improvments for
statistics plots 2 hours ago

You can't +1 your own PR 😛


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7331 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABHCo5Z04c0HdOZ2Vo4ru9cmzhjs7PbGks5q2_yogaJpZM4Kd5xr
.

Sent from my sorry. Sorry about the typos.

@NelleV
Copy link
Member

NelleV commented Oct 25, 2016

So… the backport doesn't apply cleanly and I got distracted by something else.
@tacaswell do you mind doing it?

QuLogic pushed a commit that referenced this pull request Oct 25, 2016
MEP12 improvments for statistics plots
@QuLogic QuLogic changed the title [MRG+1] MEP12 improvments for statistics plots MEP12 improvments for statistics plots Oct 25, 2016
@QuLogic
Copy link
Member

QuLogic commented Oct 25, 2016

Backported to v2.x via 58cc83d.

@phobson phobson deleted the MEP12-statistic-plots branch October 25, 2016 23:29
@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0 (style change major release) Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation MEP: MEP12 gallery and examples improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants