From a49416a8c3fac0d90ee966f0c59ff9389dfaa347 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 4 Jan 2021 00:39:49 -0500 Subject: [PATCH 1/2] add references to statistics examples --- .flake8 | 1 + examples/statistics/boxplot.py | 13 +++++++++++++ examples/statistics/boxplot_color.py | 13 +++++++++++++ examples/statistics/boxplot_demo.py | 14 ++++++++++++++ examples/statistics/boxplot_vs_violin.py | 15 +++++++++++++++ examples/statistics/bxp.py | 13 +++++++++++++ examples/statistics/confidence_ellipse.py | 13 +++++++++++++ examples/statistics/customized_violin.py | 15 +++++++++++++++ examples/statistics/errorbar.py | 13 +++++++++++++ examples/statistics/errorbar_features.py | 13 +++++++++++++ examples/statistics/errorbar_limits.py | 13 +++++++++++++ examples/statistics/errorbars_and_boxes.py | 15 +++++++++++++++ examples/statistics/hexbin_demo.py | 13 +++++++++++++ examples/statistics/hist.py | 15 +++++++++++++++ examples/statistics/histogram_cumulative.py | 13 +++++++++++++ examples/statistics/histogram_features.py | 3 ++- examples/statistics/histogram_histtypes.py | 13 +++++++++++++ examples/statistics/histogram_multihist.py | 13 +++++++++++++ .../multiple_histograms_side_by_side.py | 13 +++++++++++++ examples/statistics/time_series_histogram.py | 14 ++++++++++++++ examples/statistics/violinplot.py | 13 +++++++++++++ 21 files changed, 260 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 535bd02e96f3..f9f41e9a9fab 100644 --- a/.flake8 +++ b/.flake8 @@ -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 diff --git a/examples/statistics/boxplot.py b/examples/statistics/boxplot.py index 8947cbd34d4f..3171e7575ec4 100644 --- a/examples/statistics/boxplot.py +++ b/examples/statistics/boxplot.py @@ -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 diff --git a/examples/statistics/boxplot_color.py b/examples/statistics/boxplot_color.py index ff7b5ce5e906..c1c00c607590 100644 --- a/examples/statistics/boxplot_color.py +++ b/examples/statistics/boxplot_color.py @@ -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 diff --git a/examples/statistics/boxplot_demo.py b/examples/statistics/boxplot_demo.py index 84daaef90cb4..d5eb08f9cf1d 100644 --- a/examples/statistics/boxplot_demo.py +++ b/examples/statistics/boxplot_demo.py @@ -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 diff --git a/examples/statistics/boxplot_vs_violin.py b/examples/statistics/boxplot_vs_violin.py index 37fe844c0617..5107a45f0dcb 100644 --- a/examples/statistics/boxplot_vs_violin.py +++ b/examples/statistics/boxplot_vs_violin.py @@ -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 diff --git a/examples/statistics/bxp.py b/examples/statistics/bxp.py index 792431bd8b22..b5e22be0e0d2 100644 --- a/examples/statistics/bxp.py +++ b/examples/statistics/bxp.py @@ -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 diff --git a/examples/statistics/confidence_ellipse.py b/examples/statistics/confidence_ellipse.py index e663f184dcf1..06d5523f522e 100644 --- a/examples/statistics/confidence_ellipse.py +++ b/examples/statistics/confidence_ellipse.py @@ -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 +matplotlib.patches.Ellipse diff --git a/examples/statistics/customized_violin.py b/examples/statistics/customized_violin.py index 91d56171d134..61c52c2d9a87 100644 --- a/examples/statistics/customized_violin.py +++ b/examples/statistics/customized_violin.py @@ -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 diff --git a/examples/statistics/errorbar.py b/examples/statistics/errorbar.py index 8c2de1dfc5a9..c6c0a8d61704 100644 --- a/examples/statistics/errorbar.py +++ b/examples/statistics/errorbar.py @@ -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 diff --git a/examples/statistics/errorbar_features.py b/examples/statistics/errorbar_features.py index b0d7c9fc6a41..253d0008dcae 100644 --- a/examples/statistics/errorbar_features.py +++ b/examples/statistics/errorbar_features.py @@ -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 diff --git a/examples/statistics/errorbar_limits.py b/examples/statistics/errorbar_limits.py index 4044d50cdaf8..914fef4cdbbc 100644 --- a/examples/statistics/errorbar_limits.py +++ b/examples/statistics/errorbar_limits.py @@ -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 diff --git a/examples/statistics/errorbars_and_boxes.py b/examples/statistics/errorbars_and_boxes.py index ceca7ee51889..7c647aedaadd 100644 --- a/examples/statistics/errorbars_and_boxes.py +++ b/examples/statistics/errorbars_and_boxes.py @@ -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 diff --git a/examples/statistics/hexbin_demo.py b/examples/statistics/hexbin_demo.py index 5ebc5d1c4b6d..3d8e85cf8f00 100644 --- a/examples/statistics/hexbin_demo.py +++ b/examples/statistics/hexbin_demo.py @@ -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 diff --git a/examples/statistics/hist.py b/examples/statistics/hist.py index 91069e662452..5fd409911c89 100644 --- a/examples/statistics/hist.py +++ b/examples/statistics/hist.py @@ -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 diff --git a/examples/statistics/histogram_cumulative.py b/examples/statistics/histogram_cumulative.py index b027cb3066da..f5da13aa49fe 100644 --- a/examples/statistics/histogram_cumulative.py +++ b/examples/statistics/histogram_cumulative.py @@ -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 diff --git a/examples/statistics/histogram_features.py b/examples/statistics/histogram_features.py index 6633462586d3..221bc4f3fc0f 100644 --- a/examples/statistics/histogram_features.py +++ b/examples/statistics/histogram_features.py @@ -19,7 +19,6 @@ .. _section: http://docs.astropy.org/en/stable/visualization/histogram.html """ -import matplotlib import numpy as np import matplotlib.pyplot as plt @@ -58,7 +57,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 diff --git a/examples/statistics/histogram_histtypes.py b/examples/statistics/histogram_histtypes.py index 2ec4fc9e1836..c22c96329be0 100644 --- a/examples/statistics/histogram_histtypes.py +++ b/examples/statistics/histogram_histtypes.py @@ -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 diff --git a/examples/statistics/histogram_multihist.py b/examples/statistics/histogram_multihist.py index a75396890020..65c7b11f337e 100644 --- a/examples/statistics/histogram_multihist.py +++ b/examples/statistics/histogram_multihist.py @@ -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 diff --git a/examples/statistics/multiple_histograms_side_by_side.py b/examples/statistics/multiple_histograms_side_by_side.py index 2c4ff176ce4b..eef1a22602e4 100644 --- a/examples/statistics/multiple_histograms_side_by_side.py +++ b/examples/statistics/multiple_histograms_side_by_side.py @@ -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 diff --git a/examples/statistics/time_series_histogram.py b/examples/statistics/time_series_histogram.py index 3c9094481c26..c0e95f93bfc6 100644 --- a/examples/statistics/time_series_histogram.py +++ b/examples/statistics/time_series_histogram.py @@ -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 diff --git a/examples/statistics/violinplot.py b/examples/statistics/violinplot.py index 1e1911d262cf..a2ff6aed61ba 100644 --- a/examples/statistics/violinplot.py +++ b/examples/statistics/violinplot.py @@ -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 From 448100ae0f21d76730ee49116c6973989196a094 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Mon, 4 Jan 2021 14:12:47 -0500 Subject: [PATCH 2/2] remove incorrect statement from example description the example does not demonstrate these things --- examples/statistics/histogram_features.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/statistics/histogram_features.py b/examples/statistics/histogram_features.py index 221bc4f3fc0f..27c4940822d8 100644 --- a/examples/statistics/histogram_features.py +++ b/examples/statistics/histogram_features.py @@ -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