From 8bec4122d0f6357c0b829aa8febd4f374f674699 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 28 Sep 2013 23:23:29 -0500 Subject: [PATCH 01/21] Remove she-bang line. --- examples/pylab_examples/histogram_demo_extended.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/pylab_examples/histogram_demo_extended.py b/examples/pylab_examples/histogram_demo_extended.py index bd262007edde..1736cbca3e94 100644 --- a/examples/pylab_examples/histogram_demo_extended.py +++ b/examples/pylab_examples/histogram_demo_extended.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python import numpy as np import pylab as P From c25ef1e02b3a0ecb279492409dac0de9b3d2c0e2 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 28 Sep 2013 23:28:13 -0500 Subject: [PATCH 02/21] Use consistent imports --- .../pylab_examples/histogram_demo_extended.py | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_extended.py b/examples/pylab_examples/histogram_demo_extended.py index 1736cbca3e94..0cf44d4ec853 100644 --- a/examples/pylab_examples/histogram_demo_extended.py +++ b/examples/pylab_examples/histogram_demo_extended.py @@ -1,5 +1,6 @@ import numpy as np -import pylab as P +import matplotlib.pyplot as plt +from matplotlib.mlab import normpdf # # The hist() function now has a lot more options @@ -9,56 +10,56 @@ # first create a single histogram # mu, sigma = 200, 25 -x = mu + sigma*P.randn(10000) +x = mu + sigma*np.random.randn(10000) # the histogram of the data with histtype='step' -n, bins, patches = P.hist(x, 50, normed=1, histtype='stepfilled') -P.setp(patches, 'facecolor', 'g', 'alpha', 0.75) +n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled') +plt.setp(patches, 'facecolor', 'g', 'alpha', 0.75) # add a line showing the expected distribution -y = P.normpdf( bins, mu, sigma) -l = P.plot(bins, y, 'k--', linewidth=1.5) +y = normpdf( bins, mu, sigma) +l = plt.plot(bins, y, 'k--', linewidth=1.5) # # create a histogram by providing the bin edges (unequally spaced) # -P.figure() +plt.figure() bins = [100,125,150,160,170,180,190,200,210,220,230,240,250,275,300] # the histogram of the data with histtype='step' -n, bins, patches = P.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) +n, bins, patches = plt.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) # # now we create a cumulative histogram of the data # -P.figure() +plt.figure() -n, bins, patches = P.hist(x, 50, normed=1, histtype='step', cumulative=True) +n, bins, patches = plt.hist(x, 50, normed=1, histtype='step', cumulative=True) # add a line showing the expected distribution -y = P.normpdf( bins, mu, sigma).cumsum() +y = normpdf( bins, mu, sigma).cumsum() y /= y[-1] -l = P.plot(bins, y, 'k--', linewidth=1.5) +l = plt.plot(bins, y, 'k--', linewidth=1.5) # create a second data-set with a smaller standard deviation sigma2 = 15. -x = mu + sigma2*P.randn(10000) +x = mu + sigma2*np.random.randn(10000) -n, bins, patches = P.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) +n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) # add a line showing the expected distribution -y = P.normpdf( bins, mu, sigma2).cumsum() +y = normpdf( bins, mu, sigma2).cumsum() y /= y[-1] -l = P.plot(bins, y, 'r--', linewidth=1.5) +l = plt.plot(bins, y, 'r--', linewidth=1.5) # finally overplot a reverted cumulative histogram -n, bins, patches = P.hist(x, bins=bins, normed=1, +n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) -P.grid(True) -P.ylim(0, 1.05) +plt.grid(True) +plt.ylim(0, 1.05) # @@ -66,41 +67,41 @@ # Note the new color kwarg, used to override the default, which # uses the line color cycle. # -P.figure() +plt.figure() # create a new data-set -x = mu + sigma*P.randn(1000,3) +x = mu + sigma*np.random.randn(1000,3) -n, bins, patches = P.hist(x, 10, normed=1, histtype='bar', +n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', color=['crimson', 'burlywood', 'chartreuse'], label=['Crimson', 'Burlywood', 'Chartreuse']) -P.legend() +plt.legend() # # ... or we can stack the data # -P.figure() +plt.figure() -n, bins, patches = P.hist(x, 10, normed=1, histtype='bar', stacked=True) +n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True) -P.show() +plt.show() # # we can also stack using the step histtype # -P.figure() +plt.figure() -n, bins, patches = P.hist(x, 10, histtype='step', stacked=True, fill=True) +n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True) -P.show() +plt.show() # # finally: make a multiple-histogram of data-sets with different length # -x0 = mu + sigma*P.randn(10000) -x1 = mu + sigma*P.randn(7000) -x2 = mu + sigma*P.randn(3000) +x0 = mu + sigma*np.random.randn(10000) +x1 = mu + sigma*np.random.randn(7000) +x2 = mu + sigma*np.random.randn(3000) # and exercise the weights option by arbitrarily giving the first half # of each series only half the weight of the others: @@ -114,8 +115,8 @@ -P.figure() +plt.figure() -n, bins, patches = P.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') +n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') -P.show() +plt.show() From 7a59f9f2f745132e15f818e67962f3e3753227ce Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 28 Sep 2013 23:36:51 -0500 Subject: [PATCH 03/21] Remove unnecessary code comments. --- .../pylab_examples/histogram_demo_extended.py | 47 ++++--------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_extended.py b/examples/pylab_examples/histogram_demo_extended.py index 0cf44d4ec853..24b8cd9cb322 100644 --- a/examples/pylab_examples/histogram_demo_extended.py +++ b/examples/pylab_examples/histogram_demo_extended.py @@ -2,58 +2,45 @@ import matplotlib.pyplot as plt from matplotlib.mlab import normpdf -# -# The hist() function now has a lot more options -# -# -# first create a single histogram -# mu, sigma = 200, 25 x = mu + sigma*np.random.randn(10000) -# the histogram of the data with histtype='step' n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled') plt.setp(patches, 'facecolor', 'g', 'alpha', 0.75) -# add a line showing the expected distribution +# Add a line showing the expected distribution. y = normpdf( bins, mu, sigma) l = plt.plot(bins, y, 'k--', linewidth=1.5) -# -# create a histogram by providing the bin edges (unequally spaced) -# plt.figure() +# Create a histogram by providing the bin edges (unequally spaced). bins = [100,125,150,160,170,180,190,200,210,220,230,240,250,275,300] -# the histogram of the data with histtype='step' n, bins, patches = plt.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) -# -# now we create a cumulative histogram of the data -# plt.figure() n, bins, patches = plt.hist(x, 50, normed=1, histtype='step', cumulative=True) -# add a line showing the expected distribution +# Add a line showing the expected distribution. y = normpdf( bins, mu, sigma).cumsum() y /= y[-1] l = plt.plot(bins, y, 'k--', linewidth=1.5) -# create a second data-set with a smaller standard deviation +# Create a second data-set with a smaller standard deviation. sigma2 = 15. x = mu + sigma2*np.random.randn(10000) n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) -# add a line showing the expected distribution +# Add a line showing the expected distribution. y = normpdf( bins, mu, sigma2).cumsum() y /= y[-1] l = plt.plot(bins, y, 'r--', linewidth=1.5) -# finally overplot a reverted cumulative histogram +# Overlay a reverted cumulative histogram. n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) @@ -62,14 +49,8 @@ plt.ylim(0, 1.05) -# -# histogram has the ability to plot multiple data in parallel ... -# Note the new color kwarg, used to override the default, which -# uses the line color cycle. -# plt.figure() -# create a new data-set x = mu + sigma*np.random.randn(1000,3) n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', @@ -77,35 +58,24 @@ label=['Crimson', 'Burlywood', 'Chartreuse']) plt.legend() -# -# ... or we can stack the data -# + plt.figure() n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True) plt.show() -# -# we can also stack using the step histtype -# - plt.figure() n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True) plt.show() -# -# finally: make a multiple-histogram of data-sets with different length -# +# Make a multiple-histogram of data-sets with different length. x0 = mu + sigma*np.random.randn(10000) x1 = mu + sigma*np.random.randn(7000) x2 = mu + sigma*np.random.randn(3000) -# and exercise the weights option by arbitrarily giving the first half -# of each series only half the weight of the others: - w0 = np.ones_like(x0) w0[:len(x0)/2] = 0.5 w1 = np.ones_like(x1) @@ -114,7 +84,6 @@ w2[:len(x2)/2] = 0.5 - plt.figure() n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') From 83dd0ea33d15e8011fb3506fd328771707171adb Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 28 Sep 2013 23:37:34 -0500 Subject: [PATCH 04/21] Remove unnecessary calls to `show` --- examples/pylab_examples/histogram_demo_extended.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_extended.py b/examples/pylab_examples/histogram_demo_extended.py index 24b8cd9cb322..851c7938e7e5 100644 --- a/examples/pylab_examples/histogram_demo_extended.py +++ b/examples/pylab_examples/histogram_demo_extended.py @@ -60,17 +60,11 @@ plt.figure() - n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True) -plt.show() - plt.figure() - n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True) -plt.show() - # Make a multiple-histogram of data-sets with different length. x0 = mu + sigma*np.random.randn(10000) x1 = mu + sigma*np.random.randn(7000) From ece3c57d14652710f22615a5f26a85873969d710 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 28 Sep 2013 23:38:33 -0500 Subject: [PATCH 05/21] Rmove unused variable --- examples/pylab_examples/histogram_demo_extended.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_extended.py b/examples/pylab_examples/histogram_demo_extended.py index 851c7938e7e5..cfc3f29294af 100644 --- a/examples/pylab_examples/histogram_demo_extended.py +++ b/examples/pylab_examples/histogram_demo_extended.py @@ -11,7 +11,7 @@ # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma) -l = plt.plot(bins, y, 'k--', linewidth=1.5) +plt.plot(bins, y, 'k--', linewidth=1.5) plt.figure() @@ -27,7 +27,7 @@ # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma).cumsum() y /= y[-1] -l = plt.plot(bins, y, 'k--', linewidth=1.5) +plt.plot(bins, y, 'k--', linewidth=1.5) # Create a second data-set with a smaller standard deviation. sigma2 = 15. @@ -38,7 +38,7 @@ # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma2).cumsum() y /= y[-1] -l = plt.plot(bins, y, 'r--', linewidth=1.5) +plt.plot(bins, y, 'r--', linewidth=1.5) # Overlay a reverted cumulative histogram. n, bins, patches = plt.hist(x, bins=bins, normed=1, From 509967518ce5ce5ba31edf12486ffaa344e748f2 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 07:14:58 -0500 Subject: [PATCH 06/21] Split up hist examples into two sections. The original example was trying to do too much in one place. --- ...xtended.py => histogram_demo_histtypes.py} | 35 +---------------- .../histogram_demo_multihist.py | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 34 deletions(-) rename examples/pylab_examples/{histogram_demo_extended.py => histogram_demo_histtypes.py} (61%) create mode 100644 examples/pylab_examples/histogram_demo_multihist.py diff --git a/examples/pylab_examples/histogram_demo_extended.py b/examples/pylab_examples/histogram_demo_histtypes.py similarity index 61% rename from examples/pylab_examples/histogram_demo_extended.py rename to examples/pylab_examples/histogram_demo_histtypes.py index cfc3f29294af..54b453622adc 100644 --- a/examples/pylab_examples/histogram_demo_extended.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -1,3 +1,4 @@ + import numpy as np import matplotlib.pyplot as plt from matplotlib.mlab import normpdf @@ -48,38 +49,4 @@ plt.grid(True) plt.ylim(0, 1.05) - -plt.figure() - -x = mu + sigma*np.random.randn(1000,3) - -n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', - color=['crimson', 'burlywood', 'chartreuse'], - label=['Crimson', 'Burlywood', 'Chartreuse']) -plt.legend() - - -plt.figure() -n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True) - -plt.figure() -n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True) - -# Make a multiple-histogram of data-sets with different length. -x0 = mu + sigma*np.random.randn(10000) -x1 = mu + sigma*np.random.randn(7000) -x2 = mu + sigma*np.random.randn(3000) - -w0 = np.ones_like(x0) -w0[:len(x0)/2] = 0.5 -w1 = np.ones_like(x1) -w1[:len(x1)/2] = 0.5 -w2 = np.ones_like(x2) -w2[:len(x2)/2] = 0.5 - - -plt.figure() - -n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') - plt.show() diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py new file mode 100644 index 000000000000..2b9cbc047bcd --- /dev/null +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -0,0 +1,39 @@ +import numpy as np +import matplotlib.pyplot as plt + + +mu, sigma = 200, 25 +plt.figure() + +x = mu + sigma*np.random.randn(1000,3) + +n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', + color=['crimson', 'burlywood', 'chartreuse'], + label=['Crimson', 'Burlywood', 'Chartreuse']) +plt.legend() + + +plt.figure() +n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True) + +plt.figure() +n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True) + +# Make a multiple-histogram of data-sets with different length. +x0 = mu + sigma*np.random.randn(10000) +x1 = mu + sigma*np.random.randn(7000) +x2 = mu + sigma*np.random.randn(3000) + +w0 = np.ones_like(x0) +w0[:len(x0)/2] = 0.5 +w1 = np.ones_like(x1) +w1[:len(x1)/2] = 0.5 +w2 = np.ones_like(x2) +w2[:len(x2)/2] = 0.5 + + +plt.figure() + +n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') + +plt.show() From 768500d4139d672f5497866000849242c890d38f Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 07:18:28 -0500 Subject: [PATCH 07/21] Remove use of `setp` in favor of keyword args. --- examples/pylab_examples/histogram_demo_histtypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 54b453622adc..f65b88cf07fd 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -7,8 +7,8 @@ mu, sigma = 200, 25 x = mu + sigma*np.random.randn(10000) -n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled') -plt.setp(patches, 'facecolor', 'g', 'alpha', 0.75) +n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled', + facecolor='g', alpha=0.75) # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma) From 44a577b553102444ffe8f92306a90eefb7134c9a Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 07:35:39 -0500 Subject: [PATCH 08/21] Replace multiple figures with subplots --- .../histogram_demo_histtypes.py | 28 +++++++++---------- .../histogram_demo_multihist.py | 21 ++++++-------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index f65b88cf07fd..1eb24ff3fba6 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -7,46 +7,44 @@ mu, sigma = 200, 25 x = mu + sigma*np.random.randn(10000) -n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled', +fig, (ax0, ax1, ax2) = plt.subplots(ncols=3, figsize=(8, 3)) + +n, bins, patches = ax0.hist(x, 50, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75) # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma) -plt.plot(bins, y, 'k--', linewidth=1.5) - - -plt.figure() +ax0.plot(bins, y, 'k--', linewidth=1.5) # Create a histogram by providing the bin edges (unequally spaced). bins = [100,125,150,160,170,180,190,200,210,220,230,240,250,275,300] -n, bins, patches = plt.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) - -plt.figure() +n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) -n, bins, patches = plt.hist(x, 50, normed=1, histtype='step', cumulative=True) +n, bins, patches = ax2.hist(x, 50, normed=1, histtype='step', cumulative=True) # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma).cumsum() y /= y[-1] -plt.plot(bins, y, 'k--', linewidth=1.5) +ax2.plot(bins, y, 'k--', linewidth=1.5) # Create a second data-set with a smaller standard deviation. sigma2 = 15. x = mu + sigma2*np.random.randn(10000) -n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) +n, bins, patches = ax2.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) # Add a line showing the expected distribution. y = normpdf( bins, mu, sigma2).cumsum() y /= y[-1] -plt.plot(bins, y, 'r--', linewidth=1.5) +ax2.plot(bins, y, 'r--', linewidth=1.5) # Overlay a reverted cumulative histogram. -n, bins, patches = plt.hist(x, bins=bins, normed=1, +n, bins, patches = ax2.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) -plt.grid(True) -plt.ylim(0, 1.05) +ax2.grid(True) +ax2.set_ylim(0, 1.05) +plt.tight_layout() plt.show() diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index 2b9cbc047bcd..869f8027b435 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -2,22 +2,21 @@ import matplotlib.pyplot as plt -mu, sigma = 200, 25 -plt.figure() +fig, axes = plt.subplots(nrows=2, ncols=2) +ax0, ax1, ax2, ax3 = axes.flat +mu, sigma = 200, 25 x = mu + sigma*np.random.randn(1000,3) -n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', +n, bins, patches = ax0.hist(x, 10, normed=1, histtype='bar', color=['crimson', 'burlywood', 'chartreuse'], label=['Crimson', 'Burlywood', 'Chartreuse']) -plt.legend() +ax0.legend(prop={'size': 10}) -plt.figure() -n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True) +n, bins, patches = ax1.hist(x, 10, normed=1, histtype='bar', stacked=True) -plt.figure() -n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True) +n, bins, patches = ax2.hist(x, 10, histtype='step', stacked=True, fill=True) # Make a multiple-histogram of data-sets with different length. x0 = mu + sigma*np.random.randn(10000) @@ -31,9 +30,7 @@ w2 = np.ones_like(x2) w2[:len(x2)/2] = 0.5 +n, bins, patches = ax3.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') -plt.figure() - -n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') - +plt.tight_layout() plt.show() From c80897d5232598a1aa72fe1174111b2802a31eb3 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 07:40:03 -0500 Subject: [PATCH 09/21] Change bin edges to make the example clearer. --- examples/pylab_examples/histogram_demo_histtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 1eb24ff3fba6..54b996251756 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -17,7 +17,7 @@ ax0.plot(bins, y, 'k--', linewidth=1.5) # Create a histogram by providing the bin edges (unequally spaced). -bins = [100,125,150,160,170,180,190,200,210,220,230,240,250,275,300] +bins = [100,150,180,195,205,220,250,300] n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) n, bins, patches = ax2.hist(x, 50, normed=1, histtype='step', cumulative=True) From bd2b13c54bf4aa2058781b9a805d68f2feab5ba5 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 07:48:31 -0500 Subject: [PATCH 10/21] Add titles to clarify intent --- examples/pylab_examples/histogram_demo_histtypes.py | 5 ++++- examples/pylab_examples/histogram_demo_multihist.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 54b996251756..8d7f472be029 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -16,9 +16,12 @@ y = normpdf( bins, mu, sigma) ax0.plot(bins, y, 'k--', linewidth=1.5) +ax0.set_title('stepfilled') + # Create a histogram by providing the bin edges (unequally spaced). bins = [100,150,180,195,205,220,250,300] n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) +ax1.set_title('unequal bins') n, bins, patches = ax2.hist(x, 50, normed=1, histtype='step', cumulative=True) @@ -42,9 +45,9 @@ n, bins, patches = ax2.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) - ax2.grid(True) ax2.set_ylim(0, 1.05) +ax2.set_title('cumulative step') plt.tight_layout() plt.show() diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index 869f8027b435..492b2a8b2809 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -12,11 +12,14 @@ color=['crimson', 'burlywood', 'chartreuse'], label=['Crimson', 'Burlywood', 'Chartreuse']) ax0.legend(prop={'size': 10}) +ax0.set_title('bar') n, bins, patches = ax1.hist(x, 10, normed=1, histtype='bar', stacked=True) +ax1.set_title('stacked bar') n, bins, patches = ax2.hist(x, 10, histtype='step', stacked=True, fill=True) +ax2.set_title('stepfilled') # Make a multiple-histogram of data-sets with different length. x0 = mu + sigma*np.random.randn(10000) @@ -31,6 +34,7 @@ w2[:len(x2)/2] = 0.5 n, bins, patches = ax3.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') +ax3.set_title('different sample sizes') plt.tight_layout() plt.show() From 24aab9706300e471292512fe071fd52542a550f7 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 07:59:01 -0500 Subject: [PATCH 11/21] Simplify example --- .../histogram_demo_multihist.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index 492b2a8b2809..60cfca9bff4c 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -8,9 +8,9 @@ mu, sigma = 200, 25 x = mu + sigma*np.random.randn(1000,3) +colors = ['crimson', 'burlywood', 'chartreuse'] n, bins, patches = ax0.hist(x, 10, normed=1, histtype='bar', - color=['crimson', 'burlywood', 'chartreuse'], - label=['Crimson', 'Burlywood', 'Chartreuse']) + color=colors, label=colors) ax0.legend(prop={'size': 10}) ax0.set_title('bar') @@ -22,18 +22,9 @@ ax2.set_title('stepfilled') # Make a multiple-histogram of data-sets with different length. -x0 = mu + sigma*np.random.randn(10000) -x1 = mu + sigma*np.random.randn(7000) -x2 = mu + sigma*np.random.randn(3000) - -w0 = np.ones_like(x0) -w0[:len(x0)/2] = 0.5 -w1 = np.ones_like(x1) -w1[:len(x1)/2] = 0.5 -w2 = np.ones_like(x2) -w2[:len(x2)/2] = 0.5 - -n, bins, patches = ax3.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') +x_multi = [mu + sigma*np.random.randn(n) for n in [10000, 5000, 2000]] + +n, bins, patches = ax3.hist(x_multi, 10, histtype='bar') ax3.set_title('different sample sizes') plt.tight_layout() From fc2ab07cc586abba4c024d8c0d841c4357a3936f Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 08:04:17 -0500 Subject: [PATCH 12/21] Split demo that tried to do too much --- .../histogram_demo_cumulative.py | 33 +++++++++++++++++++ .../histogram_demo_histtypes.py | 33 ++----------------- 2 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 examples/pylab_examples/histogram_demo_cumulative.py diff --git a/examples/pylab_examples/histogram_demo_cumulative.py b/examples/pylab_examples/histogram_demo_cumulative.py new file mode 100644 index 000000000000..e2d2ef7a9768 --- /dev/null +++ b/examples/pylab_examples/histogram_demo_cumulative.py @@ -0,0 +1,33 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib import mlab + +mu, sigma = 200, 25 +x = mu + sigma*np.random.randn(10000) +n, bins, patches = plt.hist(x, 50, normed=1, histtype='step', cumulative=True) + +# Add a line showing the expected distribution. +y = mlab.normpdf( bins, mu, sigma).cumsum() +y /= y[-1] +plt.plot(bins, y, 'k--', linewidth=1.5) + +# Create a second data-set with a smaller standard deviation. +sigma2 = 15. +x = mu + sigma2*np.random.randn(10000) + +n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) + +# Add a line showing the expected distribution. +y = mlab.normpdf( bins, mu, sigma2).cumsum() +y /= y[-1] +plt.plot(bins, y, 'r--', linewidth=1.5) + +# Overlay a reverted cumulative histogram. +n, bins, patches = plt.hist(x, bins=bins, normed=1, + histtype='step', cumulative=-1) + +plt.grid(True) +plt.ylim(0, 1.05) +plt.title('cumulative step') + +plt.show() diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 8d7f472be029..170c1325eb3e 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -1,19 +1,18 @@ - import numpy as np import matplotlib.pyplot as plt -from matplotlib.mlab import normpdf +from matplotlib import mlab mu, sigma = 200, 25 x = mu + sigma*np.random.randn(10000) -fig, (ax0, ax1, ax2) = plt.subplots(ncols=3, figsize=(8, 3)) +fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4)) n, bins, patches = ax0.hist(x, 50, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75) # Add a line showing the expected distribution. -y = normpdf( bins, mu, sigma) +y = mlab.normpdf( bins, mu, sigma) ax0.plot(bins, y, 'k--', linewidth=1.5) ax0.set_title('stepfilled') @@ -23,31 +22,5 @@ n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) ax1.set_title('unequal bins') -n, bins, patches = ax2.hist(x, 50, normed=1, histtype='step', cumulative=True) - -# Add a line showing the expected distribution. -y = normpdf( bins, mu, sigma).cumsum() -y /= y[-1] -ax2.plot(bins, y, 'k--', linewidth=1.5) - -# Create a second data-set with a smaller standard deviation. -sigma2 = 15. -x = mu + sigma2*np.random.randn(10000) - -n, bins, patches = ax2.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) - -# Add a line showing the expected distribution. -y = normpdf( bins, mu, sigma2).cumsum() -y /= y[-1] -ax2.plot(bins, y, 'r--', linewidth=1.5) - -# Overlay a reverted cumulative histogram. -n, bins, patches = ax2.hist(x, bins=bins, normed=1, - histtype='step', cumulative=-1) - -ax2.grid(True) -ax2.set_ylim(0, 1.05) -ax2.set_title('cumulative step') - plt.tight_layout() plt.show() From e57b5fc31fbad83ed9c43c77ef15368efdcb9ec1 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 08:06:44 -0500 Subject: [PATCH 13/21] Remove unnecessary second histogram --- examples/pylab_examples/histogram_demo_cumulative.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_cumulative.py b/examples/pylab_examples/histogram_demo_cumulative.py index e2d2ef7a9768..f976664af63f 100644 --- a/examples/pylab_examples/histogram_demo_cumulative.py +++ b/examples/pylab_examples/histogram_demo_cumulative.py @@ -11,17 +11,6 @@ y /= y[-1] plt.plot(bins, y, 'k--', linewidth=1.5) -# Create a second data-set with a smaller standard deviation. -sigma2 = 15. -x = mu + sigma2*np.random.randn(10000) - -n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=True) - -# Add a line showing the expected distribution. -y = mlab.normpdf( bins, mu, sigma2).cumsum() -y /= y[-1] -plt.plot(bins, y, 'r--', linewidth=1.5) - # Overlay a reverted cumulative histogram. n, bins, patches = plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) From 1458aa87c5eae9dd99e141956a6adf7a0f3c6707 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 08:10:08 -0500 Subject: [PATCH 14/21] Remove unnecessary parameters --- examples/pylab_examples/histogram_demo_multihist.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index 60cfca9bff4c..fa8c5fe3fdf4 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -5,8 +5,7 @@ fig, axes = plt.subplots(nrows=2, ncols=2) ax0, ax1, ax2, ax3 = axes.flat -mu, sigma = 200, 25 -x = mu + sigma*np.random.randn(1000,3) +x = np.random.randn(1000,3) colors = ['crimson', 'burlywood', 'chartreuse'] n, bins, patches = ax0.hist(x, 10, normed=1, histtype='bar', @@ -22,7 +21,7 @@ ax2.set_title('stepfilled') # Make a multiple-histogram of data-sets with different length. -x_multi = [mu + sigma*np.random.randn(n) for n in [10000, 5000, 2000]] +x_multi = [np.random.randn(n) for n in [10000, 5000, 2000]] n, bins, patches = ax3.hist(x_multi, 10, histtype='bar') ax3.set_title('different sample sizes') From c3cce1c0a255111caf055144a058a28ab971f319 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 08:23:21 -0500 Subject: [PATCH 15/21] PEP8 fixes --- .../pylab_examples/histogram_demo_cumulative.py | 14 +++++++++----- .../pylab_examples/histogram_demo_histtypes.py | 12 ++++++------ .../pylab_examples/histogram_demo_multihist.py | 16 +++++++--------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_cumulative.py b/examples/pylab_examples/histogram_demo_cumulative.py index f976664af63f..d4743900c395 100644 --- a/examples/pylab_examples/histogram_demo_cumulative.py +++ b/examples/pylab_examples/histogram_demo_cumulative.py @@ -2,18 +2,22 @@ import matplotlib.pyplot as plt from matplotlib import mlab -mu, sigma = 200, 25 + +mu = 200 +sigma = 25 +n_bins = 50 x = mu + sigma*np.random.randn(10000) -n, bins, patches = plt.hist(x, 50, normed=1, histtype='step', cumulative=True) + +n, bins, patches = plt.hist(x, n_bins, normed=1, + histtype='step', cumulative=True) # Add a line showing the expected distribution. -y = mlab.normpdf( bins, mu, sigma).cumsum() +y = mlab.normpdf(bins, mu, sigma).cumsum() y /= y[-1] plt.plot(bins, y, 'k--', linewidth=1.5) # Overlay a reverted cumulative histogram. -n, bins, patches = plt.hist(x, bins=bins, normed=1, - histtype='step', cumulative=-1) +plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) plt.grid(True) plt.ylim(0, 1.05) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 170c1325eb3e..4aaa0f53f766 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -3,22 +3,22 @@ from matplotlib import mlab -mu, sigma = 200, 25 +mu = 200 +sigma = 25 +n_bins = 50 x = mu + sigma*np.random.randn(10000) fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4)) -n, bins, patches = ax0.hist(x, 50, normed=1, histtype='stepfilled', +n, bins, patches = ax0.hist(x, n_bins, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75) - # Add a line showing the expected distribution. -y = mlab.normpdf( bins, mu, sigma) +y = mlab.normpdf(bins, mu, sigma) ax0.plot(bins, y, 'k--', linewidth=1.5) - ax0.set_title('stepfilled') # Create a histogram by providing the bin edges (unequally spaced). -bins = [100,150,180,195,205,220,250,300] +bins = [100, 150, 180, 195, 205, 220, 250, 300] n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) ax1.set_title('unequal bins') diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index fa8c5fe3fdf4..115f9cc41d04 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -2,28 +2,26 @@ import matplotlib.pyplot as plt +n_bins = 10 +x = np.random.randn(1000, 3) + fig, axes = plt.subplots(nrows=2, ncols=2) ax0, ax1, ax2, ax3 = axes.flat -x = np.random.randn(1000,3) - colors = ['crimson', 'burlywood', 'chartreuse'] -n, bins, patches = ax0.hist(x, 10, normed=1, histtype='bar', - color=colors, label=colors) +ax0.hist(x, n_bins, normed=1, histtype='bar', color=colors, label=colors) ax0.legend(prop={'size': 10}) ax0.set_title('bar') - -n, bins, patches = ax1.hist(x, 10, normed=1, histtype='bar', stacked=True) +ax1.hist(x, n_bins, normed=1, histtype='bar', stacked=True) ax1.set_title('stacked bar') -n, bins, patches = ax2.hist(x, 10, histtype='step', stacked=True, fill=True) +ax2.hist(x, n_bins, histtype='step', stacked=True, fill=True) ax2.set_title('stepfilled') # Make a multiple-histogram of data-sets with different length. x_multi = [np.random.randn(n) for n in [10000, 5000, 2000]] - -n, bins, patches = ax3.hist(x_multi, 10, histtype='bar') +ax3.hist(x_multi, n_bins, histtype='bar') ax3.set_title('different sample sizes') plt.tight_layout() From 6d1b8a2ef277091eb718690e4443e6fa30cbc488 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 11:40:04 -0500 Subject: [PATCH 16/21] Add example docstrings --- examples/pylab_examples/histogram_demo_cumulative.py | 6 +++++- examples/pylab_examples/histogram_demo_histtypes.py | 7 +++++++ examples/pylab_examples/histogram_demo_multihist.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/pylab_examples/histogram_demo_cumulative.py b/examples/pylab_examples/histogram_demo_cumulative.py index d4743900c395..b555f0060eca 100644 --- a/examples/pylab_examples/histogram_demo_cumulative.py +++ b/examples/pylab_examples/histogram_demo_cumulative.py @@ -1,3 +1,7 @@ +""" +Demo of the histogram (hist) function used to plot a cumulative distribution. + +""" import numpy as np import matplotlib.pyplot as plt from matplotlib import mlab @@ -16,7 +20,7 @@ y /= y[-1] plt.plot(bins, y, 'k--', linewidth=1.5) -# Overlay a reverted cumulative histogram. +# Overlay a reversed cumulative histogram. plt.hist(x, bins=bins, normed=1, histtype='step', cumulative=-1) plt.grid(True) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 4aaa0f53f766..1bda872d43cf 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -1,3 +1,10 @@ +""" +Demo of the histogram (hist) function with different ``histtype`` settings. + +* Histogram with step curve that has a color fill. +* Histogram with with unequal bin widths. + +""" import numpy as np import matplotlib.pyplot as plt from matplotlib import mlab diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index 115f9cc41d04..a3f2bcfafc56 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -1,3 +1,13 @@ +""" +Demo of the histogram (hist) function with multiple data sets. + +Plot histogram with multiple sample sets and demonstrate: + + * Use of legend with multiple sample sets + * Stacked bars + * Step curve with a color fill + * Data sets of different sample sizes +""" import numpy as np import matplotlib.pyplot as plt From f7b2217a1f92343e8aca0684d19c9915cc2e8674 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 11:42:28 -0500 Subject: [PATCH 17/21] Simplify example. Remove plot of exact PDF since this is already demoed in another example. --- examples/pylab_examples/histogram_demo_histtypes.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/pylab_examples/histogram_demo_histtypes.py index 1bda872d43cf..898b90cae17f 100644 --- a/examples/pylab_examples/histogram_demo_histtypes.py +++ b/examples/pylab_examples/histogram_demo_histtypes.py @@ -7,26 +7,20 @@ """ import numpy as np import matplotlib.pyplot as plt -from matplotlib import mlab mu = 200 sigma = 25 -n_bins = 50 x = mu + sigma*np.random.randn(10000) fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4)) -n, bins, patches = ax0.hist(x, n_bins, normed=1, histtype='stepfilled', - facecolor='g', alpha=0.75) -# Add a line showing the expected distribution. -y = mlab.normpdf(bins, mu, sigma) -ax0.plot(bins, y, 'k--', linewidth=1.5) +ax0.hist(x, 20, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75) ax0.set_title('stepfilled') # Create a histogram by providing the bin edges (unequally spaced). bins = [100, 150, 180, 195, 205, 220, 250, 300] -n, bins, patches = ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) +ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8) ax1.set_title('unequal bins') plt.tight_layout() From a2b5dcda1d7bd82c29cc27ec61f1e9f782dddbfd Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 11:44:27 -0500 Subject: [PATCH 18/21] Clarify title of plot --- examples/pylab_examples/histogram_demo_multihist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/pylab_examples/histogram_demo_multihist.py index a3f2bcfafc56..9fb970cd0b2e 100644 --- a/examples/pylab_examples/histogram_demo_multihist.py +++ b/examples/pylab_examples/histogram_demo_multihist.py @@ -21,7 +21,7 @@ colors = ['crimson', 'burlywood', 'chartreuse'] ax0.hist(x, n_bins, normed=1, histtype='bar', color=colors, label=colors) ax0.legend(prop={'size': 10}) -ax0.set_title('bar') +ax0.set_title('bars with legend') ax1.hist(x, n_bins, normed=1, histtype='bar', stacked=True) ax1.set_title('stacked bar') From e62e51ec219b13dc61c88391cd052b092590b925 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 11:51:11 -0500 Subject: [PATCH 19/21] Move histogram examples to statistics directory --- .../{pylab_examples => statistics}/histogram_demo_cumulative.py | 0 .../{pylab_examples => statistics}/histogram_demo_histtypes.py | 0 .../{pylab_examples => statistics}/histogram_demo_multihist.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename examples/{pylab_examples => statistics}/histogram_demo_cumulative.py (100%) rename examples/{pylab_examples => statistics}/histogram_demo_histtypes.py (100%) rename examples/{pylab_examples => statistics}/histogram_demo_multihist.py (100%) diff --git a/examples/pylab_examples/histogram_demo_cumulative.py b/examples/statistics/histogram_demo_cumulative.py similarity index 100% rename from examples/pylab_examples/histogram_demo_cumulative.py rename to examples/statistics/histogram_demo_cumulative.py diff --git a/examples/pylab_examples/histogram_demo_histtypes.py b/examples/statistics/histogram_demo_histtypes.py similarity index 100% rename from examples/pylab_examples/histogram_demo_histtypes.py rename to examples/statistics/histogram_demo_histtypes.py diff --git a/examples/pylab_examples/histogram_demo_multihist.py b/examples/statistics/histogram_demo_multihist.py similarity index 100% rename from examples/pylab_examples/histogram_demo_multihist.py rename to examples/statistics/histogram_demo_multihist.py From 2dc9a4651e5e566afc0866c603aa8d06aaf32b71 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 12:47:51 -0500 Subject: [PATCH 20/21] Fix example links. The example linked in backend_driver was broken when examples were split up and renamed/moved. --- examples/tests/backend_driver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/tests/backend_driver.py b/examples/tests/backend_driver.py index 1c7a4587538f..0edf4332e586 100755 --- a/examples/tests/backend_driver.py +++ b/examples/tests/backend_driver.py @@ -74,7 +74,10 @@ files['statistics'] = [ 'errorbar_demo.py', 'errorbar_demo_features.py', + 'histogram_demo_cumulative.py', 'histogram_demo_features.py', + 'histogram_demo_histtypes.py', + 'histogram_demo_multihist.py', ] files['pie'] = [ @@ -172,7 +175,6 @@ 'hexbin_demo.py', 'hexbin_demo2.py', 'hist_colormapped.py', - 'histogram_demo_extended.py', 'vline_hline_demo.py', 'image_clip_path.py', From ef51dc3d4b27e7ad550cd3d2d282531765b0e5a3 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 29 Sep 2013 12:48:55 -0500 Subject: [PATCH 21/21] Shorten color names for better gallery build --- examples/statistics/histogram_demo_multihist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/statistics/histogram_demo_multihist.py b/examples/statistics/histogram_demo_multihist.py index 9fb970cd0b2e..57dd2ac00691 100644 --- a/examples/statistics/histogram_demo_multihist.py +++ b/examples/statistics/histogram_demo_multihist.py @@ -18,7 +18,7 @@ fig, axes = plt.subplots(nrows=2, ncols=2) ax0, ax1, ax2, ax3 = axes.flat -colors = ['crimson', 'burlywood', 'chartreuse'] +colors = ['red', 'tan', 'lime'] ax0.hist(x, n_bins, normed=1, histtype='bar', color=colors, label=colors) ax0.legend(prop={'size': 10}) ax0.set_title('bars with legend')