Skip to content

Add reference section to all statistics examples #19231

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 2 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,4 @@ per-file-ignores =
examples/userdemo/custom_boxstyle01.py: E402
examples/userdemo/pgf_preamble_sgskip.py: E402
examples/widgets/*.py: E402
examples/statistics/*.py: E402
13 changes: 13 additions & 0 deletions examples/statistics/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,16 @@
fig.suptitle("I never said they'd be pretty")
fig.subplots_adjust(hspace=0.4)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.boxplot
matplotlib.pyplot.boxplot
13 changes: 13 additions & 0 deletions examples/statistics/boxplot_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@
ax.set_ylabel('Observed values')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.boxplot
matplotlib.pyplot.boxplot
14 changes: 14 additions & 0 deletions examples/statistics/boxplot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,17 @@ def fake_bootstrapper(n):
plt.setp(bp['whiskers'], color='k', linestyle='-')
plt.setp(bp['fliers'], markersize=3.0)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.boxplot
matplotlib.pyplot.boxplot
matplotlib.axes.Axes.set
15 changes: 15 additions & 0 deletions examples/statistics/boxplot_vs_violin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@
plt.setp(axs, xticks=[y + 1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'])
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.boxplot
matplotlib.pyplot.boxplot
matplotlib.axes.Axes.violinplot
matplotlib.pyplot.violinplot
13 changes: 13 additions & 0 deletions examples/statistics/bxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,16 @@
fig.suptitle("I never said they'd be pretty")
fig.subplots_adjust(hspace=0.4)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.bxp
matplotlib.cbook.boxplot_stats
13 changes: 13 additions & 0 deletions examples/statistics/confidence_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,16 @@ def get_correlated_dataset(n, dependency, mu, scale):

fig.subplots_adjust(hspace=0.25)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.transforms.Affine2D
Copy link
Member

Choose a reason for hiding this comment

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

I'd add matplotlib.patches.Ellipse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. Although it seems that the backlinking does not work for classes like Ellipse or Affine2D. See https://51381-1385122-gh.circle-artifacts.com/0/doc/build/html/api/transformations.html#matplotlib.transforms.Affine2D where this example is not linked to :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added that the Ellipse in the latest push, though the issue with it rendering will remain I suppose

matplotlib.patches.Ellipse
15 changes: 15 additions & 0 deletions examples/statistics/customized_violin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,18 @@ def set_axis_style(ax, labels):

plt.subplots_adjust(bottom=0.15, wspace=0.05)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.violinplot
matplotlib.pyplot.violinplot
matplotlib.axes.Axes.vlines
matplotlib.pyplot.vlines
13 changes: 13 additions & 0 deletions examples/statistics/errorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@
fig, ax = plt.subplots()
ax.errorbar(x, y, xerr=0.2, yerr=0.4)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.errorbar
matplotlib.pyplot.errorbar
13 changes: 13 additions & 0 deletions examples/statistics/errorbar_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@
ax1.set_title('variable, asymmetric error')
ax1.set_yscale('log')
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.errorbar
matplotlib.pyplot.errorbar
13 changes: 13 additions & 0 deletions examples/statistics/errorbar_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,16 @@
ax.set_xlim((0, 5.5))
ax.set_title('Errorbar upper and lower limits')
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.errorbar
matplotlib.pyplot.errorbar
15 changes: 15 additions & 0 deletions examples/statistics/errorbars_and_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,18 @@ def make_error_boxes(ax, xdata, ydata, xerror, yerror, facecolor='r',
_ = make_error_boxes(ax, x, y, xerr, yerr)

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.errorbar
matplotlib.pyplot.errorbar
matplotlib.axes.Axes.add_collection
matplotlib.collections.PatchCollection
13 changes: 13 additions & 0 deletions examples/statistics/hexbin_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@
cb.set_label('log10(N)')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.hexbin
matplotlib.pyplot.hexbin
15 changes: 15 additions & 0 deletions examples/statistics/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,18 @@
axs[2].hist2d(x, y, bins=(80, 10), norm=colors.LogNorm())

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.hist
matplotlib.pyplot.hist
matplotlib.pyplot.hist2d
matplotlib.ticker.PercentFormatter
13 changes: 13 additions & 0 deletions examples/statistics/histogram_cumulative.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,16 @@
ax.set_ylabel('Likelihood of occurrence')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.hist
matplotlib.pyplot.hist
5 changes: 2 additions & 3 deletions examples/statistics/histogram_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* The *density* parameter, which normalizes bin heights so that the integral of
the histogram is 1. The resulting histogram is an approximation of the
probability density function.
* Setting the face color of the bars.
* Setting the opacity (alpha value).

Selecting different bin counts and sizes can significantly affect the shape
of a histogram. The Astropy docs have a great section_ on how to select these
Expand All @@ -19,7 +17,6 @@
.. _section: http://docs.astropy.org/en/stable/visualization/histogram.html
"""

import matplotlib
import numpy as np
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -58,7 +55,9 @@
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.hist
matplotlib.pyplot.hist
matplotlib.axes.Axes.set_title
matplotlib.axes.Axes.set_xlabel
matplotlib.axes.Axes.set_ylabel
13 changes: 13 additions & 0 deletions examples/statistics/histogram_histtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@

fig.tight_layout()
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.hist
matplotlib.pyplot.hist
13 changes: 13 additions & 0 deletions examples/statistics/histogram_multihist.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,16 @@

fig.tight_layout()
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.hist
matplotlib.pyplot.hist
13 changes: 13 additions & 0 deletions examples/statistics/multiple_histograms_side_by_side.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,16 @@
ax.set_xlabel("Data sets")

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.barh
matplotlib.pyplot.barh
14 changes: 14 additions & 0 deletions examples/statistics/time_series_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,17 @@
toc = time.time()
print(f"{toc-tic:.3f} sec. elapsed")
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.pcolormesh
matplotlib.pyplot.pcolormesh
matplotlib.figure.Figure.colorbar
13 changes: 13 additions & 0 deletions examples/statistics/violinplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,16 @@
fig.suptitle("Violin Plotting Examples")
fig.subplots_adjust(hspace=0.4)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.violinplot
matplotlib.pyplot.violinplot