From d0ff103552f39329627532281d891acccc128025 Mon Sep 17 00:00:00 2001 From: domspad Date: Sat, 11 Jul 2015 15:33:13 -0500 Subject: [PATCH 1/2] pylab to plt and np --- examples/pylab_examples/axes_demo.py | 40 +++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/pylab_examples/axes_demo.py b/examples/pylab_examples/axes_demo.py index fc3ec16227a7..f92d01e9066b 100644 --- a/examples/pylab_examples/axes_demo.py +++ b/examples/pylab_examples/axes_demo.py @@ -1,32 +1,34 @@ #!/usr/bin/env python -from pylab import * +import matplotlib.pyplot as plt +import numpy as np +import scipy as sp # create some data to use for the plot dt = 0.001 -t = arange(0.0, 10.0, dt) -r = exp(-t[:1000]/0.05) # impulse response -x = randn(len(t)) -s = convolve(x, r)[:len(x)]*dt # colored noise +t = np.arange(0.0, 10.0, dt) +r = np.exp(-t[:1000]/0.05) # impulse response +x = sp.randn(len(t)) +s = np.convolve(x, r)[:len(x)]*dt # colored noise # the main axes is subplot(111) by default -plot(t, s) -axis([0, 1, 1.1*amin(s), 2*amax(s)]) -xlabel('time (s)') -ylabel('current (nA)') -title('Gaussian colored noise') +plt.plot(t, s) +plt.axis([0, 1, 1.1*np.amin(s), 2*np.amax(s)]) +plt.xlabel('time (s)') +plt.ylabel('current (nA)') +plt.title('Gaussian colored noise') # this is an inset axes over the main axes -a = axes([.65, .6, .2, .2], axisbg='y') -n, bins, patches = hist(s, 400, normed=1) -title('Probability') -setp(a, xticks=[], yticks=[]) +a = plt.axes([.65, .6, .2, .2], axisbg='y') +n, bins, patches = plt.hist(s, 400, normed=1) +plt.title('Probability') +plt.setp(a, xticks=[], yticks=[]) # this is another inset axes over the main axes -a = axes([0.2, 0.6, .2, .2], axisbg='y') -plot(t[:len(r)], r) -title('Impulse response') -setp(a, xlim=(0, .2), xticks=[], yticks=[]) +a = plt.axes([0.2, 0.6, .2, .2], axisbg='y') +plt.plot(t[:len(r)], r) +plt.title('Impulse response') +plt.setp(a, xlim=(0, .2), xticks=[], yticks=[]) -show() +plt.show() From da7841c994b12bb67d26e8a9c379a5df37c78857 Mon Sep 17 00:00:00 2001 From: domspad Date: Thu, 16 Jul 2015 23:18:35 -0700 Subject: [PATCH 2/2] pep8 --- examples/pylab_examples/axes_demo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/axes_demo.py b/examples/pylab_examples/axes_demo.py index f92d01e9066b..9bb9c047bf9d 100644 --- a/examples/pylab_examples/axes_demo.py +++ b/examples/pylab_examples/axes_demo.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -import matplotlib.pyplot as plt -import numpy as np +import matplotlib.pyplot as plt +import numpy as np import scipy as sp # create some data to use for the plot