|
From: <jd...@us...> - 2008-06-26 19:08:50
|
Revision: 5682
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5682&view=rev
Author: jdh2358
Date: 2008-06-26 12:08:48 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
cleaned some docs for api examples
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/bar_stacked.py
trunk/matplotlib/examples/pylab_examples/broken_barh.py
trunk/matplotlib/examples/pylab_examples/hline_demo.py
trunk/matplotlib/examples/pylab_examples/xcorr_demo.py
Modified: trunk/matplotlib/examples/pylab_examples/bar_stacked.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/bar_stacked.py 2008-06-26 18:05:17 UTC (rev 5681)
+++ trunk/matplotlib/examples/pylab_examples/bar_stacked.py 2008-06-26 19:08:48 UTC (rev 5682)
@@ -1,23 +1,25 @@
#!/usr/bin/env python
# a stacked bar plot with errorbars
-from pylab import *
+import numpy as np
+import matplotlib.pyplot as plt
+
N = 5
menMeans = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, 20, 25)
menStd = (2, 3, 4, 1, 2)
womenStd = (3, 5, 2, 3, 3)
-ind = arange(N) # the x locations for the groups
+ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
-p1 = bar(ind, menMeans, width, color='r', yerr=womenStd)
-p2 = bar(ind, womenMeans, width, color='y',
- bottom=menMeans, yerr=menStd)
+p1 = plt.bar(ind, menMeans, width, color='r', yerr=womenStd)
+p2 = plt.bar(ind, womenMeans, width, color='y',
+ bottom=menMeans, yerr=menStd)
-ylabel('Scores')
-title('Scores by group and gender')
-xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
-yticks(arange(0,81,10))
-legend( (p1[0], p2[0]), ('Men', 'Women') )
+plt.ylabel('Scores')
+plt.title('Scores by group and gender')
+plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
+plt.yticks(np.arange(0,81,10))
+plt.legend( (p1[0], p2[0]), ('Men', 'Women') )
-show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/broken_barh.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/broken_barh.py 2008-06-26 18:05:17 UTC (rev 5681)
+++ trunk/matplotlib/examples/pylab_examples/broken_barh.py 2008-06-26 19:08:48 UTC (rev 5682)
@@ -1,10 +1,9 @@
-
"""
Make a "broken" horizontal bar plot, ie one with gaps
"""
-from matplotlib.pyplot import figure, show
+import matplotlib.pyplot as plt
-fig = figure()
+fig = plt.figure()
ax = fig.add_subplot(111)
ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue')
ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9),
@@ -22,4 +21,4 @@
horizontalalignment='right', verticalalignment='top')
#fig.savefig('broken_barh', dpi=100)
-show()
+plt.show()
Modified: trunk/matplotlib/examples/pylab_examples/hline_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008-06-26 18:05:17 UTC (rev 5681)
+++ trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
@@ -1,22 +1,23 @@
#!/usr/bin/env python
-from matplotlib.pyplot import *
-from numpy import sin, exp, absolute, pi, arange
-from numpy.random import normal
+import numpy as np
+import matplotlib.pyplot as plt
def f(t):
- s1 = sin(2*pi*t)
- e1 = exp(-t)
- return absolute((s1*e1))+.05
+ s1 = np.sin(2*np.pi*t)
+ e1 = np.exp(-t)
+ return np.absolute((s1*e1))+.05
-t = arange(0.0, 5.0, 0.1)
+t = np.arange(0.0, 5.0, 0.1)
s = f(t)
-nse = normal(0.0, 0.3, t.shape) * s
+nse = np.random.normal(0.0, 0.3, t.shape) * s
-plot(s+nse, t, 'b^')
-hlines(t, [0], s)
-xlabel('time (s)')
-title('Comparison of model with data')
-savefig('test')
-show()
+plt.plot(s+nse, t, 'b^')
+plt.hlines(t, [0], s, lw=2)
+plt.xlabel('time (s)')
+plt.title('Comparison of model with data')
+plt.savefig('test')
+plt.xlim(xmin=0)
+plt.show()
+
Modified: trunk/matplotlib/examples/pylab_examples/xcorr_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/xcorr_demo.py 2008-06-26 18:05:17 UTC (rev 5681)
+++ trunk/matplotlib/examples/pylab_examples/xcorr_demo.py 2008-06-26 19:08:48 UTC (rev 5682)
@@ -1,17 +1,17 @@
-from matplotlib.pylab import figure, show
-import numpy
+import matplotlib.pyplot as plt
+import numpy as np
-x,y = numpy.random.randn(2,100)
-fig = figure()
+x,y = np.random.randn(2,100)
+fig = plt.figure()
ax1 = fig.add_subplot(211)
-ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True)
+ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
ax1.grid(True)
ax1.axhline(0, color='black', lw=2)
ax2 = fig.add_subplot(212, sharex=ax1)
-ax2.acorr(x, usevlines=True, normed=True, maxlags=50)
+ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
ax2.grid(True)
ax2.axhline(0, color='black', lw=2)
-show()
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|