From 1b72df1a390441fbe9301a75ca832485a3a2f83f Mon Sep 17 00:00:00 2001 From: domspad Date: Sat, 11 Jul 2015 15:37:34 -0500 Subject: [PATCH 1/2] pylab to plt and np --- examples/pylab_examples/axes_props.py | 43 ++++++++++++++------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/examples/pylab_examples/axes_props.py b/examples/pylab_examples/axes_props.py index 4ae17f380384..889e664f0155 100644 --- a/examples/pylab_examples/axes_props.py +++ b/examples/pylab_examples/axes_props.py @@ -3,30 +3,31 @@ You can control the axis tick and grid properties """ -from pylab import * +import matplotlib.pyplot as plt +import numpy as np -t = arange(0.0, 2.0, 0.01) -s = sin(2*pi*t) -plot(t, s) -grid(True) +t = np.arange(0.0, 2.0, 0.01) +s = np.sin(2*pi*t) +plt.plot(t, s) +plt.grid(True) # MATLAB style -xticklines = getp(gca(), 'xticklines') -yticklines = getp(gca(), 'yticklines') -xgridlines = getp(gca(), 'xgridlines') -ygridlines = getp(gca(), 'ygridlines') -xticklabels = getp(gca(), 'xticklabels') -yticklabels = getp(gca(), 'yticklabels') - -setp(xticklines, 'linewidth', 3) -setp(yticklines, 'linewidth', 3) -setp(xgridlines, 'linestyle', '-') -setp(ygridlines, 'linestyle', '-') -setp(yticklabels, 'color', 'r', fontsize='medium') -setp(xticklabels, 'color', 'r', fontsize='medium') - - -show() +xticklines = plt.getp(plt.gca(), 'xticklines') +yticklines = plt.getp(plt.gca(), 'yticklines') +xgridlines = plt.getp(plt.gca(), 'xgridlines') +ygridlines = plt.getp(plt.gca(), 'ygridlines') +xticklabels = plt.getp(plt.gca(), 'xticklabels') +yticklabels = plt.getp(plt.gca(), 'yticklabels') + +plt.setp(xticklines, 'linewidth', 3) +plt.setp(yticklines, 'linewidth', 3) +plt.setp(xgridlines, 'linestyle', '-') +plt.setp(ygridlines, 'linestyle', '-') +plt.setp(yticklabels, 'color', 'r', fontsize='medium') +plt.setp(xticklabels, 'color', 'r', fontsize='medium') + + +plt.show() """ From 5a5f458aaf850357a00590621aae85fc3d63bd0b Mon Sep 17 00:00:00 2001 From: domspad Date: Thu, 16 Jul 2015 23:15:50 -0700 Subject: [PATCH 2/2] pep8 --- examples/pylab_examples/axes_props.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pylab_examples/axes_props.py b/examples/pylab_examples/axes_props.py index 889e664f0155..2697fca37c52 100644 --- a/examples/pylab_examples/axes_props.py +++ b/examples/pylab_examples/axes_props.py @@ -4,10 +4,10 @@ """ import matplotlib.pyplot as plt -import numpy as np +import numpy as np t = np.arange(0.0, 2.0, 0.01) -s = np.sin(2*pi*t) +s = np.sin(2*np.pi*t) plt.plot(t, s) plt.grid(True)