From fa2e492ba902792f1cff8562d549181035d18728 Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Wed, 29 Jul 2015 08:48:05 -0400 Subject: [PATCH 1/3] mep12 on logo.py --- examples/pylab_examples/logo.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/pylab_examples/logo.py b/examples/pylab_examples/logo.py index 03cb060d18d2..2265012517b0 100755 --- a/examples/pylab_examples/logo.py +++ b/examples/pylab_examples/logo.py @@ -1,28 +1,29 @@ -#!/usr/bin/env python # This file generates the matplotlib web page logo -from __future__ import print_function -from pylab import * +# from __future__ import print_function +# Above import not necessary for Python 3 onwards. Recommend taking this out in all examples. +import matplotlib.pyplot as plt +import numpy as np import matplotlib.cbook as cbook # convert data to mV datafile = cbook.get_sample_data('membrane.dat', asfileobj=False) print('loading', datafile) -x = 1000*0.1*fromstring(open(datafile, 'rb').read(), float32) +x = 1000*0.1*np.fromstring(open(datafile, 'rb').read(), np.float32) # 0.0005 is the sample interval -t = 0.0005*arange(len(x)) -figure(1, figsize=(7, 1), dpi=100) -ax = subplot(111, axisbg='y') -plot(t, x) -text(0.5, 0.5, 'matplotlib', color='r', +t = 0.0005*np.arange(len(x)) +plt.figure(1, figsize=(7, 1), dpi=100) +ax = plt.subplot(111, axisbg='y') +plt.plot(t, x) +plt.text(0.5, 0.5, 'matplotlib', color='r', fontsize=40, fontname=['Courier', 'Bitstream Vera Sans Mono'], horizontalalignment='center', verticalalignment='center', transform=ax.transAxes, ) -axis([1, 1.72, -60, 10]) -setp(gca(), 'xticklabels', []) -setp(gca(), 'yticklabels', []) +plt.axis([1, 1.72, -60, 10]) +plt.setp(plt.gca(), 'xticklabels', []) +plt.setp(plt.gca(), 'yticklabels', []) -show() +plt.show() From d35ebe69a2ef3d091d3f4d18673f5e682e31ba90 Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Wed, 29 Jul 2015 08:48:51 -0400 Subject: [PATCH 2/3] pep8 on logo.py --- examples/pylab_examples/logo.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/pylab_examples/logo.py b/examples/pylab_examples/logo.py index 2265012517b0..43fbda5170f9 100755 --- a/examples/pylab_examples/logo.py +++ b/examples/pylab_examples/logo.py @@ -1,27 +1,28 @@ # This file generates the matplotlib web page logo -# from __future__ import print_function -# Above import not necessary for Python 3 onwards. Recommend taking this out in all examples. +# from __future__ import print_function +# Above import not necessary for Python 3 onwards. Recommend taking this +# out in all examples. import matplotlib.pyplot as plt -import numpy as np +import numpy as np import matplotlib.cbook as cbook # convert data to mV datafile = cbook.get_sample_data('membrane.dat', asfileobj=False) print('loading', datafile) -x = 1000*0.1*np.fromstring(open(datafile, 'rb').read(), np.float32) +x = 1000 * 0.1 * np.fromstring(open(datafile, 'rb').read(), np.float32) # 0.0005 is the sample interval -t = 0.0005*np.arange(len(x)) +t = 0.0005 * np.arange(len(x)) plt.figure(1, figsize=(7, 1), dpi=100) ax = plt.subplot(111, axisbg='y') plt.plot(t, x) plt.text(0.5, 0.5, 'matplotlib', color='r', - fontsize=40, fontname=['Courier', 'Bitstream Vera Sans Mono'], - horizontalalignment='center', - verticalalignment='center', - transform=ax.transAxes, - ) + fontsize=40, fontname=['Courier', 'Bitstream Vera Sans Mono'], + horizontalalignment='center', + verticalalignment='center', + transform=ax.transAxes, + ) plt.axis([1, 1.72, -60, 10]) plt.setp(plt.gca(), 'xticklabels', []) plt.setp(plt.gca(), 'yticklabels', []) From e77f12c69dad15cff8c9c29819ffa53723a43eea Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Wed, 29 Jul 2015 11:47:36 -0400 Subject: [PATCH 3/3] made requested changes --- examples/pylab_examples/logo.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/pylab_examples/logo.py b/examples/pylab_examples/logo.py index 43fbda5170f9..d13a714fb0bb 100755 --- a/examples/pylab_examples/logo.py +++ b/examples/pylab_examples/logo.py @@ -1,8 +1,8 @@ -# This file generates the matplotlib web page logo +# This file generates an old version of the matplotlib logo -# from __future__ import print_function +from __future__ import print_function # Above import not necessary for Python 3 onwards. Recommend taking this -# out in all examples. +# out in examples in the future, since we should all move to Python 3. import matplotlib.pyplot as plt import numpy as np import matplotlib.cbook as cbook @@ -24,7 +24,7 @@ transform=ax.transAxes, ) plt.axis([1, 1.72, -60, 10]) -plt.setp(plt.gca(), 'xticklabels', []) -plt.setp(plt.gca(), 'yticklabels', []) +plt.gca().set_xticklabels([]) +plt.gca().set_yticklabels([]) plt.show()