From ed4d7e7f48514a39c5dac2bc371deb4c2e36d7ac Mon Sep 17 00:00:00 2001 From: aneda Date: Thu, 26 May 2016 20:25:58 -0400 Subject: [PATCH 1/7] correction for doc string and PEP8 --- examples/statistics/boxplot_color_demo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/statistics/boxplot_color_demo.py b/examples/statistics/boxplot_color_demo.py index e16bf3822ea2..9bf1f255861f 100644 --- a/examples/statistics/boxplot_color_demo.py +++ b/examples/statistics/boxplot_color_demo.py @@ -1,4 +1,4 @@ -# Box plots with custom fill colors +"""Box plots with custom fill colors.""" import matplotlib.pyplot as plt import numpy as np @@ -29,12 +29,12 @@ # adding horizontal grid lines for ax in axes: ax.yaxis.grid(True) - ax.set_xticks([y+1 for y in range(len(all_data))], ) + ax.set_xticks([y + 1 for y in range(len(all_data))], ) ax.set_xlabel('xlabel') ax.set_ylabel('ylabel') # add x-tick labels -plt.setp(axes, xticks=[y+1 for y in range(len(all_data))], +plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))], xticklabels=['x1', 'x2', 'x3', 'x4']) plt.show() From a3f236285ce8426a3b42a4dcebafa118104e07ae Mon Sep 17 00:00:00 2001 From: aneda Date: Thu, 26 May 2016 20:35:04 -0400 Subject: [PATCH 2/7] Cleanup : doc string and pep8 --- examples/statistics/boxplot_vs_violin_demo.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/statistics/boxplot_vs_violin_demo.py b/examples/statistics/boxplot_vs_violin_demo.py index acec4f00ceb5..4e6f97de3e52 100644 --- a/examples/statistics/boxplot_vs_violin_demo.py +++ b/examples/statistics/boxplot_vs_violin_demo.py @@ -1,13 +1,15 @@ -# Box plot - violin plot comparison -# -# Note that although violin plots are closely related to Tukey's (1977) box plots, -# they add useful information such as the distribution of the sample data (density trace). -# -# By default, box plots show data points outside 1.5 x the inter-quartile range as outliers -# above or below the whiskers wheras violin plots show the whole range of the data. -# -# Violin plots require matplotlib >= 1.4. +"""Box plot - violin plot comparison. +Note that although violin plots are closely related to Tukey's (1977) box +plots, they add useful information such as the distribution of the sample +data (density trace). + +By default, box plots show data points outside 1.5 x the inter-quartile range +as outliers above or below the whiskers wheras violin plots show the whole +range of the data. + +Violin plots require matplotlib >= 1.4. +""" import matplotlib.pyplot as plt import numpy as np @@ -29,11 +31,11 @@ # adding horizontal grid lines for ax in axes: ax.yaxis.grid(True) - ax.set_xticks([y+1 for y in range(len(all_data))]) + ax.set_xticks([y + 1 for y in range(len(all_data))]) ax.set_xlabel('xlabel') ax.set_ylabel('ylabel') # add x-tick labels -plt.setp(axes, xticks=[y+1 for y in range(len(all_data))], +plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))], xticklabels=['x1', 'x2', 'x3', 'x4']) plt.show() From 9fafd50565397402d14731c57d86026893d68213 Mon Sep 17 00:00:00 2001 From: aneda Date: Thu, 26 May 2016 20:57:13 -0400 Subject: [PATCH 3/7] Added initial description --- examples/showcase/bachelors_degrees_by_gender.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/showcase/bachelors_degrees_by_gender.py b/examples/showcase/bachelors_degrees_by_gender.py index fb5132cc4224..100525901f37 100644 --- a/examples/showcase/bachelors_degrees_by_gender.py +++ b/examples/showcase/bachelors_degrees_by_gender.py @@ -1,3 +1,11 @@ +"""Timeline graph comparison with aligned colored annotation. + +This example shows lines tracking change over time. It features dashed +lines at fixed increments on the Y axis. + +It adds a text label at the right end of every line in the corresponding color. +""" + import matplotlib.pyplot as plt from matplotlib.mlab import csv2rec from matplotlib.cbook import get_sample_data From 39ffd6c0c4b34e25d4a1388cd3ccc956a52ceb92 Mon Sep 17 00:00:00 2001 From: Federico Ariza Date: Mon, 3 Oct 2016 20:39:36 -0400 Subject: [PATCH 4/7] update docstring --- examples/showcase/bachelors_degrees_by_gender.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/showcase/bachelors_degrees_by_gender.py b/examples/showcase/bachelors_degrees_by_gender.py index 100525901f37..d891fbe52153 100644 --- a/examples/showcase/bachelors_degrees_by_gender.py +++ b/examples/showcase/bachelors_degrees_by_gender.py @@ -1,9 +1,9 @@ -"""Timeline graph comparison with aligned colored annotation. - -This example shows lines tracking change over time. It features dashed -lines at fixed increments on the Y axis. +""" +A graph of multiple time series which demonstrates extensive custom +styling of plot frame, tick lines and labels, and line graph properties. -It adds a text label at the right end of every line in the corresponding color. +Also demonstrates the custom placement of text labels along the right edge +as an alternative to a conventional legend. """ import matplotlib.pyplot as plt From 49085a976511caa8fc4feddf27c03b372d801890 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Fri, 21 Oct 2016 09:42:05 -0700 Subject: [PATCH 5/7] DOC: clarify boxplot color demo --- examples/statistics/boxplot_color_demo.py | 31 +++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/examples/statistics/boxplot_color_demo.py b/examples/statistics/boxplot_color_demo.py index 9bf1f255861f..796311a674a5 100644 --- a/examples/statistics/boxplot_color_demo.py +++ b/examples/statistics/boxplot_color_demo.py @@ -1,24 +1,34 @@ -"""Box plots with custom fill colors.""" +"""Box plots with custom fill colors. + +This plot illustrates how to create two types of boxplots +(rectangular and notched), and how to fill them with custom +colors by accessing the properties of the artists of the +boxplots. Additionally, the ``labels`` parameter is used to +provide x-tick labels for each sample. +""" import matplotlib.pyplot as plt import numpy as np # Random test data np.random.seed(123) -all_data = [np.random.normal(0, std, 100) for std in range(1, 4)] +all_data = [np.random.normal(0, std, size=(100, 4)) for std in range(1, 4)] +labels = ['x1', 'x2', 'x3'] fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5)) # rectangular box plot bplot1 = axes[0].boxplot(all_data, - vert=True, # vertical box aligmnent - patch_artist=True) # fill with color + vert=True, # vertical box aligmnent + patch_artist=True, # fill with color + labels=labels) # will be used to label x-ticks # notch shape box plot bplot2 = axes[1].boxplot(all_data, notch=True, # notch shape - vert=True, # vertical box aligmnent - patch_artist=True) # fill with color + vert=True, # vertical box aligmnent + patch_artist=True, # fill with color + labels=labels) # will be used to label x-ticks # fill with colors colors = ['pink', 'lightblue', 'lightgreen'] @@ -29,12 +39,7 @@ # adding horizontal grid lines for ax in axes: ax.yaxis.grid(True) - ax.set_xticks([y + 1 for y in range(len(all_data))], ) - ax.set_xlabel('xlabel') - ax.set_ylabel('ylabel') - -# add x-tick labels -plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))], - xticklabels=['x1', 'x2', 'x3', 'x4']) + ax.set_xlabel('Three Separate Samples') + ax.set_ylabel('Observed values') plt.show() From 8291567bb949e16869192f7c937db5eee5cdc426 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Fri, 21 Oct 2016 10:53:10 -0700 Subject: [PATCH 6/7] fix typos, add axes titles --- examples/statistics/boxplot_color_demo.py | 12 +++++++----- examples/statistics/boxplot_vs_violin_demo.py | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/statistics/boxplot_color_demo.py b/examples/statistics/boxplot_color_demo.py index 796311a674a5..3cc45708e705 100644 --- a/examples/statistics/boxplot_color_demo.py +++ b/examples/statistics/boxplot_color_demo.py @@ -1,9 +1,9 @@ """Box plots with custom fill colors. -This plot illustrates how to create two types of boxplots +This plot illustrates how to create two types of box plots (rectangular and notched), and how to fill them with custom colors by accessing the properties of the artists of the -boxplots. Additionally, the ``labels`` parameter is used to +box plots. Additionally, the ``labels`` parameter is used to provide x-tick labels for each sample. """ @@ -19,16 +19,18 @@ # rectangular box plot bplot1 = axes[0].boxplot(all_data, - vert=True, # vertical box aligmnent + vert=True, # vertical box alignment patch_artist=True, # fill with color labels=labels) # will be used to label x-ticks +axes[0].set_title('Rectangular box plot') # notch shape box plot bplot2 = axes[1].boxplot(all_data, notch=True, # notch shape - vert=True, # vertical box aligmnent + vert=True, # vertical box alignment patch_artist=True, # fill with color labels=labels) # will be used to label x-ticks +axes[1].set_title('Notched box plot') # fill with colors colors = ['pink', 'lightblue', 'lightgreen'] @@ -39,7 +41,7 @@ # adding horizontal grid lines for ax in axes: ax.yaxis.grid(True) - ax.set_xlabel('Three Separate Samples') + ax.set_xlabel('Three separate samples') ax.set_ylabel('Observed values') plt.show() diff --git a/examples/statistics/boxplot_vs_violin_demo.py b/examples/statistics/boxplot_vs_violin_demo.py index 4e6f97de3e52..c4150e5db7bb 100644 --- a/examples/statistics/boxplot_vs_violin_demo.py +++ b/examples/statistics/boxplot_vs_violin_demo.py @@ -5,7 +5,7 @@ data (density trace). By default, box plots show data points outside 1.5 x the inter-quartile range -as outliers above or below the whiskers wheras violin plots show the whole +as outliers above or below the whiskers whereas violin plots show the whole range of the data. Violin plots require matplotlib >= 1.4. @@ -22,18 +22,18 @@ axes[0].violinplot(all_data, showmeans=False, showmedians=True) -axes[0].set_title('violin plot') +axes[0].set_title('Violin plot') # plot box plot axes[1].boxplot(all_data) -axes[1].set_title('box plot') +axes[1].set_title('Box plot') # adding horizontal grid lines for ax in axes: ax.yaxis.grid(True) ax.set_xticks([y + 1 for y in range(len(all_data))]) - ax.set_xlabel('xlabel') - ax.set_ylabel('ylabel') + ax.set_xlabel('Four separate samples') + ax.set_ylabel('Observed values') # add x-tick labels plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))], From 11d9ec349057f4ad07267cef03aaf23e69d56959 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Fri, 21 Oct 2016 13:00:07 -0700 Subject: [PATCH 7/7] fix sample size in boxplot demo --- examples/statistics/boxplot_color_demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/statistics/boxplot_color_demo.py b/examples/statistics/boxplot_color_demo.py index 3cc45708e705..474f427d76eb 100644 --- a/examples/statistics/boxplot_color_demo.py +++ b/examples/statistics/boxplot_color_demo.py @@ -12,7 +12,7 @@ # Random test data np.random.seed(123) -all_data = [np.random.normal(0, std, size=(100, 4)) for std in range(1, 4)] +all_data = [np.random.normal(0, std, size=100) for std in range(1, 4)] labels = ['x1', 'x2', 'x3'] fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5))