|
From: <ef...@us...> - 2007-07-20 19:17:16
|
Revision: 3597
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3597&view=rev
Author: efiring
Date: 2007-07-20 12:17:14 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
A few more changes in examples
Modified Paths:
--------------
trunk/matplotlib/examples/contour_demo.py
trunk/matplotlib/examples/ellipse_demo.py
trunk/matplotlib/examples/image_demo.py
trunk/matplotlib/examples/simple3d_oo.py
Modified: trunk/matplotlib/examples/contour_demo.py
===================================================================
--- trunk/matplotlib/examples/contour_demo.py 2007-07-20 18:35:35 UTC (rev 3596)
+++ trunk/matplotlib/examples/contour_demo.py 2007-07-20 19:17:14 UTC (rev 3597)
@@ -97,5 +97,5 @@
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
-savefig('contour_demo')
+#savefig('contour_demo')
show()
Modified: trunk/matplotlib/examples/ellipse_demo.py
===================================================================
--- trunk/matplotlib/examples/ellipse_demo.py 2007-07-20 18:35:35 UTC (rev 3596)
+++ trunk/matplotlib/examples/ellipse_demo.py 2007-07-20 19:17:14 UTC (rev 3597)
@@ -1,24 +1,23 @@
-from pylab import figure, show, nx
-from matplotlib.patches import Ellipse
-rand = nx.mlab.rand
-
-NUM = 250
-
-ells = [Ellipse(xy=rand(2)*10, width=rand(), height=rand(), angle=rand()*360)
- for i in xrange(NUM)]
-
-fig = figure()
-ax = fig.add_subplot(111, aspect='equal')
-for e in ells:
- ax.add_artist(e)
- e.set_clip_box(ax.bbox)
- e.set_alpha(rand())
- e.set_facecolor(rand(3))
-
-ax.set_xlim(0, 10)
-ax.set_ylim(0, 10)
-
-fig.savefig('../figures/ellipse_demo.eps')
-fig.savefig('../figures/ellipse_demo.png')
-
-show()
+from pylab import figure, show, rand
+from matplotlib.patches import Ellipse
+
+NUM = 250
+
+ells = [Ellipse(xy=rand(2)*10, width=rand(), height=rand(), angle=rand()*360)
+ for i in xrange(NUM)]
+
+fig = figure()
+ax = fig.add_subplot(111, aspect='equal')
+for e in ells:
+ ax.add_artist(e)
+ e.set_clip_box(ax.bbox)
+ e.set_alpha(rand())
+ e.set_facecolor(rand(3))
+
+ax.set_xlim(0, 10)
+ax.set_ylim(0, 10)
+
+#fig.savefig('ellipse_demo.eps')
+#fig.savefig('ellipse_demo.png')
+
+show()
Modified: trunk/matplotlib/examples/image_demo.py
===================================================================
--- trunk/matplotlib/examples/image_demo.py 2007-07-20 18:35:35 UTC (rev 3596)
+++ trunk/matplotlib/examples/image_demo.py 2007-07-20 19:17:14 UTC (rev 3597)
@@ -11,6 +11,6 @@
im = imshow(Z, interpolation='bilinear', cmap=cm.gray,
origin='lower', extent=[-3,3,-3,3])
-savefig('image_demo')
+#savefig('image_demo')
show()
Modified: trunk/matplotlib/examples/simple3d_oo.py
===================================================================
--- trunk/matplotlib/examples/simple3d_oo.py 2007-07-20 18:35:35 UTC (rev 3596)
+++ trunk/matplotlib/examples/simple3d_oo.py 2007-07-20 19:17:14 UTC (rev 3597)
@@ -2,12 +2,11 @@
import matplotlib
matplotlib.use('WXAgg')
-matplotlib.rcParams['numerix'] = 'numpy'
from wx import *
import matplotlib.axes3d
import matplotlib.mlab
-from matplotlib import numerix as nx
+import numpy as npy
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg, FigureManager, NavigationToolbar2WxAgg
@@ -39,13 +38,14 @@
ax3d = matplotlib.axes3d.Axes3D(self.fig)
plt = self.fig.axes.append(ax3d)
- delta = nx.pi / 199.0
- u = nx.arange(0, 2*nx.pi+(delta*2), delta*2)
- v = nx.arange(0, nx.pi+delta, delta)
+ delta = npy.pi / 199.0
+ u = npy.arange(0, 2*npy.pi+(delta*2), delta*2)
+ v = npy.arange(0, npy.pi+delta, delta)
- x=nx.outerproduct(nx.cos(u),nx.sin(v))
- y=nx.outerproduct(nx.sin(u),nx.sin(v))
- z=nx.outerproduct(nx.ones(nx.size(u)), nx.cos(v))
+ x = npy.cos(u)[:,npy.newaxis] * npy.sin(v)[npy.newaxis,:]
+ y = npy.sin(u)[:,npy.newaxis] * npy.sin(v)[npy.newaxis,:]
+ z = npy.ones_like(u)[:,npy.newaxis] * npy.cos(v)[npy.newaxis,:]
+ # (there is probably a better way to calculate z)
print x.shape, y.shape, z.shape
#ax3d.plot_wireframe(x,y,z)
@@ -55,7 +55,7 @@
ax3d.set_xlabel('X')
ax3d.set_ylabel('Y')
ax3d.set_zlabel('Z')
- self.fig.savefig('globe')
+ #self.fig.savefig('globe')
if __name__ == '__main__':
app = PySimpleApp(0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <pki...@us...> - 2007-09-05 21:40:44
|
Revision: 3793
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3793&view=rev
Author: pkienzle
Date: 2007-09-05 14:40:41 -0700 (Wed, 05 Sep 2007)
Log Message:
-----------
Convert to numpy
Modified Paths:
--------------
trunk/matplotlib/examples/quadmesh_demo.py
trunk/matplotlib/examples/simple3d.py
Modified: trunk/matplotlib/examples/quadmesh_demo.py
===================================================================
--- trunk/matplotlib/examples/quadmesh_demo.py 2007-09-05 19:38:27 UTC (rev 3792)
+++ trunk/matplotlib/examples/quadmesh_demo.py 2007-09-05 21:40:41 UTC (rev 3793)
@@ -4,23 +4,21 @@
with some restrictions.
"""
-from matplotlib.mlab import linspace, meshgrid
-import matplotlib.numerix as nx
+import numpy as nx
from pylab import figure,show
-import matplotlib.numerix.ma as ma
from matplotlib import cm, colors
n = 56
-x = linspace(-1.5,1.5,n)
-X,Y = meshgrid(x,x);
+x = nx.linspace(-1.5,1.5,n)
+X,Y = nx.meshgrid(x,x);
Qx = nx.cos(Y) - nx.cos(X)
Qz = nx.sin(Y) + nx.sin(X)
Qx = (Qx + 1.1)
Z = nx.sqrt(X**2 + Y**2)/5;
-Z = (Z - nx.mlab.amin(Z)) / (nx.mlab.amax(Z) - nx.mlab.amin(Z))
+Z = (Z - nx.amin(Z)) / (nx.amax(Z) - nx.amin(Z))
# The color array can include masked values:
-Zm = ma.masked_where(nx.fabs(Qz) < 0.5*nx.mlab.amax(Qz), Z)
+Zm = nx.ma.masked_where(nx.fabs(Qz) < 0.5*nx.amax(Qz), Z)
fig = figure()
Modified: trunk/matplotlib/examples/simple3d.py
===================================================================
--- trunk/matplotlib/examples/simple3d.py 2007-09-05 19:38:27 UTC (rev 3792)
+++ trunk/matplotlib/examples/simple3d.py 2007-09-05 21:40:41 UTC (rev 3793)
@@ -1,11 +1,6 @@
#!/usr/bin/env python
-import matplotlib
-matplotlib.rcParams['numerix'] = 'numpy'
-import numpy as np
-from numpy import arange, cos, linspace, ones, pi, sin
-import matplotlib.numerix as nx
-from matplotlib.numerix import outerproduct
+from numpy import arange, cos, linspace, ones, pi, sin, outer
import pylab
import matplotlib.axes3d as axes3d
@@ -20,9 +15,9 @@
u = arange(0, 2*pi+(delta*2), delta*2)
v = arange(0, pi+delta, delta)
-x = outerproduct(cos(u),sin(v))
-y = outerproduct(sin(u),sin(v))
-z = outerproduct(ones(u.shape), cos(v))
+x = outer(cos(u),sin(v))
+y = outer(sin(u),sin(v))
+z = outer(ones(u.shape), cos(v))
#ax3d.plot_wireframe(x,y,z)
surf = ax3d.plot_surface(x, y, z)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2007-09-24 13:03:06
|
Revision: 3882
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3882&view=rev
Author: dsdale
Date: 2007-09-24 06:03:01 -0700 (Mon, 24 Sep 2007)
Log Message:
-----------
modifed embedding_in_qt* examples so they can be run from ipython with
-q*thread
Modified Paths:
--------------
trunk/matplotlib/examples/embedding_in_qt.py
trunk/matplotlib/examples/embedding_in_qt4.py
Modified: trunk/matplotlib/examples/embedding_in_qt.py
===================================================================
--- trunk/matplotlib/examples/embedding_in_qt.py 2007-09-24 13:01:17 UTC (rev 3881)
+++ trunk/matplotlib/examples/embedding_in_qt.py 2007-09-24 13:03:01 UTC (rev 3882)
@@ -25,7 +25,7 @@
# Note: color-intensive applications may require a different color allocation
# strategy.
-QApplication.setColorSpec(QApplication.NormalColor)
+#QApplication.setColorSpec(QApplication.NormalColor)
app = QApplication(sys.argv)
class MyMplCanvas(FigureCanvas):
@@ -129,12 +129,8 @@
% {"prog": progname, "version": progversion})
-def main():
- aw = ApplicationWindow()
- aw.setCaption("%s" % progname)
- qApp.setMainWidget(aw)
- aw.show()
- sys.exit(qApp.exec_loop())
-
-
-if __name__ == "__main__": main()
+aw = ApplicationWindow()
+aw.setCaption("%s" % progname)
+qApp.setMainWidget(aw)
+aw.show()
+sys.exit(qApp.exec_loop())
Modified: trunk/matplotlib/examples/embedding_in_qt4.py
===================================================================
--- trunk/matplotlib/examples/embedding_in_qt4.py 2007-09-24 13:01:17 UTC (rev 3881)
+++ trunk/matplotlib/examples/embedding_in_qt4.py 2007-09-24 13:03:01 UTC (rev 3882)
@@ -122,17 +122,10 @@
% {"prog": progname, "version": progversion})
-def main():
- # Note: color-intensive applications may require a different color
- # allocation strategy.
- QtGui.QApplication.setColorSpec(QtGui.QApplication.NormalColor)
- qApp = QtGui.QApplication(sys.argv)
+qApp = QtGui.QApplication(sys.argv)
- aw = ApplicationWindow()
- aw.setWindowTitle("%s" % progname)
- aw.show()
-# sys.exit(qApp.exec_())
- qApp.exec_()
-
-
-if __name__ == "__main__": main()
+aw = ApplicationWindow()
+aw.setWindowTitle("%s" % progname)
+aw.show()
+sys.exit(qApp.exec_())
+#qApp.exec_()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2007-10-29 17:47:21
|
Revision: 4057
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4057&view=rev
Author: mdboom
Date: 2007-10-29 10:47:10 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
Improve the code coverage of backend_driver.py
Modified Paths:
--------------
trunk/matplotlib/examples/arrow_demo.py
trunk/matplotlib/examples/backend_driver.py
trunk/matplotlib/examples/legend_auto.py
trunk/matplotlib/examples/wxcursor_demo.py
Added Paths:
-----------
trunk/matplotlib/examples/equal_aspect_ratio.py
trunk/matplotlib/examples/hline_demo.py
Modified: trunk/matplotlib/examples/arrow_demo.py
===================================================================
--- trunk/matplotlib/examples/arrow_demo.py 2007-10-29 17:39:06 UTC (rev 4056)
+++ trunk/matplotlib/examples/arrow_demo.py 2007-10-29 17:47:10 UTC (rev 4057)
@@ -280,6 +280,7 @@
if __name__ == '__main__':
from sys import argv
+ d = None
if len(argv) > 1:
if argv[1] == 'full':
d = all_on_max
@@ -293,7 +294,7 @@
elif argv[1] == 'sample':
d = sample_data
scaled = True
- else:
+ if d is None:
d = all_on_max
scaled=False
if len(argv) > 2:
Modified: trunk/matplotlib/examples/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/backend_driver.py 2007-10-29 17:39:06 UTC (rev 4056)
+++ trunk/matplotlib/examples/backend_driver.py 2007-10-29 17:47:10 UTC (rev 4057)
@@ -22,10 +22,16 @@
files = (
'alignment_test.py',
'arctest.py',
+ 'arrow_demo.py',
'axes_demo.py',
+ 'axhspan_demo.py',
'bar_stacked.py',
'barchart_demo.py',
+ 'boxplot_demo.py',
+ 'broken_barh.py',
+ 'barh_demo.py',
'color_demo.py',
+ 'colorbar_only.py',
'contour_demo.py',
'contourf_demo.py',
'csd_demo.py',
@@ -33,6 +39,8 @@
'customize_rc.py',
'date_demo1.py',
'date_demo2.py',
+ 'equal_aspect_ratio.py',
+ 'errorbar_limits.py',
'figimage_demo.py',
'figlegend_demo.py',
'figtext.py',
@@ -40,12 +48,14 @@
'finance_demo.py',
'fonts_demo_kw.py',
'histogram_demo.py',
+ 'hline_demo.py',
'image_demo.py',
'image_demo2.py',
'image_masked.py',
'image_origin.py',
'invert_axes.py',
'layer_images.py',
+ 'legend_auto.py',
'legend_demo.py',
'legend_demo2.py',
'line_collection.py',
@@ -66,11 +76,18 @@
'polar_demo.py',
'polar_scatter.py',
'psd_demo.py',
+ 'quadmesh_demo.py',
'quiver_demo.py',
'scatter_demo.py',
'scatter_demo2.py',
+ 'scatter_star_poly.py',
+ 'shared_axis_demo.py',
+ 'shared_axis_across_figures.py',
'simple_plot.py',
'specgram_demo.py',
+ 'spy_demos.py',
+ 'stem_plot.py',
+ 'step_demo.py',
'stock_demo.py',
'subplot_demo.py',
# 'set_and_get.py',
@@ -104,7 +121,7 @@
def run(arglist):
os.system(' '.join(arglist))
-def drive(backend, python='python', switches = []):
+def drive(backend, python=['python'], switches = []):
exclude = failbackend.get(backend, [])
switchstring = ' '.join(switches)
@@ -151,17 +168,20 @@
tmpfile.write('savefig("%s", dpi=150)' % outfile)
tmpfile.close()
- run([python, tmpfile_name, switchstring])
+ run(python + [tmpfile_name, switchstring])
#os.system('%s %s %s' % (python, tmpfile_name, switchstring))
os.remove(tmpfile_name)
if __name__ == '__main__':
times = {}
default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template']
- if sys.platform == 'win32':
- python = r'c:\Python24\python.exe'
+ if '--coverage' in sys.argv:
+ python = ['coverage.py', '-x']
+ sys.argv.remove('--coverage')
+ elif sys.platform == 'win32':
+ python = [r'c:\Python24\python.exe']
else:
- python = 'python'
+ python = ['python']
all_backends = [b.lower() for b in mplbe.all_backends]
all_backends.extend(['cairo.png', 'cairo.ps', 'cairo.pdf', 'cairo.svg'])
backends = []
Added: trunk/matplotlib/examples/equal_aspect_ratio.py
===================================================================
--- trunk/matplotlib/examples/equal_aspect_ratio.py (rev 0)
+++ trunk/matplotlib/examples/equal_aspect_ratio.py 2007-10-29 17:47:10 UTC (rev 4057)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+"""
+Example: simple line plot.
+Show how to make a plot that has equal aspect ratio
+"""
+from pylab import *
+
+t = arange(0.0, 1.0+0.01, 0.01)
+s = cos(2*2*pi*t)
+plot(t, s, '-', lw=2)
+
+xlabel('time (s)')
+ylabel('voltage (mV)')
+title('About as simple as it gets, folks')
+grid(True)
+
+axes().set_aspect('equal', 'datalim')
+
+
+#savefig('simple_plot.png')
+savefig('equal_aspect')
+
+show()
Property changes on: trunk/matplotlib/examples/equal_aspect_ratio.py
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/matplotlib/examples/hline_demo.py
===================================================================
--- trunk/matplotlib/examples/hline_demo.py (rev 0)
+++ trunk/matplotlib/examples/hline_demo.py 2007-10-29 17:47:10 UTC (rev 4057)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+from matplotlib.pyplot import *
+from numpy import sin, exp, absolute, pi, arange
+from numpy.random import normal
+
+def f(t):
+ s1 = sin(2*pi*t)
+ e1 = exp(-t)
+ return absolute((s1*e1))+.05
+
+
+t = arange(0.0, 5.0, 0.1)
+s = f(t)
+nse = 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')
+show()
+
Property changes on: trunk/matplotlib/examples/hline_demo.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/matplotlib/examples/legend_auto.py
===================================================================
--- trunk/matplotlib/examples/legend_auto.py 2007-10-29 17:39:06 UTC (rev 4056)
+++ trunk/matplotlib/examples/legend_auto.py 2007-10-29 17:47:10 UTC (rev 4057)
@@ -79,7 +79,12 @@
if __name__ == '__main__':
nfigs = 10
- figures = [int(f) for f in sys.argv[1:]]
+ figures = []
+ for f in sys.argv[1:]:
+ try:
+ figures.append(int(f))
+ except ValueError:
+ pass
if len(figures) == 0:
figures = range(1, nfigs+1)
Modified: trunk/matplotlib/examples/wxcursor_demo.py
===================================================================
--- trunk/matplotlib/examples/wxcursor_demo.py 2007-10-29 17:39:06 UTC (rev 4056)
+++ trunk/matplotlib/examples/wxcursor_demo.py 2007-10-29 17:47:10 UTC (rev 4057)
@@ -3,6 +3,8 @@
"""
import matplotlib
+matplotlib.use('WXAgg')
+
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
@@ -65,6 +67,5 @@
return True
if __name__=='__main__':
- matplotlib.use('WXAgg')
app = App(0)
app.MainLoop()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2007-10-29 19:00:26
|
Revision: 4062
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4062&view=rev
Author: jdh2358
Date: 2007-10-29 12:00:25 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
added cohere demo
Modified Paths:
--------------
trunk/matplotlib/examples/backend_driver.py
trunk/matplotlib/examples/image_slices_viewer.py
Added Paths:
-----------
trunk/matplotlib/examples/cohere_demo.py
Modified: trunk/matplotlib/examples/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/backend_driver.py 2007-10-29 18:52:41 UTC (rev 4061)
+++ trunk/matplotlib/examples/backend_driver.py 2007-10-29 19:00:25 UTC (rev 4062)
@@ -32,9 +32,10 @@
'barh_demo.py',
'color_demo.py',
'colorbar_only.py',
+ 'cohere_demo.py',
'contour_demo.py',
'contourf_demo.py',
- 'csd_demo.py',
+ 'csd_demo.py',
'custom_ticker1.py',
'customize_rc.py',
'date_demo1.py',
Added: trunk/matplotlib/examples/cohere_demo.py
===================================================================
--- trunk/matplotlib/examples/cohere_demo.py (rev 0)
+++ trunk/matplotlib/examples/cohere_demo.py 2007-10-29 19:00:25 UTC (rev 4062)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+"""
+Compute the coherence of two signals
+"""
+import numpy as n
+
+from pylab import figure, show
+
+dt = 0.01
+t = n.arange(0, 30, dt)
+Nt = len(t)
+nse1 = n.random.randn(Nt) # white noise 1
+nse2 = n.random.randn(Nt) # white noise 2
+r = n.exp(-t/0.05)
+
+cnse1 = n.convolve(nse1, r)*dt # colored noise 1
+cnse1 = cnse1[:Nt]
+cnse2 = n.convolve(nse2, r)*dt # colored noise 2
+cnse2 = cnse2[:Nt]
+
+# two signals with a coherent part and a random part
+s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1
+s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2
+
+fig = figure()
+ax = fig.add_subplot(211)
+ax.plot(t, s1, 'b-', t, s2, 'g-')
+ax.set_xlim(0,5)
+ax.set_xlabel('time')
+ax.set_ylabel('s1 and s2')
+
+ax = fig.add_subplot(212)
+cxy, f = ax.cohere(s1, s2, 256, 1./dt)
+
+show()
+
+
Modified: trunk/matplotlib/examples/image_slices_viewer.py
===================================================================
--- trunk/matplotlib/examples/image_slices_viewer.py 2007-10-29 18:52:41 UTC (rev 4061)
+++ trunk/matplotlib/examples/image_slices_viewer.py 2007-10-29 19:00:25 UTC (rev 4062)
@@ -17,7 +17,7 @@
self.update()
def onscroll(self, event):
-
+ print event.button
if event.button=='up':
self.ind = numpy.clip(self.ind+1, 0, self.slices-1)
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2007-12-13 13:40:53
|
Revision: 4718
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4718&view=rev
Author: mdboom
Date: 2007-12-13 05:40:40 -0800 (Thu, 13 Dec 2007)
Log Message:
-----------
Updated to numpy names.
Modified Paths:
--------------
trunk/matplotlib/examples/logo.py
trunk/matplotlib/examples/mri_demo.py
Modified: trunk/matplotlib/examples/logo.py
===================================================================
--- trunk/matplotlib/examples/logo.py 2007-12-12 20:13:52 UTC (rev 4717)
+++ trunk/matplotlib/examples/logo.py 2007-12-13 13:40:40 UTC (rev 4718)
@@ -5,7 +5,7 @@
# convert data to mV
x = 1000*0.1*fromstring(
- file('data/membrane.dat', 'rb').read(), Float32)
+ file('data/membrane.dat', 'rb').read(), float32)
# 0.0005 is the sample interval
t = 0.0005*arange(len(x))
figure(1, figsize=(7,1), dpi=100)
Modified: trunk/matplotlib/examples/mri_demo.py
===================================================================
--- trunk/matplotlib/examples/mri_demo.py 2007-12-12 20:13:52 UTC (rev 4717)
+++ trunk/matplotlib/examples/mri_demo.py 2007-12-13 13:40:40 UTC (rev 4718)
@@ -3,7 +3,7 @@
# data are 256x256 16 bit integers
dfile = 'data/s1045.ima'
-im = fromstring(file(dfile, 'rb').read(), UInt16).astype(Float)
+im = fromstring(file(dfile, 'rb').read(), uint16).astype(float)
im.shape = 256, 256
#imshow(im, ColormapJet(256))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-16 12:50:22
|
Revision: 5144
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5144&view=rev
Author: jdh2358
Date: 2008-05-16 05:50:00 -0700 (Fri, 16 May 2008)
Log Message:
-----------
moved deprecated examples to storage
Added Paths:
-----------
trunk/matplotlib/examples/cold_storage/
trunk/matplotlib/examples/cold_storage/README
trunk/matplotlib/examples/cold_storage/agg_resize.py
trunk/matplotlib/examples/cold_storage/agg_test.py
trunk/matplotlib/examples/cold_storage/clippath_test.py
trunk/matplotlib/examples/cold_storage/glyph_to_path.py
Removed Paths:
-------------
trunk/matplotlib/examples/agg_resize.py
trunk/matplotlib/examples/agg_test.py
trunk/matplotlib/examples/clippath_test.py
trunk/matplotlib/examples/glyph_to_path.py
Deleted: trunk/matplotlib/examples/agg_resize.py
===================================================================
--- trunk/matplotlib/examples/agg_resize.py 2008-05-15 19:25:14 UTC (rev 5143)
+++ trunk/matplotlib/examples/agg_resize.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -1,7 +0,0 @@
-# test the resizing methods in the agg wrapper
-
-import matplotlib.agg as agg
-
-
-imMatrix = agg.trans_affine(1,0,0,1,0,0)
-interp = agg.span_interpolator_linear(imMatrix);
Deleted: trunk/matplotlib/examples/agg_test.py
===================================================================
--- trunk/matplotlib/examples/agg_test.py 2008-05-15 19:25:14 UTC (rev 5143)
+++ trunk/matplotlib/examples/agg_test.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -1,154 +0,0 @@
-# this example uses the agg python module directly there is no
-# documentation -- you have to know how to use the agg c++ API to use
-# it
-import matplotlib.agg as agg
-from math import pi
-
-## Define some colors
-red = agg.rgba8(255,0,0,255)
-blue = agg.rgba8(0,0,255,255)
-green = agg.rgba8(0,255,0,255)
-black = agg.rgba8(0,0,0,255)
-white = agg.rgba8(255,255,255,255)
-yellow = agg.rgba8(192,192,255,255)
-
-## Create the rendering buffer, rasterizer, etc
-width, height = 600,400
-stride = width*4
-buffer = agg.buffer(width, height, stride)
-
-rbuf = agg.rendering_buffer()
-rbuf.attachb(buffer)
-
-pf = agg.pixel_format_rgba(rbuf)
-rbase = agg.renderer_base_rgba(pf)
-rbase.clear_rgba8(blue)
-
-renderer = agg.renderer_scanline_aa_solid_rgba(rbase);
-renderer.color_rgba8( red )
-rasterizer = agg.rasterizer_scanline_aa()
-scanline = agg.scanline_p8()
-
-## A polygon path
-path = agg.path_storage()
-path.move_to(10,10)
-path.line_to(100,100)
-path.line_to(200,200)
-path.line_to(100,200)
-path.close_polygon()
-
-# stroke it
-stroke = agg.conv_stroke_path(path)
-stroke.width(3.0)
-rasterizer.add_path(stroke)
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-## A curved path
-path = agg.path_storage()
-path.move_to(200,10)
-path.line_to(350,50)
-path.curve3(150,200)
-path.curve3(100,70)
-path.close_polygon()
-curve = agg.conv_curve_path(path)
-
-# fill it
-rasterizer.add_path(curve)
-renderer.color_rgba8( green )
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-# and stroke it
-stroke = agg.conv_stroke_curve(curve)
-stroke.width(5.0)
-rasterizer.add_path(stroke)
-renderer.color_rgba8( yellow )
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-## Transforming a path
-path = agg.path_storage()
-path.move_to(0,0)
-path.line_to(1,0)
-path.line_to(1,1)
-path.line_to(0,1)
-path.close_polygon()
-
-rotation = agg.trans_affine_rotation(pi/4)
-scaling = agg.trans_affine_scaling(30,30)
-translation = agg.trans_affine_translation(300,300)
-trans = rotation*scaling*translation
-
-transpath = agg.conv_transform_path(path, trans)
-stroke = agg.conv_stroke_transpath(transpath)
-stroke.width(2.0)
-rasterizer.add_path(stroke)
-renderer.color_rgba8( black )
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-## Converting a transformed path to a curve
-path = agg.path_storage()
-path.move_to(0,0)
-path.curve3(1,0)
-path.curve3(1,1)
-path.curve3(0,1)
-path.close_polygon()
-
-rotation = agg.trans_affine_rotation(pi/4)
-scaling = agg.trans_affine_scaling(30,30)
-translation = agg.trans_affine_translation(300,250)
-trans = rotation*scaling*translation
-trans.flip_y()
-
-transpath = agg.conv_transform_path(path, trans)
-curvetrans = agg.conv_curve_trans(transpath)
-stroke = agg.conv_stroke_curvetrans(curvetrans)
-stroke.width(2.0)
-rasterizer.add_path(stroke)
-renderer.color_rgba8( white )
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-if 0:
- ## Copy a rectangle from the buffer the rectangle defined by
- ## x0,y0->x1,y1 and paste it at xdest, ydest
- x0, y0 = 10, 50
- x1, y1 = 110, 190
- xdest, ydest = 350, 200
-
-
-
- widthr, heightr = x1-x0, y1-y0
- strider = widthr*4
- copybuffer = agg.buffer(widthr, heightr, strider)
-
-
- rbufcopy = agg.rendering_buffer()
- rbufcopy.attachb(copybuffer)
- pfcopy = agg.pixel_format_rgba(rbufcopy)
- rbasecopy = agg.renderer_base_rgba(pfcopy)
-
- rect = agg.rect(x0, y0, x1, y1)
- print rect.is_valid()
- rectp = agg.rectPtr(rect)
- #print dir(rbasecopy)
-
- # agg is funny about the arguments to copy from; the last 2 args are
- # dx, dy. If the src and dest buffers are the same size and you omit
- # the dx and dy args, the position of the copy in the dest buffer is
- # the same as in the src. Since our dest buffer is smaller than our
- # src buffer, we have to offset the location by -x0, -y0
- rbasecopy.copy_from(rbuf, rect, -x0, -y0);
-
- # paste the rectangle at a new location xdest, ydest
- rbase.copy_from(rbufcopy, None, xdest, ydest);
-
-
-
-## Display it with PIL
-s = buffer.to_string()
-print len(s)
-import Image
-im = Image.fromstring( "RGBA", (width, height), s)
-im.show()
-
-
-
-
Deleted: trunk/matplotlib/examples/clippath_test.py
===================================================================
--- trunk/matplotlib/examples/clippath_test.py 2008-05-15 19:25:14 UTC (rev 5143)
+++ trunk/matplotlib/examples/clippath_test.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -1,56 +0,0 @@
-from matplotlib.pyplot import figure, show
-import matplotlib.transforms as transforms
-from matplotlib.patches import RegularPolygon
-import matplotlib.agg as agg
-from numpy import arange, sin, pi
-from numpy.random import rand
-
-class ClipWindow:
- def __init__(self, ax, line):
- self.ax = ax
- ax.set_title('drag polygon around to test clipping')
- self.canvas = ax.figure.canvas
- self.line = line
- self.poly = RegularPolygon(
- (200, 200), numVertices=10, radius=100,
- facecolor='yellow', alpha=0.25,
- transform=transforms.IdentityTransform())
-
- ax.add_patch(self.poly)
- self.canvas.mpl_connect('button_press_event', self.onpress)
- self.canvas.mpl_connect('button_release_event', self.onrelease)
- self.canvas.mpl_connect('motion_notify_event', self.onmove)
- self.x, self.y = None, None
-
- def onpress(self, event):
- self.x, self.y = event.x, event.y
-
- def onrelease(self, event):
- self.x, self.y = None, None
-
- def onmove(self, event):
-
- if self.x is None: return
- dx = event.x - self.x
- dy = event.y - self.y
- self.x, self.y = event.x, event.y
- x, y = self.poly.xy
- x += dx
- y += dy
- #print self.y, event.y, dy, y
- self.poly.xy = x,y
- self._clip()
-
- def _clip(self):
- self.line.set_clip_path(self.poly.get_path(), self.poly.get_transform())
- self.canvas.draw_idle()
-
-
-fig = figure(figsize=(8,8))
-ax = fig.add_subplot(111)
-t = arange(0.0, 4.0, 0.01)
-s = 2*sin(2*pi*8*t)
-
-line, = ax.plot(t, 2*(rand(len(t))-0.5), 'b-')
-clipwin = ClipWindow(ax, line)
-show()
Added: trunk/matplotlib/examples/cold_storage/README
===================================================================
--- trunk/matplotlib/examples/cold_storage/README (rev 0)
+++ trunk/matplotlib/examples/cold_storage/README 2008-05-16 12:50:00 UTC (rev 5144)
@@ -0,0 +1,4 @@
+These are old examples that are now derecated and most likely
+non-functional but we are keeping them around in case we want to
+resurrect them on day. You can safely ignore them.
+
Copied: trunk/matplotlib/examples/cold_storage/agg_resize.py (from rev 5143, trunk/matplotlib/examples/agg_resize.py)
===================================================================
--- trunk/matplotlib/examples/cold_storage/agg_resize.py (rev 0)
+++ trunk/matplotlib/examples/cold_storage/agg_resize.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -0,0 +1,7 @@
+# test the resizing methods in the agg wrapper
+
+import matplotlib.agg as agg
+
+
+imMatrix = agg.trans_affine(1,0,0,1,0,0)
+interp = agg.span_interpolator_linear(imMatrix);
Copied: trunk/matplotlib/examples/cold_storage/agg_test.py (from rev 5143, trunk/matplotlib/examples/agg_test.py)
===================================================================
--- trunk/matplotlib/examples/cold_storage/agg_test.py (rev 0)
+++ trunk/matplotlib/examples/cold_storage/agg_test.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -0,0 +1,154 @@
+# this example uses the agg python module directly there is no
+# documentation -- you have to know how to use the agg c++ API to use
+# it
+import matplotlib.agg as agg
+from math import pi
+
+## Define some colors
+red = agg.rgba8(255,0,0,255)
+blue = agg.rgba8(0,0,255,255)
+green = agg.rgba8(0,255,0,255)
+black = agg.rgba8(0,0,0,255)
+white = agg.rgba8(255,255,255,255)
+yellow = agg.rgba8(192,192,255,255)
+
+## Create the rendering buffer, rasterizer, etc
+width, height = 600,400
+stride = width*4
+buffer = agg.buffer(width, height, stride)
+
+rbuf = agg.rendering_buffer()
+rbuf.attachb(buffer)
+
+pf = agg.pixel_format_rgba(rbuf)
+rbase = agg.renderer_base_rgba(pf)
+rbase.clear_rgba8(blue)
+
+renderer = agg.renderer_scanline_aa_solid_rgba(rbase);
+renderer.color_rgba8( red )
+rasterizer = agg.rasterizer_scanline_aa()
+scanline = agg.scanline_p8()
+
+## A polygon path
+path = agg.path_storage()
+path.move_to(10,10)
+path.line_to(100,100)
+path.line_to(200,200)
+path.line_to(100,200)
+path.close_polygon()
+
+# stroke it
+stroke = agg.conv_stroke_path(path)
+stroke.width(3.0)
+rasterizer.add_path(stroke)
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+## A curved path
+path = agg.path_storage()
+path.move_to(200,10)
+path.line_to(350,50)
+path.curve3(150,200)
+path.curve3(100,70)
+path.close_polygon()
+curve = agg.conv_curve_path(path)
+
+# fill it
+rasterizer.add_path(curve)
+renderer.color_rgba8( green )
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+# and stroke it
+stroke = agg.conv_stroke_curve(curve)
+stroke.width(5.0)
+rasterizer.add_path(stroke)
+renderer.color_rgba8( yellow )
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+## Transforming a path
+path = agg.path_storage()
+path.move_to(0,0)
+path.line_to(1,0)
+path.line_to(1,1)
+path.line_to(0,1)
+path.close_polygon()
+
+rotation = agg.trans_affine_rotation(pi/4)
+scaling = agg.trans_affine_scaling(30,30)
+translation = agg.trans_affine_translation(300,300)
+trans = rotation*scaling*translation
+
+transpath = agg.conv_transform_path(path, trans)
+stroke = agg.conv_stroke_transpath(transpath)
+stroke.width(2.0)
+rasterizer.add_path(stroke)
+renderer.color_rgba8( black )
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+## Converting a transformed path to a curve
+path = agg.path_storage()
+path.move_to(0,0)
+path.curve3(1,0)
+path.curve3(1,1)
+path.curve3(0,1)
+path.close_polygon()
+
+rotation = agg.trans_affine_rotation(pi/4)
+scaling = agg.trans_affine_scaling(30,30)
+translation = agg.trans_affine_translation(300,250)
+trans = rotation*scaling*translation
+trans.flip_y()
+
+transpath = agg.conv_transform_path(path, trans)
+curvetrans = agg.conv_curve_trans(transpath)
+stroke = agg.conv_stroke_curvetrans(curvetrans)
+stroke.width(2.0)
+rasterizer.add_path(stroke)
+renderer.color_rgba8( white )
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+if 0:
+ ## Copy a rectangle from the buffer the rectangle defined by
+ ## x0,y0->x1,y1 and paste it at xdest, ydest
+ x0, y0 = 10, 50
+ x1, y1 = 110, 190
+ xdest, ydest = 350, 200
+
+
+
+ widthr, heightr = x1-x0, y1-y0
+ strider = widthr*4
+ copybuffer = agg.buffer(widthr, heightr, strider)
+
+
+ rbufcopy = agg.rendering_buffer()
+ rbufcopy.attachb(copybuffer)
+ pfcopy = agg.pixel_format_rgba(rbufcopy)
+ rbasecopy = agg.renderer_base_rgba(pfcopy)
+
+ rect = agg.rect(x0, y0, x1, y1)
+ print rect.is_valid()
+ rectp = agg.rectPtr(rect)
+ #print dir(rbasecopy)
+
+ # agg is funny about the arguments to copy from; the last 2 args are
+ # dx, dy. If the src and dest buffers are the same size and you omit
+ # the dx and dy args, the position of the copy in the dest buffer is
+ # the same as in the src. Since our dest buffer is smaller than our
+ # src buffer, we have to offset the location by -x0, -y0
+ rbasecopy.copy_from(rbuf, rect, -x0, -y0);
+
+ # paste the rectangle at a new location xdest, ydest
+ rbase.copy_from(rbufcopy, None, xdest, ydest);
+
+
+
+## Display it with PIL
+s = buffer.to_string()
+print len(s)
+import Image
+im = Image.fromstring( "RGBA", (width, height), s)
+im.show()
+
+
+
+
Copied: trunk/matplotlib/examples/cold_storage/clippath_test.py (from rev 5143, trunk/matplotlib/examples/clippath_test.py)
===================================================================
--- trunk/matplotlib/examples/cold_storage/clippath_test.py (rev 0)
+++ trunk/matplotlib/examples/cold_storage/clippath_test.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -0,0 +1,56 @@
+from matplotlib.pyplot import figure, show
+import matplotlib.transforms as transforms
+from matplotlib.patches import RegularPolygon
+import matplotlib.agg as agg
+from numpy import arange, sin, pi
+from numpy.random import rand
+
+class ClipWindow:
+ def __init__(self, ax, line):
+ self.ax = ax
+ ax.set_title('drag polygon around to test clipping')
+ self.canvas = ax.figure.canvas
+ self.line = line
+ self.poly = RegularPolygon(
+ (200, 200), numVertices=10, radius=100,
+ facecolor='yellow', alpha=0.25,
+ transform=transforms.IdentityTransform())
+
+ ax.add_patch(self.poly)
+ self.canvas.mpl_connect('button_press_event', self.onpress)
+ self.canvas.mpl_connect('button_release_event', self.onrelease)
+ self.canvas.mpl_connect('motion_notify_event', self.onmove)
+ self.x, self.y = None, None
+
+ def onpress(self, event):
+ self.x, self.y = event.x, event.y
+
+ def onrelease(self, event):
+ self.x, self.y = None, None
+
+ def onmove(self, event):
+
+ if self.x is None: return
+ dx = event.x - self.x
+ dy = event.y - self.y
+ self.x, self.y = event.x, event.y
+ x, y = self.poly.xy
+ x += dx
+ y += dy
+ #print self.y, event.y, dy, y
+ self.poly.xy = x,y
+ self._clip()
+
+ def _clip(self):
+ self.line.set_clip_path(self.poly.get_path(), self.poly.get_transform())
+ self.canvas.draw_idle()
+
+
+fig = figure(figsize=(8,8))
+ax = fig.add_subplot(111)
+t = arange(0.0, 4.0, 0.01)
+s = 2*sin(2*pi*8*t)
+
+line, = ax.plot(t, 2*(rand(len(t))-0.5), 'b-')
+clipwin = ClipWindow(ax, line)
+show()
Copied: trunk/matplotlib/examples/cold_storage/glyph_to_path.py (from rev 5143, trunk/matplotlib/examples/glyph_to_path.py)
===================================================================
--- trunk/matplotlib/examples/cold_storage/glyph_to_path.py (rev 0)
+++ trunk/matplotlib/examples/cold_storage/glyph_to_path.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -0,0 +1,84 @@
+import os
+import matplotlib
+from matplotlib.ft2font import FT2Font
+import matplotlib.agg as agg
+
+MOVETO, LINETO, CURVE3, CURVE4, ENDPOLY = range(5)
+
+def glyph_to_agg_path(glyph):
+ path = agg.path_storage()
+ for tup in glyph.path:
+ print tup
+ code = tup[0]
+ if code == MOVETO:
+ x,y = tup[1:]
+ path.move_to(x,y)
+ elif code == LINETO:
+ x,y = tup[1:]
+ path.line_to(x,y)
+ elif code == CURVE3:
+ xctl, yctl, xto, yto= tup[1:]
+ path.curve3(xctl, yctl, xto, yto)
+
+ elif code == CURVE4:
+ xctl1, yctl1, xctl2, yctl2, xto, yto= tup[1:]
+ path.curve4(xctl1, yct1, xctl2, yctl2, xto, yto)
+ elif code == ENDPOLY:
+ path.end_poly()
+
+ return path
+
+width, height = 300,300
+fname = os.path.join(matplotlib.get_data_path(), 'fonts/ttf/Vera.ttf')
+font = FT2Font(fname)
+glyph = font.load_char(ord('y'))
+path = glyph_to_agg_path(glyph)
+
+curve = agg.conv_curve_path(path)
+
+
+scaling = agg.trans_affine_scaling(20,20)
+translation = agg.trans_affine_translation(4,4)
+rotation = agg.trans_affine_rotation(3.1415926)
+mtrans = translation*scaling # cannot use this as a temporary
+tpath = agg.conv_transform_path(path, mtrans)
+
+curve = agg.conv_curve_trans(tpath)
+
+stride = width*4
+buffer = agg.buffer(width, height, stride)
+
+rbuf = agg.rendering_buffer()
+rbuf.attachb(buffer)
+
+red = agg.rgba8(255,0,0,255)
+blue = agg.rgba8(0,0,255,255)
+white = agg.rgba8(255,255,255,255)
+
+pf = agg.pixel_format_rgba(rbuf)
+rbase = agg.renderer_base_rgba(pf)
+rbase.clear_rgba8(white)
+
+renderer = agg.renderer_scanline_aa_solid_rgba(rbase);
+
+
+rasterizer = agg.rasterizer_scanline_aa()
+scanline = agg.scanline_p8()
+
+# first fill
+rasterizer.add_path(curve)
+renderer.color_rgba8(blue)
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+# then stroke
+stroke = agg.conv_stroke_curvetrans(curve)
+stroke.width(2.0)
+renderer.color_rgba8( red )
+rasterizer.add_path(stroke)
+agg.render_scanlines_rgba(rasterizer, scanline, renderer);
+
+s = buffer.to_string()
+import Image
+im = Image.fromstring( "RGBA", (width, height), s)
+im.show()
+
Deleted: trunk/matplotlib/examples/glyph_to_path.py
===================================================================
--- trunk/matplotlib/examples/glyph_to_path.py 2008-05-15 19:25:14 UTC (rev 5143)
+++ trunk/matplotlib/examples/glyph_to_path.py 2008-05-16 12:50:00 UTC (rev 5144)
@@ -1,84 +0,0 @@
-import os
-import matplotlib
-from matplotlib.ft2font import FT2Font
-import matplotlib.agg as agg
-
-MOVETO, LINETO, CURVE3, CURVE4, ENDPOLY = range(5)
-
-def glyph_to_agg_path(glyph):
- path = agg.path_storage()
- for tup in glyph.path:
- print tup
- code = tup[0]
- if code == MOVETO:
- x,y = tup[1:]
- path.move_to(x,y)
- elif code == LINETO:
- x,y = tup[1:]
- path.line_to(x,y)
- elif code == CURVE3:
- xctl, yctl, xto, yto= tup[1:]
- path.curve3(xctl, yctl, xto, yto)
-
- elif code == CURVE4:
- xctl1, yctl1, xctl2, yctl2, xto, yto= tup[1:]
- path.curve4(xctl1, yct1, xctl2, yctl2, xto, yto)
- elif code == ENDPOLY:
- path.end_poly()
-
- return path
-
-width, height = 300,300
-fname = os.path.join(matplotlib.get_data_path(), 'fonts/ttf/Vera.ttf')
-font = FT2Font(fname)
-glyph = font.load_char(ord('y'))
-path = glyph_to_agg_path(glyph)
-
-curve = agg.conv_curve_path(path)
-
-
-scaling = agg.trans_affine_scaling(20,20)
-translation = agg.trans_affine_translation(4,4)
-rotation = agg.trans_affine_rotation(3.1415926)
-mtrans = translation*scaling # cannot use this as a temporary
-tpath = agg.conv_transform_path(path, mtrans)
-
-curve = agg.conv_curve_trans(tpath)
-
-stride = width*4
-buffer = agg.buffer(width, height, stride)
-
-rbuf = agg.rendering_buffer()
-rbuf.attachb(buffer)
-
-red = agg.rgba8(255,0,0,255)
-blue = agg.rgba8(0,0,255,255)
-white = agg.rgba8(255,255,255,255)
-
-pf = agg.pixel_format_rgba(rbuf)
-rbase = agg.renderer_base_rgba(pf)
-rbase.clear_rgba8(white)
-
-renderer = agg.renderer_scanline_aa_solid_rgba(rbase);
-
-
-rasterizer = agg.rasterizer_scanline_aa()
-scanline = agg.scanline_p8()
-
-# first fill
-rasterizer.add_path(curve)
-renderer.color_rgba8(blue)
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-# then stroke
-stroke = agg.conv_stroke_curvetrans(curve)
-stroke.width(2.0)
-renderer.color_rgba8( red )
-rasterizer.add_path(stroke)
-agg.render_scanlines_rgba(rasterizer, scanline, renderer);
-
-s = buffer.to_string()
-import Image
-im = Image.fromstring( "RGBA", (width, height), s)
-im.show()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-16 19:48:10
|
Revision: 5151
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5151&view=rev
Author: jdh2358
Date: 2008-05-16 12:47:10 -0700 (Fri, 16 May 2008)
Log Message:
-----------
reorganized examples
Added Paths:
-----------
trunk/matplotlib/examples/animation/
trunk/matplotlib/examples/animation/animation_blit.py
trunk/matplotlib/examples/animation/animation_blit_fltk.py
trunk/matplotlib/examples/animation/animation_blit_qt.py
trunk/matplotlib/examples/animation/animation_blit_qt4.py
trunk/matplotlib/examples/animation/animation_blit_tk.py
trunk/matplotlib/examples/animation/animation_blit_wx.py
trunk/matplotlib/examples/animation/dynamic_collection.py
trunk/matplotlib/examples/animation/dynamic_demo_wx.py
trunk/matplotlib/examples/animation/dynamic_image_wxagg.py
trunk/matplotlib/examples/animation/dynamic_image_wxagg2.py
trunk/matplotlib/examples/event_handling/
trunk/matplotlib/examples/event_handling/lasso_demo.py
trunk/matplotlib/examples/event_handling/pick_event_demo.py
trunk/matplotlib/examples/event_handling/zoom_window.py
trunk/matplotlib/examples/misc/
trunk/matplotlib/examples/misc/font_indexing.py
trunk/matplotlib/examples/misc/ftface_props.py
trunk/matplotlib/examples/misc/rc_traits.py
trunk/matplotlib/examples/misc/rec_groupby_demo.py
trunk/matplotlib/examples/misc/rec_join_demo.py
trunk/matplotlib/examples/pylab/
trunk/matplotlib/examples/pylab/README
trunk/matplotlib/examples/pylab/__init__.py
trunk/matplotlib/examples/pylab/accented_text.py
trunk/matplotlib/examples/pylab/agg_buffer_to_array.py
trunk/matplotlib/examples/pylab/agg_oo.py
trunk/matplotlib/examples/pylab/alignment_test.py
trunk/matplotlib/examples/pylab/anim.py
trunk/matplotlib/examples/pylab/annotation_demo.py
trunk/matplotlib/examples/pylab/anscombe.py
trunk/matplotlib/examples/pylab/arctest.py
trunk/matplotlib/examples/pylab/arrow_demo.py
trunk/matplotlib/examples/pylab/auto_layout.py
trunk/matplotlib/examples/pylab/axes_demo.py
trunk/matplotlib/examples/pylab/axes_props.py
trunk/matplotlib/examples/pylab/axhspan_demo.py
trunk/matplotlib/examples/pylab/axis_equal_demo.py
trunk/matplotlib/examples/pylab/backend_driver.py
trunk/matplotlib/examples/pylab/bar_stacked.py
trunk/matplotlib/examples/pylab/barchart_demo.py
trunk/matplotlib/examples/pylab/barcode_demo.py
trunk/matplotlib/examples/pylab/barh_demo.py
trunk/matplotlib/examples/pylab/boxplot_demo.py
trunk/matplotlib/examples/pylab/break.py
trunk/matplotlib/examples/pylab/broken_barh.py
trunk/matplotlib/examples/pylab/clippedline.py
trunk/matplotlib/examples/pylab/cohere_demo.py
trunk/matplotlib/examples/pylab/color_by_yvalue.py
trunk/matplotlib/examples/pylab/color_demo.py
trunk/matplotlib/examples/pylab/colours.py
trunk/matplotlib/examples/pylab/contour_demo.py
trunk/matplotlib/examples/pylab/contour_image.py
trunk/matplotlib/examples/pylab/contourf_demo.py
trunk/matplotlib/examples/pylab/contourf_log.py
trunk/matplotlib/examples/pylab/coords_demo.py
trunk/matplotlib/examples/pylab/coords_report.py
trunk/matplotlib/examples/pylab/csd_demo.py
trunk/matplotlib/examples/pylab/cursor_demo.py
trunk/matplotlib/examples/pylab/custom_figure_class.py
trunk/matplotlib/examples/pylab/custom_projection_example.py
trunk/matplotlib/examples/pylab/custom_scale_example.py
trunk/matplotlib/examples/pylab/custom_ticker1.py
trunk/matplotlib/examples/pylab/customize_rc.py
trunk/matplotlib/examples/pylab/dannys_example.py
trunk/matplotlib/examples/pylab/dash_control.py
trunk/matplotlib/examples/pylab/dashpointlabel.py
trunk/matplotlib/examples/pylab/dashtick.py
trunk/matplotlib/examples/pylab/data_browser.py
trunk/matplotlib/examples/pylab/data_helper.py
trunk/matplotlib/examples/pylab/date_demo1.py
trunk/matplotlib/examples/pylab/date_demo2.py
trunk/matplotlib/examples/pylab/date_demo_convert.py
trunk/matplotlib/examples/pylab/date_demo_rrule.py
trunk/matplotlib/examples/pylab/date_index_formatter.py
trunk/matplotlib/examples/pylab/dynamic_demo.py
trunk/matplotlib/examples/pylab/dynamic_image_gtkagg.py
trunk/matplotlib/examples/pylab/ellipse_demo.py
trunk/matplotlib/examples/pylab/ellipse_rotated.py
trunk/matplotlib/examples/pylab/equal_aspect_ratio.py
trunk/matplotlib/examples/pylab/errorbar_demo.py
trunk/matplotlib/examples/pylab/errorbar_limits.py
trunk/matplotlib/examples/pylab/figimage_demo.py
trunk/matplotlib/examples/pylab/figlegend_demo.py
trunk/matplotlib/examples/pylab/figtext.py
trunk/matplotlib/examples/pylab/fill_between.py
trunk/matplotlib/examples/pylab/fill_between_posneg.py
trunk/matplotlib/examples/pylab/fill_demo.py
trunk/matplotlib/examples/pylab/fill_demo2.py
trunk/matplotlib/examples/pylab/fill_spiral.py
trunk/matplotlib/examples/pylab/finance_demo.py
trunk/matplotlib/examples/pylab/font_table_ttf.py
trunk/matplotlib/examples/pylab/fonts_demo.py
trunk/matplotlib/examples/pylab/fonts_demo_kw.py
trunk/matplotlib/examples/pylab/ganged_plots.py
trunk/matplotlib/examples/pylab/geo_demo.py
trunk/matplotlib/examples/pylab/ginput_demo.py
trunk/matplotlib/examples/pylab/gradient_bar.py
trunk/matplotlib/examples/pylab/hatch_demo.py
trunk/matplotlib/examples/pylab/hexbin_demo.py
trunk/matplotlib/examples/pylab/hist_colormapped.py
trunk/matplotlib/examples/pylab/histogram_demo.py
trunk/matplotlib/examples/pylab/hline_demo.py
trunk/matplotlib/examples/pylab/image_demo.py
trunk/matplotlib/examples/pylab/image_demo2.py
trunk/matplotlib/examples/pylab/image_demo3.py
trunk/matplotlib/examples/pylab/image_interp.py
trunk/matplotlib/examples/pylab/image_masked.py
trunk/matplotlib/examples/pylab/image_origin.py
trunk/matplotlib/examples/pylab/image_slices_viewer.py
trunk/matplotlib/examples/pylab/integral_demo.py
trunk/matplotlib/examples/pylab/interactive.py
trunk/matplotlib/examples/pylab/interactive2.py
trunk/matplotlib/examples/pylab/interp_demo.py
trunk/matplotlib/examples/pylab/invert_axes.py
trunk/matplotlib/examples/pylab/keypress_demo.py
trunk/matplotlib/examples/pylab/layer_images.py
trunk/matplotlib/examples/pylab/legend_auto.py
trunk/matplotlib/examples/pylab/legend_demo.py
trunk/matplotlib/examples/pylab/legend_demo2.py
trunk/matplotlib/examples/pylab/legend_scatter.py
trunk/matplotlib/examples/pylab/line_collection.py
trunk/matplotlib/examples/pylab/line_collection2.py
trunk/matplotlib/examples/pylab/line_styles.py
trunk/matplotlib/examples/pylab/lineprops_dialog_gtk.py
trunk/matplotlib/examples/pylab/load_converter.py
trunk/matplotlib/examples/pylab/loadrec.py
trunk/matplotlib/examples/pylab/log_bar.py
trunk/matplotlib/examples/pylab/log_demo.py
trunk/matplotlib/examples/pylab/log_test.py
trunk/matplotlib/examples/pylab/logo.py
trunk/matplotlib/examples/pylab/major_minor_demo1.py
trunk/matplotlib/examples/pylab/major_minor_demo2.py
trunk/matplotlib/examples/pylab/manual_axis.py
trunk/matplotlib/examples/pylab/masked_demo.py
trunk/matplotlib/examples/pylab/mathtext_demo.py
trunk/matplotlib/examples/pylab/mathtext_examples.py
trunk/matplotlib/examples/pylab/matplotlib_icon.py
trunk/matplotlib/examples/pylab/matshow.py
trunk/matplotlib/examples/pylab/movie_demo.py
trunk/matplotlib/examples/pylab/mri_demo.py
trunk/matplotlib/examples/pylab/mri_with_eeg.py
trunk/matplotlib/examples/pylab/multi_image.py
trunk/matplotlib/examples/pylab/multiline.py
trunk/matplotlib/examples/pylab/multiple_figs_demo.py
trunk/matplotlib/examples/pylab/nan_test.py
trunk/matplotlib/examples/pylab/newscalarformatter_demo.py
trunk/matplotlib/examples/pylab/pcolor_demo.py
trunk/matplotlib/examples/pylab/pcolor_demo2.py
trunk/matplotlib/examples/pylab/pcolor_log.py
trunk/matplotlib/examples/pylab/pcolor_nonuniform.py
trunk/matplotlib/examples/pylab/pcolor_small.py
trunk/matplotlib/examples/pylab/pick_event_demo2.py
trunk/matplotlib/examples/pylab/pie_demo.py
trunk/matplotlib/examples/pylab/plotfile_demo.py
trunk/matplotlib/examples/pylab/polar_bar.py
trunk/matplotlib/examples/pylab/polar_demo.py
trunk/matplotlib/examples/pylab/polar_legend.py
trunk/matplotlib/examples/pylab/polar_scatter.py
trunk/matplotlib/examples/pylab/poly_editor.py
trunk/matplotlib/examples/pylab/poormans_contour.py
trunk/matplotlib/examples/pylab/print_stdout.py
trunk/matplotlib/examples/pylab/psd_demo.py
trunk/matplotlib/examples/pylab/pstest.py
trunk/matplotlib/examples/pylab/pylab_with_gtk.py
trunk/matplotlib/examples/pylab/pythonic_matplotlib.py
trunk/matplotlib/examples/pylab/quadmesh_demo.py
trunk/matplotlib/examples/pylab/quiver_demo.py
trunk/matplotlib/examples/pylab/scatter_custom_symbol.py
trunk/matplotlib/examples/pylab/scatter_demo.py
trunk/matplotlib/examples/pylab/scatter_demo2.py
trunk/matplotlib/examples/pylab/scatter_masked.py
trunk/matplotlib/examples/pylab/scatter_profile.py
trunk/matplotlib/examples/pylab/scatter_star_poly.py
trunk/matplotlib/examples/pylab/set_and_get.py
trunk/matplotlib/examples/pylab/shared_axis_across_figures.py
trunk/matplotlib/examples/pylab/shared_axis_demo.py
trunk/matplotlib/examples/pylab/simple3d.py
trunk/matplotlib/examples/pylab/simple_plot.py
trunk/matplotlib/examples/pylab/simple_plot_fps.py
trunk/matplotlib/examples/pylab/specgram_demo.py
trunk/matplotlib/examples/pylab/spy_demos.py
trunk/matplotlib/examples/pylab/stem_plot.py
trunk/matplotlib/examples/pylab/step_demo.py
trunk/matplotlib/examples/pylab/stix_fonts_demo.py
trunk/matplotlib/examples/pylab/stock_demo.py
trunk/matplotlib/examples/pylab/strip_chart_demo.py
trunk/matplotlib/examples/pylab/subplot_demo.py
trunk/matplotlib/examples/pylab/subplot_toolbar.py
trunk/matplotlib/examples/pylab/subplots_adjust.py
trunk/matplotlib/examples/pylab/symlog_demo.py
trunk/matplotlib/examples/pylab/system_monitor.py
trunk/matplotlib/examples/pylab/table_demo.py
trunk/matplotlib/examples/pylab/tex_demo.py
trunk/matplotlib/examples/pylab/tex_unicode_demo.py
trunk/matplotlib/examples/pylab/text_handles.py
trunk/matplotlib/examples/pylab/text_rotation.py
trunk/matplotlib/examples/pylab/text_themes.py
trunk/matplotlib/examples/pylab/to_numeric.py
trunk/matplotlib/examples/pylab/toggle_images.py
trunk/matplotlib/examples/pylab/transoffset.py
trunk/matplotlib/examples/pylab/two_scales.py
trunk/matplotlib/examples/pylab/unicode_demo.py
trunk/matplotlib/examples/pylab/vertical_ticklabels.py
trunk/matplotlib/examples/pylab/vline_demo.py
trunk/matplotlib/examples/pylab/webapp_demo.py
trunk/matplotlib/examples/pylab/xcorr_demo.py
trunk/matplotlib/examples/pylab/zorder_demo.py
trunk/matplotlib/examples/pyplot/
trunk/matplotlib/examples/pyplot/barchart_demo.py
trunk/matplotlib/examples/pyplot/collections_demo.py
trunk/matplotlib/examples/pyplot/colorbar_only.py
trunk/matplotlib/examples/pyplot/date_demo.py
trunk/matplotlib/examples/pyplot/scatter_piecharts.py
trunk/matplotlib/examples/tests/
trunk/matplotlib/examples/user_interfaces/
trunk/matplotlib/examples/user_interfaces/README.wx
trunk/matplotlib/examples/user_interfaces/embedding_in_gtk.py
trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py
trunk/matplotlib/examples/user_interfaces/embedding_in_gtk3.py
trunk/matplotlib/examples/user_interfaces/embedding_in_qt.py
trunk/matplotlib/examples/user_interfaces/embedding_in_qt4.py
trunk/matplotlib/examples/user_interfaces/embedding_in_tk.py
trunk/matplotlib/examples/user_interfaces/embedding_in_tk2.py
trunk/matplotlib/examples/user_interfaces/embedding_in_wx.py
trunk/matplotlib/examples/user_interfaces/embedding_in_wx2.py
trunk/matplotlib/examples/user_interfaces/embedding_in_wx3.py
trunk/matplotlib/examples/user_interfaces/embedding_in_wx4.py
trunk/matplotlib/examples/user_interfaces/gtk_spreadsheet.py
trunk/matplotlib/examples/user_interfaces/histogram_demo_canvasagg.py
trunk/matplotlib/examples/user_interfaces/mathtext_wx.py
trunk/matplotlib/examples/user_interfaces/mpl_with_glade.glade
trunk/matplotlib/examples/user_interfaces/mpl_with_glade.py
trunk/matplotlib/examples/user_interfaces/printing_in_wx.py
trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_custom.py
trunk/matplotlib/examples/user_interfaces/rec_edit_gtk_simple.py
trunk/matplotlib/examples/user_interfaces/simple3d_oo.py
trunk/matplotlib/examples/user_interfaces/wxcursor_demo.py
Removed Paths:
-------------
trunk/matplotlib/examples/README
trunk/matplotlib/examples/README.wx
trunk/matplotlib/examples/__init__.py
trunk/matplotlib/examples/accented_text.py
trunk/matplotlib/examples/agg_buffer_to_array.py
trunk/matplotlib/examples/agg_oo.py
trunk/matplotlib/examples/alignment_test.py
trunk/matplotlib/examples/anim.py
trunk/matplotlib/examples/animation_blit.py
trunk/matplotlib/examples/animation_blit_fltk.py
trunk/matplotlib/examples/animation_blit_qt.py
trunk/matplotlib/examples/animation_blit_qt4.py
trunk/matplotlib/examples/animation_blit_tk.py
trunk/matplotlib/examples/animation_blit_wx.py
trunk/matplotlib/examples/annotation_demo.py
trunk/matplotlib/examples/anscombe.py
trunk/matplotlib/examples/arctest.py
trunk/matplotlib/examples/arrow_demo.py
trunk/matplotlib/examples/auto_layout.py
trunk/matplotlib/examples/axes_demo.py
trunk/matplotlib/examples/axes_props.py
trunk/matplotlib/examples/axhspan_demo.py
trunk/matplotlib/examples/axis_equal_demo.py
trunk/matplotlib/examples/backend_driver.py
trunk/matplotlib/examples/bar_stacked.py
trunk/matplotlib/examples/barchart_demo.py
trunk/matplotlib/examples/barcode_demo.py
trunk/matplotlib/examples/barh_demo.py
trunk/matplotlib/examples/boxplot_demo.py
trunk/matplotlib/examples/break.py
trunk/matplotlib/examples/broken_barh.py
trunk/matplotlib/examples/clippedline.py
trunk/matplotlib/examples/cohere_demo.py
trunk/matplotlib/examples/collections_demo.py
trunk/matplotlib/examples/color_by_yvalue.py
trunk/matplotlib/examples/color_demo.py
trunk/matplotlib/examples/colorbar_only.py
trunk/matplotlib/examples/colours.py
trunk/matplotlib/examples/contour_demo.py
trunk/matplotlib/examples/contour_image.py
trunk/matplotlib/examples/contourf_demo.py
trunk/matplotlib/examples/contourf_log.py
trunk/matplotlib/examples/coords_demo.py
trunk/matplotlib/examples/coords_report.py
trunk/matplotlib/examples/csd_demo.py
trunk/matplotlib/examples/cursor_demo.py
trunk/matplotlib/examples/custom_figure_class.py
trunk/matplotlib/examples/custom_projection_example.py
trunk/matplotlib/examples/custom_scale_example.py
trunk/matplotlib/examples/custom_ticker1.py
trunk/matplotlib/examples/customize_rc.py
trunk/matplotlib/examples/dannys_example.py
trunk/matplotlib/examples/dash_control.py
trunk/matplotlib/examples/dashpointlabel.py
trunk/matplotlib/examples/dashtick.py
trunk/matplotlib/examples/data_browser.py
trunk/matplotlib/examples/data_helper.py
trunk/matplotlib/examples/date_demo.py
trunk/matplotlib/examples/date_demo1.py
trunk/matplotlib/examples/date_demo2.py
trunk/matplotlib/examples/date_demo_convert.py
trunk/matplotlib/examples/date_demo_rrule.py
trunk/matplotlib/examples/date_index_formatter.py
trunk/matplotlib/examples/dynamic_collection.py
trunk/matplotlib/examples/dynamic_demo.py
trunk/matplotlib/examples/dynamic_demo_wx.py
trunk/matplotlib/examples/dynamic_image_gtkagg.py
trunk/matplotlib/examples/dynamic_image_wxagg.py
trunk/matplotlib/examples/dynamic_image_wxagg2.py
trunk/matplotlib/examples/ellipse_demo.py
trunk/matplotlib/examples/ellipse_rotated.py
trunk/matplotlib/examples/embedding_in_gtk.py
trunk/matplotlib/examples/embedding_in_gtk2.py
trunk/matplotlib/examples/embedding_in_gtk3.py
trunk/matplotlib/examples/embedding_in_qt.py
trunk/matplotlib/examples/embedding_in_qt4.py
trunk/matplotlib/examples/embedding_in_tk.py
trunk/matplotlib/examples/embedding_in_tk2.py
trunk/matplotlib/examples/embedding_in_wx.py
trunk/matplotlib/examples/embedding_in_wx2.py
trunk/matplotlib/examples/embedding_in_wx3.py
trunk/matplotlib/examples/embedding_in_wx4.py
trunk/matplotlib/examples/equal_aspect_ratio.py
trunk/matplotlib/examples/errorbar_demo.py
trunk/matplotlib/examples/errorbar_limits.py
trunk/matplotlib/examples/figimage_demo.py
trunk/matplotlib/examples/figlegend_demo.py
trunk/matplotlib/examples/figtext.py
trunk/matplotlib/examples/fill_between.py
trunk/matplotlib/examples/fill_between_posneg.py
trunk/matplotlib/examples/fill_demo.py
trunk/matplotlib/examples/fill_demo2.py
trunk/matplotlib/examples/fill_spiral.py
trunk/matplotlib/examples/finance_demo.py
trunk/matplotlib/examples/font_indexing.py
trunk/matplotlib/examples/font_table_ttf.py
trunk/matplotlib/examples/fonts_demo.py
trunk/matplotlib/examples/fonts_demo_kw.py
trunk/matplotlib/examples/ftface_props.py
trunk/matplotlib/examples/ganged_plots.py
trunk/matplotlib/examples/geo_demo.py
trunk/matplotlib/examples/ginput_demo.py
trunk/matplotlib/examples/gradient_bar.py
trunk/matplotlib/examples/gtk_spreadsheet.py
trunk/matplotlib/examples/hatch_demo.py
trunk/matplotlib/examples/hexbin_demo.py
trunk/matplotlib/examples/hist_colormapped.py
trunk/matplotlib/examples/histogram_demo.py
trunk/matplotlib/examples/histogram_demo_canvasagg.py
trunk/matplotlib/examples/hline_demo.py
trunk/matplotlib/examples/image_demo.py
trunk/matplotlib/examples/image_demo2.py
trunk/matplotlib/examples/image_demo3.py
trunk/matplotlib/examples/image_interp.py
trunk/matplotlib/examples/image_masked.py
trunk/matplotlib/examples/image_origin.py
trunk/matplotlib/examples/image_slices_viewer.py
trunk/matplotlib/examples/integral_demo.py
trunk/matplotlib/examples/interactive.py
trunk/matplotlib/examples/interactive2.py
trunk/matplotlib/examples/interp_demo.py
trunk/matplotlib/examples/invert_axes.py
trunk/matplotlib/examples/keypress_demo.py
trunk/matplotlib/examples/lasso_demo.py
trunk/matplotlib/examples/layer_images.py
trunk/matplotlib/examples/legend_auto.py
trunk/matplotlib/examples/legend_demo.py
trunk/matplotlib/examples/legend_demo2.py
trunk/matplotlib/examples/legend_scatter.py
trunk/matplotlib/examples/line_collection.py
trunk/matplotlib/examples/line_collection2.py
trunk/matplotlib/examples/line_styles.py
trunk/matplotlib/examples/lineprops_dialog_gtk.py
trunk/matplotlib/examples/load_converter.py
trunk/matplotlib/examples/loadrec.py
trunk/matplotlib/examples/log_bar.py
trunk/matplotlib/examples/log_demo.py
trunk/matplotlib/examples/log_test.py
trunk/matplotlib/examples/logo.py
trunk/matplotlib/examples/major_minor_demo1.py
trunk/matplotlib/examples/major_minor_demo2.py
trunk/matplotlib/examples/manual_axis.py
trunk/matplotlib/examples/masked_demo.py
trunk/matplotlib/examples/mathtext_demo.py
trunk/matplotlib/examples/mathtext_examples.py
trunk/matplotlib/examples/mathtext_wx.py
trunk/matplotlib/examples/matplotlib_icon.py
trunk/matplotlib/examples/matshow.py
trunk/matplotlib/examples/movie_demo.py
trunk/matplotlib/examples/mpl_with_glade.glade
trunk/matplotlib/examples/mpl_with_glade.py
trunk/matplotlib/examples/mri_demo.py
trunk/matplotlib/examples/mri_with_eeg.py
trunk/matplotlib/examples/multi_image.py
trunk/matplotlib/examples/multiline.py
trunk/matplotlib/examples/multiple_figs_demo.py
trunk/matplotlib/examples/nan_test.py
trunk/matplotlib/examples/newscalarformatter_demo.py
trunk/matplotlib/examples/pcolor_demo.py
trunk/matplotlib/examples/pcolor_demo2.py
trunk/matplotlib/examples/pcolor_log.py
trunk/matplotlib/examples/pcolor_nonuniform.py
trunk/matplotlib/examples/pcolor_small.py
trunk/matplotlib/examples/pick_event_demo.py
trunk/matplotlib/examples/pick_event_demo2.py
trunk/matplotlib/examples/pie_demo.py
trunk/matplotlib/examples/plotfile_demo.py
trunk/matplotlib/examples/polar_bar.py
trunk/matplotlib/examples/polar_demo.py
trunk/matplotlib/examples/polar_legend.py
trunk/matplotlib/examples/polar_scatter.py
trunk/matplotlib/examples/poly_editor.py
trunk/matplotlib/examples/poormans_contour.py
trunk/matplotlib/examples/print_stdout.py
trunk/matplotlib/examples/printing_in_wx.py
trunk/matplotlib/examples/psd_demo.py
trunk/matplotlib/examples/pstest.py
trunk/matplotlib/examples/pylab_with_gtk.py
trunk/matplotlib/examples/pythonic_matplotlib.py
trunk/matplotlib/examples/quadmesh_demo.py
trunk/matplotlib/examples/quiver_demo.py
trunk/matplotlib/examples/rc_traits.py
trunk/matplotlib/examples/rec_edit_gtk_custom.py
trunk/matplotlib/examples/rec_edit_gtk_simple.py
trunk/matplotlib/examples/rec_groupby_demo.py
trunk/matplotlib/examples/rec_join_demo.py
trunk/matplotlib/examples/scatter_custom_symbol.py
trunk/matplotlib/examples/scatter_demo.py
trunk/matplotlib/examples/scatter_demo2.py
trunk/matplotlib/examples/scatter_masked.py
trunk/matplotlib/examples/scatter_piecharts.py
trunk/matplotlib/examples/scatter_profile.py
trunk/matplotlib/examples/scatter_star_poly.py
trunk/matplotlib/examples/set_and_get.py
trunk/matplotlib/examples/shared_axis_across_figures.py
trunk/matplotlib/examples/shared_axis_demo.py
trunk/matplotlib/examples/simple3d.py
trunk/matplotlib/examples/simple3d_oo.py
trunk/matplotlib/examples/simple_plot.py
trunk/matplotlib/examples/simple_plot_fps.py
trunk/matplotlib/examples/specgram_demo.py
trunk/matplotlib/examples/spy_demos.py
trunk/matplotlib/examples/stem_plot.py
trunk/matplotlib/examples/step_demo.py
trunk/matplotlib/examples/stix_fonts_demo.py
trunk/matplotlib/examples/stock_demo.py
trunk/matplotlib/examples/strip_chart_demo.py
trunk/matplotlib/examples/subplot_demo.py
trunk/matplotlib/examples/subplot_toolbar.py
trunk/matplotlib/examples/subplots_adjust.py
trunk/matplotlib/examples/symlog_demo.py
trunk/matplotlib/examples/system_monitor.py
trunk/matplotlib/examples/table_demo.py
trunk/matplotlib/examples/tex_demo.py
trunk/matplotlib/examples/tex_unicode_demo.py
trunk/matplotlib/examples/text_handles.py
trunk/matplotlib/examples/text_rotation.py
trunk/matplotlib/examples/text_themes.py
trunk/matplotlib/examples/to_numeric.py
trunk/matplotlib/examples/toggle_images.py
trunk/matplotlib/examples/transoffset.py
trunk/matplotlib/examples/two_scales.py
trunk/matplotlib/examples/unicode_demo.py
trunk/matplotlib/examples/vertical_ticklabels.py
trunk/matplotlib/examples/vline_demo.py
trunk/matplotlib/examples/webapp_demo.py
trunk/matplotlib/examples/wxcursor_demo.py
trunk/matplotlib/examples/xcorr_demo.py
trunk/matplotlib/examples/zoom_window.py
trunk/matplotlib/examples/zorder_demo.py
Deleted: trunk/matplotlib/examples/README
===================================================================
--- trunk/matplotlib/examples/README 2008-05-16 19:20:04 UTC (rev 5150)
+++ trunk/matplotlib/examples/README 2008-05-16 19:47:10 UTC (rev 5151)
@@ -1,24 +0,0 @@
-Here are some demos of how to use the matplotlib.
-
-
--- data_helper.py - a convenience module to load some data from the
- data dir
-
--- embedding_in_gtk - The Figure class derives from gtk.DrawingArea,
- so it is easy to embed in larger applications.
-
--- histograms_gauss.py - 2D histograms; requires the jdh.mlab module
-
--- simple_plot.py - the basic 2D line plot
-
--- subplot_demo.py - how to do multiple axes on a single plot
-
--- vline_demo.py - working with straight lines
-
--- stock_demo.py - working with large datasets. Click on the plot and
- launch the navigation tool; wheel mouse over the navigation
- buttons to scroll and zoom. There are 58 days of minute by
- minute stock quotes for two tickers. The plot lib uses
- Numeric's super speedy searchsorted routine to extract the
- clipping indices so only the data in the viewport are handled.
-
Deleted: trunk/matplotlib/examples/README.wx
===================================================================
--- trunk/matplotlib/examples/README.wx 2008-05-16 19:20:04 UTC (rev 5150)
+++ trunk/matplotlib/examples/README.wx 2008-05-16 19:47:10 UTC (rev 5151)
@@ -1,21 +0,0 @@
-You have a few different options available to you for embedding
-matplotlib in a wxPython application
-
-1. Embed one of the wxPython backend widgets (which subclass wx.Panel)
- directly and draw plots on it using matplotlib's object-oriented
- API. This approach is demonstrated by some of the examples
- embedding_in_wx*.py
-
-2. Embed the PlotPanel from Matt Newville's `MPlot' package and draw
- plots on it using its plot() and oplot() methods.
-
- http://cars9.uchicago.edu/~newville/Python/MPlot/
-
-3. Embed the PlotPanel from Ken McIvor wxmpl module and draw plots on
- it using the matplotlib's object-oriented API.
-
- http://agni.phys.iit.edu/~kmcivor/wxmpl/
-
-Each of these approachs has different benefits and drawbacks, so I
-encourage you to evaluate each of them and select the one that best
-meets your needs.
Deleted: trunk/matplotlib/examples/__init__.py
===================================================================
Deleted: trunk/matplotlib/examples/accented_text.py
===================================================================
--- trunk/matplotlib/examples/accented_text.py 2008-05-16 19:20:04 UTC (rev 5150)
+++ trunk/matplotlib/examples/accented_text.py 2008-05-16 19:47:10 UTC (rev 5151)
@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-"""
-matplotlib supports accented characters via TeX mathtext
-
-The following accents are provided: \hat, \breve, \grave, \bar,
-\acute, \tilde, \vec, \dot, \ddot. All of them have the same syntax,
-eg to make an overbar you do \bar{o} or to make an o umlaut you do
-\ddot{o}. The shortcuts are also provided, eg: \"o \'e \`e \~n \.x
-\^y
-
-"""
-from pylab import *
-
-plot(range(10))
-
-title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}\breve{i}\bar{A}\tilde{n}\vec{q}$', fontsize=20)
-# shorthand is also supported and curly's are optional
-xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20)
-
-
-show()
Deleted: trunk/matplotlib/examples/agg_buffer_to_array.py
===================================================================
--- trunk/matplotlib/examples/agg_buffer_to_array.py 2008-05-16 19:20:04 UTC (rev 5150)
+++ trunk/matplotlib/examples/agg_buffer_to_array.py 2008-05-16 19:47:10 UTC (rev 5151)
@@ -1,24 +0,0 @@
-import matplotlib
-matplotlib.use('Agg')
-from pylab import figure, show
-import numpy as npy
-
-# make an agg figure
-fig = figure()
-ax = fig.add_subplot(111)
-ax.plot([1,2,3])
-ax.set_title('a simple figure')
-fig.canvas.draw()
-
-# grab rhe pixel buffer and dumpy it into a numpy array
-buf = fig.canvas.buffer_rgba(0,0)
-l, b, w, h = fig.bbox.bounds
-X = npy.fromstring(buf, npy.uint8)
-X.shape = h,w,4
-
-# now display the array X as an Axes in a new figure
-fig2 = figure()
-ax2 = fig2.add_subplot(111, frameon=False)
-ax2.imshow(X)
-fig2.savefig('simple.png')
-show()
Deleted: trunk/matplotlib/examples/agg_oo.py
===================================================================
--- trunk/matplotlib/examples/agg_oo.py 2008-05-16 19:20:04 UTC (rev 5150)
+++ trunk/matplotlib/examples/agg_oo.py 2008-05-16 19:47:10 UTC (rev 5151)
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-"""
-A pure OO (look Ma, no pylab!) example using the agg backend
-"""
-from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
-from matplotlib.figure import Figure
-
-fig = Figure()
-canvas = FigureCanvas(fig)
-ax = fig.add_subplot(111)
-ax.plot([1,2,3])
-ax.set_title('hi mom')
-ax.grid(True)
-ax.set_xlabel('time')
-ax.set_ylabel('volts')
-canvas.print_figure('test')
Deleted: trunk/matplotlib/examples/alignment_test.py
===================================================================
--- trunk/matplotlib/examples/alignment_test.py 2008-05-16 19:20:04 UTC (rev 5150)
+++ trunk/matplotlib/examples/alignment_test.py 2008-05-16 19:47:10 UTC (rev 5151)
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-"""
-You can precisely layout text in data or axes (0,1) coordinates. This
-example shows you some of the alignment and rotation specifications to
-layout text
-"""
-
-from pylab import *
-from matplotlib.lines import Line2D
-from matplotlib.patches import Rectangle
-
-# build a rectangle in axes coords
-left, width = .25, .5
-bottom, height = .25, .5
-right = left + width
-top = bottom + height
-ax = gca()
-p = Rectangle((left, bottom), width, height,
- fill=False,
- )
-p.set_transform(ax.transAxes)
-p.set_clip_on(False)
-ax.add_patch(p)
-
-
-ax.text(left, bottom, 'left top',
- horizontalalignment='left',
- verticalalignment='top',
- transform=ax.transAxes)
-
-ax.text(left, bottom, 'left bottom',
- horizontalalignment='left',
- verticalalignment='bottom',
- transform=ax.transAxes)
-
-ax.text(right, top, 'right bottom',
- horizontalalignment='right',
- verticalalignment='bottom',
- transform=ax.transAxes)
-
-ax.text(right, top, 'right top',
- horizontalalignment='right',
- verticalalignment='top',
- transform=ax.transAxes)
-
-ax.text(right, bottom, 'center top',
- horizontalalignment='center',
- verticalalignment='top',
- ...
[truncated message content] |
|
From: <jd...@us...> - 2008-05-16 19:51:42
|
Revision: 5153
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5153&view=rev
Author: jdh2358
Date: 2008-05-16 12:51:33 -0700 (Fri, 16 May 2008)
Log Message:
-----------
renamed pylot to api for examples
Added Paths:
-----------
trunk/matplotlib/examples/api/
trunk/matplotlib/examples/api/agg_oo.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab/agg_oo.py
trunk/matplotlib/examples/pyplot/
Copied: trunk/matplotlib/examples/api (from rev 5151, trunk/matplotlib/examples/pyplot)
Copied: trunk/matplotlib/examples/api/agg_oo.py (from rev 5151, trunk/matplotlib/examples/pylab/agg_oo.py)
===================================================================
--- trunk/matplotlib/examples/api/agg_oo.py (rev 0)
+++ trunk/matplotlib/examples/api/agg_oo.py 2008-05-16 19:51:33 UTC (rev 5153)
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+"""
+A pure OO (look Ma, no pylab!) example using the agg backend
+"""
+from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
+from matplotlib.figure import Figure
+
+fig = Figure()
+canvas = FigureCanvas(fig)
+ax = fig.add_subplot(111)
+ax.plot([1,2,3])
+ax.set_title('hi mom')
+ax.grid(True)
+ax.set_xlabel('time')
+ax.set_ylabel('volts')
+canvas.print_figure('test')
Deleted: trunk/matplotlib/examples/pylab/agg_oo.py
===================================================================
--- trunk/matplotlib/examples/pylab/agg_oo.py 2008-05-16 19:49:55 UTC (rev 5152)
+++ trunk/matplotlib/examples/pylab/agg_oo.py 2008-05-16 19:51:33 UTC (rev 5153)
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-"""
-A pure OO (look Ma, no pylab!) example using the agg backend
-"""
-from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
-from matplotlib.figure import Figure
-
-fig = Figure()
-canvas = FigureCanvas(fig)
-ax = fig.add_subplot(111)
-ax.plot([1,2,3])
-ax.set_title('hi mom')
-ax.grid(True)
-ax.set_xlabel('time')
-ax.set_ylabel('volts')
-canvas.print_figure('test')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-16 20:10:00
|
Revision: 5156
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5156&view=rev
Author: jdh2358
Date: 2008-05-16 13:09:54 -0700 (Fri, 16 May 2008)
Log Message:
-----------
moved new hist examples to pylab
Added Paths:
-----------
trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py
trunk/matplotlib/examples/pylab/histogram_demo_step.py
Removed Paths:
-------------
trunk/matplotlib/examples/histogram_demo_cumulative.py
trunk/matplotlib/examples/histogram_demo_step.py
Deleted: trunk/matplotlib/examples/histogram_demo_cumulative.py
===================================================================
--- trunk/matplotlib/examples/histogram_demo_cumulative.py 2008-05-16 20:09:09 UTC (rev 5155)
+++ trunk/matplotlib/examples/histogram_demo_cumulative.py 2008-05-16 20:09:54 UTC (rev 5156)
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-from pylab import *
-
-mu, sigma = 100, 25
-x = mu + sigma*randn(10000)
-
-# the histogram of the data
-n, bins, patches = hist(x, 50, normed=1, histtype='step', cumulative=True)
-setp(patches, 'facecolor', 'g', 'alpha', 0.75)
-
-# add a 'best fit' line
-y = normpdf( bins, mu, sigma).cumsum()
-y /= y[-1]
-l = plot(bins, y, 'k--', linewidth=1.5)
-
-# overlay the first histogram with a second one
-# were the data has a smaller standard deviation
-mu, sigma = 100, 10
-x = mu + sigma*randn(10000)
-
-n, bins, patches = hist(x, bins=bins, normed=1, histtype='step', cumulative=True)
-setp(patches, 'facecolor', 'r', 'alpha', 0.25)
-
-# add a 'best fit' line
-y = normpdf( bins, mu, sigma).cumsum()
-y /= y[-1]
-l = plot(bins, y, 'k--', linewidth=1.5)
-
-grid(True)
-ylim(0, 1.1)
-
-#savefig('histogram_demo',dpi=72)
-show()
\ No newline at end of file
Deleted: trunk/matplotlib/examples/histogram_demo_step.py
===================================================================
--- trunk/matplotlib/examples/histogram_demo_step.py 2008-05-16 20:09:09 UTC (rev 5155)
+++ trunk/matplotlib/examples/histogram_demo_step.py 2008-05-16 20:09:54 UTC (rev 5156)
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-from pylab import *
-
-mu, sigma = 100, 15
-x = mu + sigma*randn(10000)
-
-# the histogram of the data
-n, bins, patches = hist(x, 50, normed=1, histtype='step')
-setp(patches, 'facecolor', 'g', 'alpha', 0.75)
-
-# add a 'best fit' line
-y = normpdf( bins, mu, sigma)
-l = plot(bins, y, 'k--', linewidth=1)
-
-
-# overlay the first histogram with a second one
-# were the data has a smaller standard deviation
-mu, sigma = 100, 5
-x = mu + sigma*randn(10000)
-
-n, bins, patches = hist(x, 50, normed=1, histtype='step')
-setp(patches, 'facecolor', 'r', 'alpha', 0.25)
-
-y = normpdf( bins, mu, sigma)
-l = plot(bins, y, 'k--', linewidth=1)
-
-axis([40, 160, 0, 0.09])
-grid(True)
-
-#savefig('histogram_demo',dpi=72)
-show()
Copied: trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py (from rev 5154, trunk/matplotlib/examples/histogram_demo_cumulative.py)
===================================================================
--- trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py (rev 0)
+++ trunk/matplotlib/examples/pylab/histogram_demo_cumulative.py 2008-05-16 20:09:54 UTC (rev 5156)
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+from pylab import *
+
+mu, sigma = 100, 25
+x = mu + sigma*randn(10000)
+
+# the histogram of the data
+n, bins, patches = hist(x, 50, normed=1, histtype='step', cumulative=True)
+setp(patches, 'facecolor', 'g', 'alpha', 0.75)
+
+# add a 'best fit' line
+y = normpdf( bins, mu, sigma).cumsum()
+y /= y[-1]
+l = plot(bins, y, 'k--', linewidth=1.5)
+
+# overlay the first histogram with a second one
+# were the data has a smaller standard deviation
+mu, sigma = 100, 10
+x = mu + sigma*randn(10000)
+
+n, bins, patches = hist(x, bins=bins, normed=1, histtype='step', cumulative=True)
+setp(patches, 'facecolor', 'r', 'alpha', 0.25)
+
+# add a 'best fit' line
+y = normpdf( bins, mu, sigma).cumsum()
+y /= y[-1]
+l = plot(bins, y, 'k--', linewidth=1.5)
+
+grid(True)
+ylim(0, 1.1)
+
+#savefig('histogram_demo',dpi=72)
+show()
\ No newline at end of file
Copied: trunk/matplotlib/examples/pylab/histogram_demo_step.py (from rev 5154, trunk/matplotlib/examples/histogram_demo_step.py)
===================================================================
--- trunk/matplotlib/examples/pylab/histogram_demo_step.py (rev 0)
+++ trunk/matplotlib/examples/pylab/histogram_demo_step.py 2008-05-16 20:09:54 UTC (rev 5156)
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+from pylab import *
+
+mu, sigma = 100, 15
+x = mu + sigma*randn(10000)
+
+# the histogram of the data
+n, bins, patches = hist(x, 50, normed=1, histtype='step')
+setp(patches, 'facecolor', 'g', 'alpha', 0.75)
+
+# add a 'best fit' line
+y = normpdf( bins, mu, sigma)
+l = plot(bins, y, 'k--', linewidth=1)
+
+
+# overlay the first histogram with a second one
+# were the data has a smaller standard deviation
+mu, sigma = 100, 5
+x = mu + sigma*randn(10000)
+
+n, bins, patches = hist(x, 50, normed=1, histtype='step')
+setp(patches, 'facecolor', 'r', 'alpha', 0.25)
+
+y = normpdf( bins, mu, sigma)
+l = plot(bins, y, 'k--', linewidth=1)
+
+axis([40, 160, 0, 0.09])
+grid(True)
+
+#savefig('histogram_demo',dpi=72)
+show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-16 20:25:36
|
Revision: 5158
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5158&view=rev
Author: jdh2358
Date: 2008-05-16 13:25:07 -0700 (Fri, 16 May 2008)
Log Message:
-----------
added a few example specific readmes
Added Paths:
-----------
trunk/matplotlib/examples/api/README.txt
trunk/matplotlib/examples/event_handling/README.txt
trunk/matplotlib/examples/user_interfaces/README.txt
Added: trunk/matplotlib/examples/api/README.txt
===================================================================
--- trunk/matplotlib/examples/api/README.txt (rev 0)
+++ trunk/matplotlib/examples/api/README.txt 2008-05-16 20:25:07 UTC (rev 5158)
@@ -0,0 +1,21 @@
+These examples use the matplotlib api rather than the pylab/pyplot
+procedural state machine. For robust, production level scripts, or
+for applications or web application servers, we recommend you use the
+matplotlib API directly as it gives you the maximum control over your
+figures, axes and plottng commands. There are a few documentation
+resources for the API
+
+ - the matplotlib artist tutorial :
+ http://matplotlib.sourceforge.net/pycon/artist_api_tut.pdf
+
+ - the "leftwich tutorial" -
+ http://matplotlib.sourceforge.net/leftwich_tut.txt
+
+ The example agg_oo.py is the simplest example of using the Agg
+ backend which is readily ported to other output formats. This
+ example is a good starting point if your are a web application
+ developer. Many of the other examples in this directory use
+ matplotlib.pyplot just to create the figure and show calls, and use
+ the API for everything else. This is a good solution for production
+ quality scripts. For full fledged GUI applications, see the
+ user_interfaces examples.
Added: trunk/matplotlib/examples/event_handling/README.txt
===================================================================
--- trunk/matplotlib/examples/event_handling/README.txt (rev 0)
+++ trunk/matplotlib/examples/event_handling/README.txt 2008-05-16 20:25:07 UTC (rev 5158)
@@ -0,0 +1,15 @@
+matplotlib supports event handling with a GUI neutral event model. So
+you can connect to matplotlib events w/o knowledge of what user
+interface matplotlib will ultimately be plugged in to. This has two
+advantages: the code you write will be more portable, and matplotlib
+events are aware of things like data coordinate space and whih axes
+the event occurs in so you don't have to mess with low level
+transformation details to go from canvas space to data space. Object
+picking examples are also included.
+
+There is an event handling tutorial at
+http://matplotlib.sourceforge.net/pycon/event_handling_tut.pdf. The
+ReST source for this document is included in the matplotlib source
+distribution.
+
+
Added: trunk/matplotlib/examples/user_interfaces/README.txt
===================================================================
--- trunk/matplotlib/examples/user_interfaces/README.txt (rev 0)
+++ trunk/matplotlib/examples/user_interfaces/README.txt 2008-05-16 20:25:07 UTC (rev 5158)
@@ -0,0 +1,13 @@
+Embedding matplotlib in graphical user interfaces
+=================================================
+
+You can embed matplotlib directly into a user interface application by
+following the embedding_in_SOMEGUI.py examples here. Currently
+matplotlib supports wxpython, pygtk, tkinter, pyqt, fltk and cocoa.
+
+When embedding matplotlib in a GUI, you must use the matplotlib API
+directly rather than the pylab/pyplot proceedural interface, so take a
+look at the examples/api directory for some example code working with
+the API.
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-16 20:32:31
|
Revision: 5159
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5159&view=rev
Author: jdh2358
Date: 2008-05-16 13:32:18 -0700 (Fri, 16 May 2008)
Log Message:
-----------
more example readmes
Modified Paths:
--------------
trunk/matplotlib/examples/api/README.txt
trunk/matplotlib/examples/event_handling/README.txt
Added Paths:
-----------
trunk/matplotlib/examples/animation/README.txt
Added: trunk/matplotlib/examples/animation/README.txt
===================================================================
--- trunk/matplotlib/examples/animation/README.txt (rev 0)
+++ trunk/matplotlib/examples/animation/README.txt 2008-05-16 20:32:18 UTC (rev 5159)
@@ -0,0 +1,7 @@
+matplotlib animations
+=====================
+
+There are a variety of techniques you can use to create dynamic plots,
+which I refer to as animations. See the tutorial at
+http://www.scipy.org/Cookbook/Matplotlib/Animations for an
+introduction to the basic concepts
Modified: trunk/matplotlib/examples/api/README.txt
===================================================================
--- trunk/matplotlib/examples/api/README.txt 2008-05-16 20:25:07 UTC (rev 5158)
+++ trunk/matplotlib/examples/api/README.txt 2008-05-16 20:32:18 UTC (rev 5159)
@@ -1,3 +1,6 @@
+matplotlib API
+==============
+
These examples use the matplotlib api rather than the pylab/pyplot
procedural state machine. For robust, production level scripts, or
for applications or web application servers, we recommend you use the
Modified: trunk/matplotlib/examples/event_handling/README.txt
===================================================================
--- trunk/matplotlib/examples/event_handling/README.txt 2008-05-16 20:25:07 UTC (rev 5158)
+++ trunk/matplotlib/examples/event_handling/README.txt 2008-05-16 20:32:18 UTC (rev 5159)
@@ -1,3 +1,6 @@
+matplotlib event handling
+=========================
+
matplotlib supports event handling with a GUI neutral event model. So
you can connect to matplotlib events w/o knowledge of what user
interface matplotlib will ultimately be plugged in to. This has two
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-16 21:01:55
|
Revision: 5162
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5162&view=rev
Author: jdh2358
Date: 2008-05-16 14:01:39 -0700 (Fri, 16 May 2008)
Log Message:
-----------
minor backend driver cleanup
Modified Paths:
--------------
trunk/matplotlib/examples/pylab/broken_barh.py
trunk/matplotlib/examples/tests/backend_driver.py
Modified: trunk/matplotlib/examples/pylab/broken_barh.py
===================================================================
--- trunk/matplotlib/examples/pylab/broken_barh.py 2008-05-16 20:47:09 UTC (rev 5161)
+++ trunk/matplotlib/examples/pylab/broken_barh.py 2008-05-16 21:01:39 UTC (rev 5162)
@@ -21,5 +21,5 @@
fontsize=16,
horizontalalignment='right', verticalalignment='top')
-fig.savefig('broken_barh', dpi=100)
+#fig.savefig('broken_barh', dpi=100)
show()
Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py 2008-05-16 20:47:09 UTC (rev 5161)
+++ trunk/matplotlib/examples/tests/backend_driver.py 2008-05-16 21:01:39 UTC (rev 5162)
@@ -181,7 +181,7 @@
line_lstrip = line.lstrip()
if (line_lstrip.startswith('from __future__ import division') or
line_lstrip.startswith('matplotlib.use') or
- line_lstrip.startswith('savefig') or
+ line_lstrip.find('savefig')>=0 or
line_lstrip.startswith('show')):
continue
tmpfile.write(line)
@@ -202,6 +202,12 @@
if __name__ == '__main__':
times = {}
default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template']
+ if len(sys.argv)==2 and sys.argv[1]=='--clean':
+ for b in default_backends:
+ # todo: implement python recursive remove
+ os.system('rm -rf %s'%b)
+ print 'all clean...'
+ raise SystemExit
if '--coverage' in sys.argv:
python = ['coverage.py', '-x']
sys.argv.remove('--coverage')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-18 21:06:28
|
Revision: 5187
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5187&view=rev
Author: jdh2358
Date: 2008-05-18 14:06:13 -0700 (Sun, 18 May 2008)
Log Message:
-----------
moved a few more examples to their proper home
Added Paths:
-----------
trunk/matplotlib/examples/animation/anim.py
trunk/matplotlib/examples/animation/dynamic_demo.py
trunk/matplotlib/examples/animation/dynamic_image_gtkagg.py
trunk/matplotlib/examples/animation/strip_chart_demo.py
trunk/matplotlib/examples/event_handling/data_browser.py
trunk/matplotlib/examples/event_handling/keypress_demo.py
trunk/matplotlib/examples/event_handling/pick_event_demo2.py
trunk/matplotlib/examples/event_handling/poly_editor.py
trunk/matplotlib/examples/user_interfaces/interactive.py
trunk/matplotlib/examples/user_interfaces/interactive2.py
trunk/matplotlib/examples/user_interfaces/lineprops_dialog_gtk.py
trunk/matplotlib/examples/user_interfaces/pylab_with_gtk.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab/anim.py
trunk/matplotlib/examples/pylab/data_browser.py
trunk/matplotlib/examples/pylab/dynamic_demo.py
trunk/matplotlib/examples/pylab/dynamic_image_gtkagg.py
trunk/matplotlib/examples/pylab/interactive.py
trunk/matplotlib/examples/pylab/interactive2.py
trunk/matplotlib/examples/pylab/keypress_demo.py
trunk/matplotlib/examples/pylab/lineprops_dialog_gtk.py
trunk/matplotlib/examples/pylab/pick_event_demo2.py
trunk/matplotlib/examples/pylab/poly_editor.py
trunk/matplotlib/examples/pylab/pylab_with_gtk.py
trunk/matplotlib/examples/pylab/strip_chart_demo.py
Copied: trunk/matplotlib/examples/animation/anim.py (from rev 5186, trunk/matplotlib/examples/pylab/anim.py)
===================================================================
--- trunk/matplotlib/examples/animation/anim.py (rev 0)
+++ trunk/matplotlib/examples/animation/anim.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+"""
+A simple example of an animated plot in matplotlib. You can test the
+speed of animation of various backends by running the script with the
+'-dSomeBackend' flag
+
+SC Aug 31 2005 mpl 0.83.2:
+Here are some numbers from my system, where FPS is the frames rendered
+per second
+
+ GTK 29 FPS
+ GTKAgg 18 FPS
+ GTKCairo 15 FPS
+ TkAgg 13 FPS
+ QkAgg 13 FPS
+"""
+import time
+
+import pylab as p
+
+# turn interactive mode on for dynamic updates. If you aren't in
+# interactive mode, you'll need to use a GUI event handler/timer.
+p.ion()
+
+tstart = time.time() # for profiling
+x = p.arange(0, 2*p.pi, 0.01) # x-array
+line, = p.plot(x, p.sin(x))
+for i in p.arange(1,200):
+ line.set_ydata(p.sin(x+i/10.0)) # update the data
+ p.draw() # redraw the canvas
+
+print 'FPS:' , 200/(time.time()-tstart)
Copied: trunk/matplotlib/examples/animation/dynamic_demo.py (from rev 5186, trunk/matplotlib/examples/pylab/dynamic_demo.py)
===================================================================
--- trunk/matplotlib/examples/animation/dynamic_demo.py (rev 0)
+++ trunk/matplotlib/examples/animation/dynamic_demo.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import gobject
+import gtk
+
+from pylab import *
+
+
+fig = figure(1)
+ind = arange(30)
+X = rand(len(ind),10)
+lines = plot(X[:,0], 'o')
+
+manager = get_current_fig_manager()
+def updatefig(*args):
+ lines[0].set_data(ind, X[:,updatefig.count])
+ manager.canvas.draw()
+ updatefig.count += 1
+ if updatefig.count<10:
+ return True
+ else:
+ return False
+
+updatefig.count = 0
+
+gobject.timeout_add(300, updatefig)
+show()
Copied: trunk/matplotlib/examples/animation/dynamic_image_gtkagg.py (from rev 5186, trunk/matplotlib/examples/pylab/dynamic_image_gtkagg.py)
===================================================================
--- trunk/matplotlib/examples/animation/dynamic_image_gtkagg.py (rev 0)
+++ trunk/matplotlib/examples/animation/dynamic_image_gtkagg.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+"""
+An animated image
+"""
+import time
+
+import gobject
+import gtk
+
+import matplotlib
+matplotlib.use('GTKAgg')
+from matplotlib import rcParams
+
+from pylab import *
+
+fig = figure(1)
+a = subplot(111)
+x = arange(120.0)*2*pi/120.0
+x = resize(x, (100,120))
+y = arange(100.0)*2*pi/100.0
+y = resize(y, (120,100))
+y = transpose(y)
+z = sin(x) + cos(y)
+im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest')
+
+manager = get_current_fig_manager()
+cnt = 0
+tstart = time.time()
+def updatefig(*args):
+ global x, y, cnt, start
+ x += pi/15
+ y += pi/20
+ z = sin(x) + cos(y)
+ im.set_array(z)
+ manager.canvas.draw()
+ cnt += 1
+ if cnt==50:
+ print 'FPS', cnt/(time.time() - tstart)
+ return False
+ return True
+
+cnt = 0
+
+gobject.idle_add(updatefig)
+show()
Copied: trunk/matplotlib/examples/animation/strip_chart_demo.py (from rev 5186, trunk/matplotlib/examples/pylab/strip_chart_demo.py)
===================================================================
--- trunk/matplotlib/examples/animation/strip_chart_demo.py (rev 0)
+++ trunk/matplotlib/examples/animation/strip_chart_demo.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,72 @@
+"""
+Emulate an oscilloscope. Requires the animation API introduced in
+matplotlib 0.84. See
+http://www.scipy.org/wikis/topical_software/Animations for an
+explanation.
+
+This example uses gtk but does not depend on it intimately. It just
+uses the idle handler to trigger events. You can plug this into a
+different GUI that supports animation (GTKAgg, TkAgg, WXAgg) and use
+your toolkits idle/timer functions.
+"""
+import gobject, gtk
+import matplotlib
+matplotlib.use('GTKAgg')
+import numpy as np
+from matplotlib.lines import Line2D
+
+
+class Scope:
+ def __init__(self, ax, maxt=10, dt=0.01):
+ self.ax = ax
+ self.canvas = ax.figure.canvas
+ self.dt = dt
+ self.maxt = maxt
+ self.tdata = [0]
+ self.ydata = [0]
+ self.line = Line2D(self.tdata, self.ydata, animated=True)
+ self.ax.add_line(self.line)
+ self.background = None
+ self.canvas.mpl_connect('draw_event', self.update_background)
+ self.ax.set_ylim(-.1, 1.1)
+ self.ax.set_xlim(0, self.maxt)
+
+ def update_background(self, event):
+ self.background = self.canvas.copy_from_bbox(self.ax.bbox)
+
+ def emitter(self, p=0.01):
+ 'return a random value with probability p, else 0'
+ v = np.random.rand(1)
+ if v>p: return 0.
+ else: return np.random.rand(1)
+
+ def update(self, *args):
+ if self.background is None: return True
+ y = self.emitter()
+ lastt = self.tdata[-1]
+ if lastt>self.tdata[0]+self.maxt: # reset the arrays
+ self.tdata = [self.tdata[-1]]
+ self.ydata = [self.ydata[-1]]
+ self.ax.set_xlim(self.tdata[0], self.tdata[0]+self.maxt)
+ self.ax.figure.canvas.draw()
+
+ self.canvas.restore_region(self.background)
+
+ t = self.tdata[-1] + self.dt
+ self.tdata.append(t)
+ self.ydata.append(y)
+ self.line.set_data(self.tdata, self.ydata)
+ self.ax.draw_artist(self.line)
+
+ self.canvas.blit(self.ax.bbox)
+ return True
+
+
+from pylab import figure, show
+
+fig = figure()
+ax = fig.add_subplot(111)
+scope = Scope(ax)
+gobject.idle_add(scope.update)
+
+show()
Copied: trunk/matplotlib/examples/event_handling/data_browser.py (from rev 5186, trunk/matplotlib/examples/pylab/data_browser.py)
===================================================================
--- trunk/matplotlib/examples/event_handling/data_browser.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/data_browser.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,82 @@
+import numpy as np
+from pylab import figure, show
+
+
+X = np.random.rand(100, 200)
+xs = np.mean(X, axis=1)
+ys = np.std(X, axis=1)
+
+fig = figure()
+ax = fig.add_subplot(211)
+ax.set_title('click on point to plot time series')
+line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
+ax2 = fig.add_subplot(212)
+
+class PointBrowser:
+ """
+ Click on a point to select and highlight it -- the data that
+ generated the point will be shown in the lower axes. Use the 'n'
+ and 'p' keys to browse through the next and pervious points
+ """
+ def __init__(self):
+ self.lastind = 0
+
+ self.text = ax.text(0.05, 0.95, 'selected: none',
+ transform=ax.transAxes, va='top')
+ self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
+ color='yellow', visible=False)
+
+ def onpress(self, event):
+ if self.lastind is None: return
+ if event.key not in ('n', 'p'): return
+ if event.key=='n': inc = 1
+ else: inc = -1
+
+
+ self.lastind += inc
+ self.lastind = np.clip(self.lastind, 0, len(xs)-1)
+ self.update()
+
+ def onpick(self, event):
+
+ if event.artist!=line: return True
+
+ N = len(event.ind)
+ if not N: return True
+
+ # the click locations
+ x = event.mouseevent.xdata
+ y = event.mouseevent.ydata
+
+
+ distances = np.hypot(x-xs[event.ind], y-ys[event.ind])
+ indmin = distances.argmin()
+ dataind = event.ind[indmin]
+
+ self.lastind = dataind
+ self.update()
+
+ def update(self):
+ if self.lastind is None: return
+
+ dataind = self.lastind
+
+ ax2.cla()
+ ax2.plot(X[dataind])
+
+ ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
+ transform=ax2.transAxes, va='top')
+ ax2.set_ylim(-0.5, 1.5)
+ self.selected.set_visible(True)
+ self.selected.set_data(xs[dataind], ys[dataind])
+
+ self.text.set_text('selected: %d'%dataind)
+ fig.canvas.draw()
+
+
+browser = PointBrowser()
+
+fig.canvas.mpl_connect('pick_event', browser.onpick)
+fig.canvas.mpl_connect('key_press_event', browser.onpress)
+
+show()
Copied: trunk/matplotlib/examples/event_handling/keypress_demo.py (from rev 5186, trunk/matplotlib/examples/pylab/keypress_demo.py)
===================================================================
--- trunk/matplotlib/examples/event_handling/keypress_demo.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/keypress_demo.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+"""
+Show how to connect to keypress events
+"""
+import numpy as n
+from pylab import figure, show
+
+def press(event):
+ print 'press', event.key
+ if event.key=='x':
+ visible = xl.get_visible()
+ xl.set_visible(not visible)
+ fig.canvas.draw()
+
+fig = figure()
+ax = fig.add_subplot(111)
+
+fig.canvas.mpl_connect('key_press_event', press)
+
+ax.plot(n.random.rand(12), n.random.rand(12), 'go')
+xl = ax.set_xlabel('easy come, easy go')
+
+show()
Copied: trunk/matplotlib/examples/event_handling/pick_event_demo2.py (from rev 5186, trunk/matplotlib/examples/pylab/pick_event_demo2.py)
===================================================================
--- trunk/matplotlib/examples/event_handling/pick_event_demo2.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/pick_event_demo2.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,45 @@
+"""
+compute the mean and stddev of 100 data sets and plot mean vs stddev.
+When you click on one of the mu, sigma points, plot the raw data from
+the dataset that generated the mean and stddev
+"""
+import numpy
+from pylab import figure, show
+
+
+X = numpy.random.rand(100, 1000)
+xs = numpy.mean(X, axis=1)
+ys = numpy.std(X, axis=1)
+
+fig = figure()
+ax = fig.add_subplot(111)
+ax.set_title('click on point to plot time series')
+line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
+
+
+def onpick(event):
+
+ if event.artist!=line: return True
+
+ N = len(event.ind)
+ if not N: return True
+
+
+ figi = figure()
+ for subplotnum, dataind in enumerate(event.ind):
+ ax = figi.add_subplot(N,1,subplotnum+1)
+ ax.plot(X[dataind])
+ ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
+ transform=ax.transAxes, va='top')
+ ax.set_ylim(-0.5, 1.5)
+ figi.show()
+ return True
+
+fig.canvas.mpl_connect('pick_event', onpick)
+
+show()
+
+
+
+
+
Copied: trunk/matplotlib/examples/event_handling/poly_editor.py (from rev 5186, trunk/matplotlib/examples/pylab/poly_editor.py)
===================================================================
--- trunk/matplotlib/examples/event_handling/poly_editor.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/poly_editor.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -0,0 +1,171 @@
+"""
+This is an example to show how to build cross-GUI applications using
+matplotlib event handling to interact with objects on the canvas
+
+"""
+from matplotlib.artist import Artist
+from matplotlib.patches import Polygon, CirclePolygon
+from numpy import sqrt, nonzero, equal, array, asarray, dot, amin, cos, sin
+from matplotlib.mlab import dist_point_to_segment
+
+
+class PolygonInteractor:
+ """
+ An polygon editor.
+
+ Key-bindings
+
+ 't' toggle vertex markers on and off. When vertex markers are on,
+ you can move them, delete them
+
+ 'd' delete the vertex under point
+
+ 'i' insert a vertex at point. You must be within epsilon of the
+ line connecting two existing vertices
+
+ """
+
+ showverts = True
+ epsilon = 5 # max pixel distance to count as a vertex hit
+
+ def __init__(self, ax, poly):
+ if poly.figure is None:
+ raise RuntimeError('You must first add the polygon to a figure or canvas before defining the interactor')
+ self.ax = ax
+ canvas = poly.figure.canvas
+ self.poly = poly
+
+ x, y = zip(*self.poly.xy)
+ self.line = Line2D(x,y,marker='o', markerfacecolor='r', animated=True)
+ self.ax.add_line(self.line)
+ #self._update_line(poly)
+
+ cid = self.poly.add_callback(self.poly_changed)
+ self._ind = None # the active vert
+
+ canvas.mpl_connect('draw_event', self.draw_callback)
+ canvas.mpl_connect('button_press_event', self.button_press_callback)
+ canvas.mpl_connect('key_press_event', self.key_press_callback)
+ canvas.mpl_connect('button_release_event', self.button_release_callback)
+ canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
+ self.canvas = canvas
+
+
+ def draw_callback(self, event):
+ self.background = self.canvas.copy_from_bbox(self.ax.bbox)
+ self.ax.draw_artist(self.poly)
+ self.ax.draw_artist(self.line)
+ self.canvas.blit(self.ax.bbox)
+
+ def poly_changed(self, poly):
+ 'this method is called whenever the polygon object is called'
+ # only copy the artist props to the line (except visibility)
+ vis = self.line.get_visible()
+ Artist.update_from(self.line, poly)
+ self.line.set_visible(vis) # don't use the poly visibility state
+
+
+ def get_ind_under_point(self, event):
+ 'get the index of the vertex under point if within epsilon tolerance'
+
+ # display coords
+ xy = asarray(self.poly.xy)
+ xyt = self.poly.get_transform().transform(xy)
+ xt, yt = xyt[:, 0], xyt[:, 1]
+ d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
+ indseq = nonzero(equal(d, amin(d)))[0]
+ ind = indseq[0]
+
+ if d[ind]>=self.epsilon:
+ ind = None
+
+ return ind
+
+ def button_press_callback(self, event):
+ 'whenever a mouse button is pressed'
+ if not self.showverts: return
+ if event.inaxes==None: return
+ if event.button != 1: return
+ self._ind = self.get_ind_under_point(event)
+
+ def button_release_callback(self, event):
+ 'whenever a mouse button is released'
+ if not self.showverts: return
+ if event.button != 1: return
+ self._ind = None
+
+ def key_press_callback(self, event):
+ 'whenever a key is pressed'
+ if not event.inaxes: return
+ if event.key=='t':
+ self.showverts = not self.showverts
+ self.line.set_visible(self.showverts)
+ if not self.showverts: self._ind = None
+ elif event.key=='d':
+ ind = self.get_ind_under_point(event)
+ if ind is not None:
+ self.poly.xy = [tup for i,tup in enumerate(self.poly.xy) if i!=ind]
+ self.line.set_data(zip(*self.poly.xy))
+ elif event.key=='i':
+ xys = self.poly.get_transform().transform(self.poly.xy)
+ p = event.x, event.y # display coords
+ for i in range(len(xys)-1):
+ s0 = xys[i]
+ s1 = xys[i+1]
+ d = dist_point_to_segment(p, s0, s1)
+ if d<=self.epsilon:
+ self.poly.xy = array(
+ list(self.poly.xy[:i]) +
+ [(event.xdata, event.ydata)] +
+ list(self.poly.xy[i:]))
+ self.line.set_data(zip(*self.poly.xy))
+ break
+
+
+ self.canvas.draw()
+
+ def motion_notify_callback(self, event):
+ 'on mouse movement'
+ if not self.showverts: return
+ if self._ind is None: return
+ if event.inaxes is None: return
+ if event.button != 1: return
+ x,y = event.xdata, event.ydata
+
+ self.poly.xy[self._ind] = x,y
+ self.line.set_data(zip(*self.poly.xy))
+
+ self.canvas.restore_region(self.background)
+ self.ax.draw_artist(self.poly)
+ self.ax.draw_artist(self.line)
+ self.canvas.blit(self.ax.bbox)
+
+
+
+from pylab import *
+
+
+
+
+
+fig = figure()
+theta = arange(0, 2*pi, 0.1)
+r = 1.5
+
+xs = r*cos(theta)
+ys = r*sin(theta)
+
+poly = Polygon(zip(xs, ys,), animated=True)
+
+
+
+
+ax = subplot(111)
+ax.add_patch(poly)
+p = PolygonInteractor( ax, poly)
+
+#ax.add_line(p.line)
+ax.set_title('Click and drag a point to move it')
+ax.set_xlim((-2,2))
+ax.set_ylim((-2,2))
+show()
Deleted: trunk/matplotlib/examples/pylab/anim.py
===================================================================
--- trunk/matplotlib/examples/pylab/anim.py 2008-05-17 22:05:52 UTC (rev 5186)
+++ trunk/matplotlib/examples/pylab/anim.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-"""
-A simple example of an animated plot in matplotlib. You can test the
-speed of animation of various backends by running the script with the
-'-dSomeBackend' flag
-
-SC Aug 31 2005 mpl 0.83.2:
-Here are some numbers from my system, where FPS is the frames rendered
-per second
-
- GTK 29 FPS
- GTKAgg 18 FPS
- GTKCairo 15 FPS
- TkAgg 13 FPS
- QkAgg 13 FPS
-"""
-import time
-
-import pylab as p
-
-# turn interactive mode on for dynamic updates. If you aren't in
-# interactive mode, you'll need to use a GUI event handler/timer.
-p.ion()
-
-tstart = time.time() # for profiling
-x = p.arange(0, 2*p.pi, 0.01) # x-array
-line, = p.plot(x, p.sin(x))
-for i in p.arange(1,200):
- line.set_ydata(p.sin(x+i/10.0)) # update the data
- p.draw() # redraw the canvas
-
-print 'FPS:' , 200/(time.time()-tstart)
Deleted: trunk/matplotlib/examples/pylab/data_browser.py
===================================================================
--- trunk/matplotlib/examples/pylab/data_browser.py 2008-05-17 22:05:52 UTC (rev 5186)
+++ trunk/matplotlib/examples/pylab/data_browser.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -1,82 +0,0 @@
-import numpy as np
-from pylab import figure, show
-
-
-X = np.random.rand(100, 200)
-xs = np.mean(X, axis=1)
-ys = np.std(X, axis=1)
-
-fig = figure()
-ax = fig.add_subplot(211)
-ax.set_title('click on point to plot time series')
-line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
-ax2 = fig.add_subplot(212)
-
-class PointBrowser:
- """
- Click on a point to select and highlight it -- the data that
- generated the point will be shown in the lower axes. Use the 'n'
- and 'p' keys to browse through the next and pervious points
- """
- def __init__(self):
- self.lastind = 0
-
- self.text = ax.text(0.05, 0.95, 'selected: none',
- transform=ax.transAxes, va='top')
- self.selected, = ax.plot([xs[0]], [ys[0]], 'o', ms=12, alpha=0.4,
- color='yellow', visible=False)
-
- def onpress(self, event):
- if self.lastind is None: return
- if event.key not in ('n', 'p'): return
- if event.key=='n': inc = 1
- else: inc = -1
-
-
- self.lastind += inc
- self.lastind = np.clip(self.lastind, 0, len(xs)-1)
- self.update()
-
- def onpick(self, event):
-
- if event.artist!=line: return True
-
- N = len(event.ind)
- if not N: return True
-
- # the click locations
- x = event.mouseevent.xdata
- y = event.mouseevent.ydata
-
-
- distances = np.hypot(x-xs[event.ind], y-ys[event.ind])
- indmin = distances.argmin()
- dataind = event.ind[indmin]
-
- self.lastind = dataind
- self.update()
-
- def update(self):
- if self.lastind is None: return
-
- dataind = self.lastind
-
- ax2.cla()
- ax2.plot(X[dataind])
-
- ax2.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
- transform=ax2.transAxes, va='top')
- ax2.set_ylim(-0.5, 1.5)
- self.selected.set_visible(True)
- self.selected.set_data(xs[dataind], ys[dataind])
-
- self.text.set_text('selected: %d'%dataind)
- fig.canvas.draw()
-
-
-browser = PointBrowser()
-
-fig.canvas.mpl_connect('pick_event', browser.onpick)
-fig.canvas.mpl_connect('key_press_event', browser.onpress)
-
-show()
Deleted: trunk/matplotlib/examples/pylab/dynamic_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab/dynamic_demo.py 2008-05-17 22:05:52 UTC (rev 5186)
+++ trunk/matplotlib/examples/pylab/dynamic_demo.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-import gobject
-import gtk
-
-from pylab import *
-
-
-fig = figure(1)
-ind = arange(30)
-X = rand(len(ind),10)
-lines = plot(X[:,0], 'o')
-
-manager = get_current_fig_manager()
-def updatefig(*args):
- lines[0].set_data(ind, X[:,updatefig.count])
- manager.canvas.draw()
- updatefig.count += 1
- if updatefig.count<10:
- return True
- else:
- return False
-
-updatefig.count = 0
-
-gobject.timeout_add(300, updatefig)
-show()
Deleted: trunk/matplotlib/examples/pylab/dynamic_image_gtkagg.py
===================================================================
--- trunk/matplotlib/examples/pylab/dynamic_image_gtkagg.py 2008-05-17 22:05:52 UTC (rev 5186)
+++ trunk/matplotlib/examples/pylab/dynamic_image_gtkagg.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-"""
-An animated image
-"""
-import time
-
-import gobject
-import gtk
-
-import matplotlib
-matplotlib.use('GTKAgg')
-from matplotlib import rcParams
-
-from pylab import *
-
-fig = figure(1)
-a = subplot(111)
-x = arange(120.0)*2*pi/120.0
-x = resize(x, (100,120))
-y = arange(100.0)*2*pi/100.0
-y = resize(y, (120,100))
-y = transpose(y)
-z = sin(x) + cos(y)
-im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest')
-
-manager = get_current_fig_manager()
-cnt = 0
-tstart = time.time()
-def updatefig(*args):
- global x, y, cnt, start
- x += pi/15
- y += pi/20
- z = sin(x) + cos(y)
- im.set_array(z)
- manager.canvas.draw()
- cnt += 1
- if cnt==50:
- print 'FPS', cnt/(time.time() - tstart)
- return False
- return True
-
-cnt = 0
-
-gobject.idle_add(updatefig)
-show()
Deleted: trunk/matplotlib/examples/pylab/interactive.py
===================================================================
--- trunk/matplotlib/examples/pylab/interactive.py 2008-05-17 22:05:52 UTC (rev 5186)
+++ trunk/matplotlib/examples/pylab/interactive.py 2008-05-18 21:06:13 UTC (rev 5187)
@@ -1,230 +0,0 @@
-#!/usr/bin/env python
-"""Multithreaded interactive interpreter with GTK and Matplotlib support.
-
-Usage:
-
- pyint-gtk.py -> starts shell with gtk thread running separately
-
- pyint-gtk.py -pylab [filename] -> initializes matplotlib, optionally running
- the named file. The shell starts after the file is executed.
-
-Threading code taken from:
-http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
-McErlean and John Finlay.
-
-Matplotlib support taken from interactive.py in the matplotlib distribution.
-
-Also borrows liberally from code.py in the Python standard library."""
-
-__author__ = "Fernando Perez <Fer...@co...>"
-
-import sys
-import code
-import threading
-
-import gobject
-import gtk
-
-try:
- import readline
-except ImportError:
- has_readline = False
-else:
- has_readline = True
-
-class MTConsole(code.InteractiveConsole):
- """Simple multi-threaded shell"""
-
- def __init__(self,on_kill=None,*args,**kw):
- code.InteractiveConsole.__init__(self,*args,**kw)
- self.code_to_run = None
- self.ready = threading.Condition()
- self._kill = False
- if on_kill is None:
- on_kill = []
- # Check that all things to kill are callable:
- for _ in on_kill:
- if not callable(_):
- raise TypeError,'on_kill must be a list of callables'
- self.on_kill = on_kill
- # Set up tab-completer
- if has_readline:
- import rlcompleter
- try: # this form only works with python 2.3
- self.completer = rlcompleter.Completer(self.locals)
- except: # simpler for py2.2
- self.completer = rlcompleter.Completer()
-
- readline.set_completer(self.completer.complete)
- # Use tab for completions
- readline.parse_and_bind('tab: complete')
- # This forces readline to automatically print the above list when tab
- # completion is set to 'complete'.
- readline.parse_and_bind('set show-all-if-ambiguous on')
- # Bindings for incremental searches in the history. These searches
- # use the string typed so far on the command line and search
- # anything in the previous input history containing them.
- readline.parse_and_bind('"\C-r": reverse-search-history')
- readline.parse_and_bind('"\C-s": forward-search-history')
-
- def runsource(self, source, filename="<input>", symbol="single"):
- """Compile and run some source in the interpreter.
-
- Arguments are as for compile_command().
-
- One several things can happen:
-
- 1) The input is incorrect; compile_command() raised an
- exception (SyntaxError or OverflowError). A syntax traceback
- will be printed by calling the showsyntaxerror() method.
-
- 2) The input is incomplete, and more input is required;
- compile_command() returned None. Nothing happens.
-
- 3) The input is complete; compile_command() returned a code
- object. The code is executed by calling self.runcode() (which
- also handles run-time exceptions, except for SystemExit).
-
- The return value is True in case 2, False in the other cases (unless
- an exception is raised). The return value can be used to
- decide whether to use sys.ps1 or sys.ps2 to prompt the next
- line.
- """
- try:
- code = self.compile(source, filename, symbol)
- except (OverflowError, SyntaxError, ValueError):
- # Case 1
- self.showsyntaxerror(filename)
- return False
-
- if code is None:
- # Case 2
- return True
-
- # Case 3
- # Store code in self, so the execution thread can handle it
- self.ready.acquire()
- self.code_to_run = code
- self.ready.wait() # Wait until processed in timeout interval
- self.ready.release()
-
- return False
-
- def runcode(self):
- """Execute a code object.
-
- When an exception occurs, self.showtraceback() is called to display a
- traceback."""
-
- self.ready.acquire()
- if self._kill:
- print 'Closing threads...',
- sys.stdout.flush()
- for tokill in self.on_kill:
- tokill()
- print 'Done.'
-
- if self.code_to_run is not None:
- self.ready.notify()
- code.InteractiveConsole.runcode(self,self.code_to_run)
-
- self.code_to_run = None
- self.ready.release()
- return True
-
- def kill (self):
- """Kill the thread, returning when it has been shut down."""
- self.ready.acquire()
- self._kill = True
- self.ready.release()
-
-class GTKInterpreter(threading.Thread):
- """Run gtk.main in the main thread and a python interpreter in a
- separate thread.
- Python commands can be passed to the thread where they will be executed.
- This is implemented by periodically checking for passed code using a
- GTK timeout callback.
- """
- TIMEOUT = 100 # Millisecond interval between timeouts.
-
- def __init__(self,banner=None):
- threading.Thread.__init__(self)
- self.banner = banner
- self.shell = MTConsole(on_kill=[gtk.main_quit])
-
- def run(self):
- self.pre_interact()
- self.shell.interact(self.banner)
- self.shell.kill()
-
- def mainloop(self):
- self.start()
- gobject.timeout_add(self.TIMEOUT, self.shell.runcode)
- try:
- if gtk.gtk...
[truncated message content] |
|
From: <md...@us...> - 2008-05-23 17:41:45
|
Revision: 5230
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5230&view=rev
Author: mdboom
Date: 2008-05-23 10:41:36 -0700 (Fri, 23 May 2008)
Log Message:
-----------
Move examples from pylab to api.
Added Paths:
-----------
trunk/matplotlib/examples/api/custom_projection_example.py
trunk/matplotlib/examples/api/custom_scale_example.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab/custom_projection_example.py
trunk/matplotlib/examples/pylab/custom_scale_example.py
Copied: trunk/matplotlib/examples/api/custom_projection_example.py (from rev 5226, trunk/matplotlib/examples/pylab/custom_projection_example.py)
===================================================================
--- trunk/matplotlib/examples/api/custom_projection_example.py (rev 0)
+++ trunk/matplotlib/examples/api/custom_projection_example.py 2008-05-23 17:41:36 UTC (rev 5230)
@@ -0,0 +1,475 @@
+from matplotlib.axes import Axes
+from matplotlib import cbook
+from matplotlib.patches import Circle
+from matplotlib.path import Path
+from matplotlib.ticker import Formatter, Locator, NullLocator, FixedLocator, NullFormatter
+from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \
+ BboxTransformTo, IdentityTransform, Transform, TransformWrapper
+from matplotlib.projections import register_projection
+
+import numpy as np
+
+# This example projection class is rather long, but it is designed to
+# illustrate many features, not all of which will be used every time.
+# It is also common to factor out a lot of these methods into common
+# code used by a number of projections with similar characteristics
+# (see geo.py).
+
+class HammerAxes(Axes):
+ """
+ A custom class for the Aitoff-Hammer projection, an equal-area map
+ projection.
+
+ http://en.wikipedia.org/wiki/Hammer_projection
+ """
+ # The projection must specify a name. This will be used be the
+ # user to select the projection, i.e. ``subplot(111,
+ # projection='hammer')``.
+ name = 'hammer'
+
+ # The number of interpolation steps when converting from straight
+ # lines to curves. (See ``transform_path``).
+ RESOLUTION = 75
+
+ def __init__(self, *args, **kwargs):
+ Axes.__init__(self, *args, **kwargs)
+ self.set_aspect(0.5, adjustable='box', anchor='C')
+ self.cla()
+
+ def cla(self):
+ """
+ Override to set up some reasonable defaults.
+ """
+ # Don't forget to call the base class
+ Axes.cla(self)
+
+ # Set up a default grid spacing
+ self.set_longitude_grid(30)
+ self.set_latitude_grid(15)
+ self.set_longitude_grid_ends(75)
+
+ # Turn off minor ticking altogether
+ self.xaxis.set_minor_locator(NullLocator())
+ self.yaxis.set_minor_locator(NullLocator())
+
+ # Do not display ticks -- we only want gridlines and text
+ self.xaxis.set_ticks_position('none')
+ self.yaxis.set_ticks_position('none')
+
+ # The limits on this projection are fixed -- they are not to
+ # be changed by the user. This makes the math in the
+ # transformation itself easier, and since this is a toy
+ # example, the easier, the better.
+ Axes.set_xlim(self, -np.pi, np.pi)
+ Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
+
+ def cla(self):
+ """
+ Initialize the Axes object to reasonable defaults.
+ """
+ Axes.cla(self)
+
+ self.set_longitude_grid(30)
+ self.set_latitude_grid(15)
+ self.set_longitude_grid_ends(75)
+ self.xaxis.set_minor_locator(NullLocator())
+ self.yaxis.set_minor_locator(NullLocator())
+ self.xaxis.set_ticks_position('none')
+ self.yaxis.set_ticks_position('none')
+
+ # self.grid(rcParams['axes.grid'])
+
+ Axes.set_xlim(self, -np.pi, np.pi)
+ Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
+
+ def _set_lim_and_transforms(self):
+ """
+ This is called once when the plot is created to set up all the
+ transforms for the data, text and grids.
+ """
+ # There are three important coordinate spaces going on here:
+ #
+ # 1. Data space: The space of the data itself
+ #
+ # 2. Axes space: The unit rectangle (0, 0) to (1, 1)
+ # covering the entire plot area.
+ #
+ # 3. Display space: The coordinates of the resulting image,
+ # often in pixels or dpi/inch.
+
+ # This function makes heavy use of the Transform classes in
+ # ``lib/matplotlib/transforms.py.`` For more information, see
+ # the inline documentation there.
+
+ # The goal of the first two transformations is to get from the
+ # data space (in this case longitude and latitude) to axes
+ # space. It is separated into a non-affine and affine part so
+ # that the non-affine part does not have to be recomputed when
+ # a simple affine change to the figure has been made (such as
+ # resizing the window or changing the dpi).
+
+ # 1) The core transformation from data space into
+ # rectilinear space defined in the HammerTransform class.
+ self.transProjection = self.HammerTransform(self.RESOLUTION)
+
+ # 2) The above has an output range that is not in the unit
+ # rectangle, so scale and translate it so it fits correctly
+ # within the axes. The peculiar calculations of xscale and
+ # yscale are specific to a Aitoff-Hammer projection, so don't
+ # worry about them too much.
+ xscale = 2.0 * np.sqrt(2.0) * np.sin(0.5 * np.pi)
+ yscale = np.sqrt(2.0) * np.sin(0.5 * np.pi)
+ self.transAffine = Affine2D() \
+ .scale(0.5 / xscale, 0.5 / yscale) \
+ .translate(0.5, 0.5)
+
+ # 3) This is the transformation from axes space to display
+ # space.
+ self.transAxes = BboxTransformTo(self.bbox)
+
+ # Now put these 3 transforms together -- from data all the way
+ # to display coordinates. Using the '+' operator, these
+ # transforms will be applied "in order". The transforms are
+ # automatically simplified, if possible, by the underlying
+ # transformation framework.
+ self.transData = \
+ self.transProjection + \
+ self.transAffine + \
+ self.transAxes
+
+ # The main data transformation is set up. Now deal with
+ # gridlines and tick labels.
+
+ # Longitude gridlines and ticklabels. The input to these
+ # transforms are in display space in x and axes space in y.
+ # Therefore, the input values will be in range (-xmin, 0),
+ # (xmax, 1). The goal of these transforms is to go from that
+ # space to display space. The tick labels will be offset 4
+ # pixels from the equator.
+ self._xaxis_pretransform = \
+ Affine2D() \
+ .scale(1.0, np.pi) \
+ .translate(0.0, -np.pi)
+ self._xaxis_transform = \
+ self._xaxis_pretransform + \
+ self.transData
+ self._xaxis_text1_transform = \
+ Affine2D().scale(1.0, 0.0) + \
+ self.transData + \
+ Affine2D().translate(0.0, 4.0)
+ self._xaxis_text2_transform = \
+ Affine2D().scale(1.0, 0.0) + \
+ self.transData + \
+ Affine2D().translate(0.0, -4.0)
+
+ # Now set up the transforms for the latitude ticks. The input to
+ # these transforms are in axes space in x and display space in
+ # y. Therefore, the input values will be in range (0, -ymin),
+ # (1, ymax). The goal of these transforms is to go from that
+ # space to display space. The tick labels will be offset 4
+ # pixels from the edge of the axes ellipse.
+ yaxis_stretch = Affine2D().scale(np.pi * 2.0, 1.0).translate(-np.pi, 0.0)
+ yaxis_space = Affine2D().scale(1.0, 1.1)
+ self._yaxis_transform = \
+ yaxis_stretch + \
+ self.transData
+ yaxis_text_base = \
+ yaxis_stretch + \
+ self.transProjection + \
+ (yaxis_space + \
+ self.transAffine + \
+ self.transAxes)
+ self._yaxis_text1_transform = \
+ yaxis_text_base + \
+ Affine2D().translate(-8.0, 0.0)
+ self._yaxis_text2_transform = \
+ yaxis_text_base + \
+ Affine2D().translate(8.0, 0.0)
+
+ def get_xaxis_transform(self):
+ """
+ Override this method to provide a transformation for the
+ x-axis grid and ticks.
+ """
+ return self._xaxis_transform
+
+ def get_xaxis_text1_transform(self, pixelPad):
+ """
+ Override this method to provide a transformation for the
+ x-axis tick labels.
+
+ Returns a tuple of the form (transform, valign, halign)
+ """
+ return self._xaxis_text1_transform, 'bottom', 'center'
+
+ def get_xaxis_text2_transform(self, pixelPad):
+ """
+ Override this method to provide a transformation for the
+ secondary x-axis tick labels.
+
+ Returns a tuple of the form (transform, valign, halign)
+ """
+ return self._xaxis_text2_transform, 'top', 'center'
+
+ def get_yaxis_transform(self):
+ """
+ Override this method to provide a transformation for the
+ y-axis grid and ticks.
+ """
+ return self._yaxis_transform
+
+ def get_yaxis_text1_transform(self, pixelPad):
+ """
+ Override this method to provide a transformation for the
+ y-axis tick labels.
+
+ Returns a tuple of the form (transform, valign, halign)
+ """
+ return self._yaxis_text1_transform, 'center', 'right'
+
+ def get_yaxis_text2_transform(self, pixelPad):
+ """
+ Override this method to provide a transformation for the
+ secondary y-axis tick labels.
+
+ Returns a tuple of the form (transform, valign, halign)
+ """
+ return self._yaxis_text2_transform, 'center', 'left'
+
+ def get_axes_patch(self):
+ """
+ Override this method to define the shape that is used for the
+ background of the plot. It should be a subclass of Patch.
+
+ In this case, it is a Circle (that may be warped by the axes
+ transform into an ellipse). Any data and gridlines will be
+ clipped to this shape.
+ """
+ return Circle((0.5, 0.5), 0.5)
+
+ # Prevent the user from applying scales to one or both of the
+ # axes. In this particular case, scaling the axes wouldn't make
+ # sense, so we don't allow it.
+ def set_xscale(self, *args, **kwargs):
+ if args[0] != 'linear':
+ raise NotImplementedError
+ Axes.set_xscale(self, *args, **kwargs)
+
+ def set_yscale(self, *args, **kwargs):
+ if args[0] != 'linear':
+ raise NotImplementedError
+ Axes.set_yscale(self, *args, **kwargs)
+
+ # Prevent the user from changing the axes limits. In our case, we
+ # want to display the whole sphere all the time, so we override
+ # set_xlim and set_ylim to ignore any input. This also applies to
+ # interactive panning and zooming in the GUI interfaces.
+ def set_xlim(self, *args, **kwargs):
+ Axes.set_xlim(self, -np.pi, np.pi)
+ Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
+ set_ylim = set_xlim
+
+ def format_coord(self, long, lat):
+ """
+ Override this method to change how the values are displayed in
+ the status bar.
+
+ In this case, we want them to be displayed in degrees N/S/E/W.
+ """
+ long = long * (180.0 / np.pi)
+ lat = lat * (180.0 / np.pi)
+ if lat >= 0.0:
+ ns = 'N'
+ else:
+ ns = 'S'
+ if long >= 0.0:
+ ew = 'E'
+ else:
+ ew = 'W'
+ # \u00b0 : degree symbol
+ return u'%f\u00b0%s, %f\u00b0%s' % (abs(lat), ns, abs(long), ew)
+
+ class DegreeFormatter(Formatter):
+ """
+ This is a custom formatter that converts the native unit of
+ radians into (truncated) degrees and adds a degree symbol.
+ """
+ def __init__(self, round_to=1.0):
+ self._round_to = round_to
+
+ def __call__(self, x, pos=None):
+ degrees = (x / np.pi) * 180.0
+ degrees = round(degrees / self._round_to) * self._round_to
+ # \u00b0 : degree symbol
+ return u"%d\u00b0" % degrees
+
+ def set_longitude_grid(self, degrees):
+ """
+ Set the number of degrees between each longitude grid.
+
+ This is an example method that is specific to this projection
+ class -- it provides a more convenient interface to set the
+ ticking than set_xticks would.
+ """
+ # Set up a FixedLocator at each of the points, evenly spaced
+ # by degrees.
+ number = (360.0 / degrees) + 1
+ self.xaxis.set_major_locator(
+ FixedLocator(
+ np.linspace(-np.pi, np.pi, number, True)[1:-1]))
+ # Set the formatter to display the tick labels in degrees,
+ # rather than radians.
+ self.xaxis.set_major_formatter(self.DegreeFormatter(degrees))
+
+ def set_latitude_grid(self, degrees):
+ """
+ Set the number of degrees between each longitude grid.
+
+ This is an example method that is specific to this projection
+ class -- it provides a more convenient interface than
+ set_yticks would.
+ """
+ # Set up a FixedLocator at each of the points, evenly spaced
+ # by degrees.
+ number = (180.0 / degrees) + 1
+ self.yaxis.set_major_locator(
+ FixedLocator(
+ np.linspace(-np.pi / 2.0, np.pi / 2.0, number, True)[1:-1]))
+ # Set the formatter to display the tick labels in degrees,
+ # rather than radians.
+ self.yaxis.set_major_formatter(self.DegreeFormatter(degrees))
+
+ def set_longitude_grid_ends(self, degrees):
+ """
+ Set the latitude(s) at which to stop drawing the longitude grids.
+
+ Often, in geographic projections, you wouldn't want to draw
+ longitude gridlines near the poles. This allows the user to
+ specify the degree at which to stop drawing longitude grids.
+
+ This is an example method that is specific to this projection
+ class -- it provides an interface to something that has no
+ analogy in the base Axes class.
+ """
+ longitude_cap = degrees * (np.pi / 180.0)
+ # Change the xaxis gridlines transform so that it draws from
+ # -degrees to degrees, rather than -pi to pi.
+ self._xaxis_pretransform \
+ .clear() \
+ .scale(1.0, longitude_cap * 2.0) \
+ .translate(0.0, -longitude_cap)
+
+ def get_data_ratio(self):
+ """
+ Return the aspect ratio of the data itself.
+
+ This method should be overridden by any Axes that have a
+ fixed data ratio.
+ """
+ return 1.0
+
+ # Interactive panning and zooming is not supported with this projection,
+ # so we override all of the following methods to disable it.
+ def can_zoom(self):
+ """
+ Return True if this axes support the zoom box
+ """
+ return False
+ def start_pan(self, x, y, button):
+ pass
+ def end_pan(self):
+ pass
+ def drag_pan(self, button, key, x, y):
+ pass
+
+ # Now, the transforms themselves.
+
+ class HammerTransform(Transform):
+ """
+ The base Hammer transform.
+ """
+ input_dims = 2
+ output_dims = 2
+ is_separable = False
+
+ def __init__(self, resolution):
+ """
+ Create a new Hammer transform. Resolution is the number of steps
+ to interpolate between each input line segment to approximate its
+ path in curved Hammer space.
+ """
+ Transform.__init__(self)
+ self._resolution = resolution
+
+ def transform(self, ll):
+ """
+ Override the transform method to implement the custom transform.
+
+ The input and output are Nx2 numpy arrays.
+ """
+ longitude = ll[:, 0:1]
+ latitude = ll[:, 1:2]
+
+ # Pre-compute some values
+ half_long = longitude / 2.0
+ cos_latitude = np.cos(latitude)
+ sqrt2 = np.sqrt(2.0)
+
+ alpha = 1.0 + cos_latitude * np.cos(half_long)
+ x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha
+ y = (sqrt2 * np.sin(latitude)) / alpha
+ return np.concatenate((x, y), 1)
+
+ # This is where things get interesting. With this projection,
+ # straight lines in data space become curves in display space.
+ # This is done by interpolating new values between the input
+ # values of the data. Since ``transform`` must not return a
+ # differently-sized array, any transform that requires
+ # changing the length of the data array must happen within
+ # ``transform_path``.
+ def transform_path(self, path):
+ vertices = path.vertices
+ ipath = path.interpolated(self._resolution)
+ return Path(self.transform(ipath.vertices), ipath.codes)
+
+ def inverted(self):
+ return HammerAxes.InvertedHammerTransform(self._resolution)
+ inverted.__doc__ = Transform.inverted.__doc__
+
+ class InvertedHammerTransform(Transform):
+ input_dims = 2
+ output_dims = 2
+ is_separable = False
+
+ def __init__(self, resolution):
+ Transform.__init__(self)
+ self._resolution = resolution
+
+ def transform(self, xy):
+ x = xy[:, 0:1]
+ y = xy[:, 1:2]
+
+ quarter_x = 0.25 * x
+ half_y = 0.5 * y
+ z = np.sqrt(1.0 - quarter_x*quarter_x - half_y*half_y)
+ longitude = 2 * np.arctan((z*x) / (2.0 * (2.0*z*z - 1.0)))
+ latitude = np.arcsin(y*z)
+ return np.concatenate((longitude, latitude), 1)
+ transform.__doc__ = Transform.transform.__doc__
+
+ def inverted(self):
+ # The inverse of the inverse is the original transform... ;)
+ return HammerAxes.HammerTransform(self._resolution)
+ inverted.__doc__ = Transform.inverted.__doc__
+
+# Now register the projection with matplotlib so the user can select
+# it.
+register_projection(HammerAxes)
+
+# Now make a simple example using the custom projection.
+from pylab import *
+
+subplot(111, projection="hammer")
+grid(True)
+
+show()
Copied: trunk/matplotlib/examples/api/custom_scale_example.py (from rev 5226, trunk/matplotlib/examples/pylab/custom_scale_example.py)
===================================================================
--- trunk/matplotlib/examples/api/custom_scale_example.py (rev 0)
+++ trunk/matplotlib/examples/api/custom_scale_example.py 2008-05-23 17:41:36 UTC (rev 5230)
@@ -0,0 +1,165 @@
+from matplotlib import scale as mscale
+from matplotlib import transforms as mtransforms
+
+class MercatorLatitudeScale(mscale.ScaleBase):
+ """
+ Scales data in range -pi/2 to pi/2 (-90 to 90 degrees) using
+ the system used to scale latitudes in a Mercator projection.
+
+ The scale function:
+ ln(tan(y) + sec(y))
+
+ The inverse scale function:
+ atan(sinh(y))
+
+ Since the Mercator scale tends to infinity at +/- 90 degrees,
+ there is user-defined threshold, above and below which nothing
+ will be plotted. This defaults to +/- 85 degrees.
+
+ source:
+ http://en.wikipedia.org/wiki/Mercator_projection
+ """
+
+ # The scale class must have a member ``name`` that defines the
+ # string used to select the scale. For example,
+ # ``gca().set_yscale("mercator")`` would be used to select this
+ # scale.
+ name = 'mercator'
+
+
+ def __init__(self, axis, **kwargs):
+ """
+ Any keyword arguments passed to ``set_xscale`` and
+ ``set_yscale`` will be passed along to the scale's
+ constructor.
+
+ thresh: The degree above which to crop the data.
+ """
+ mscale.ScaleBase.__init__(self)
+ thresh = kwargs.pop("thresh", (85 / 180.0) * np.pi)
+ if thresh >= np.pi / 2.0:
+ raise ValueError("thresh must be less than pi/2")
+ self.thresh = thresh
+
+ def get_transform(self):
+ """
+ Override this method to return a new instance that does the
+ actual transformation of the data.
+
+ The MercatorLatitudeTransform class is defined below as a
+ nested class of this one.
+ """
+ return self.MercatorLatitudeTransform(self.thresh)
+
+ def set_default_locators_and_formatters(self, axis):
+ """
+ Override to set up the locators and formatters to use with the
+ scale. This is only required if the scale requires custom
+ locators and formatters. Writing custom locators and
+ formatters is rather outside the scope of this example, but
+ there are many helpful examples in ``ticker.py``.
+
+ In our case, the Mercator example uses a fixed locator from
+ -90 to 90 degrees and a custom formatter class to put convert
+ the radians to degrees and put a degree symbol after the
+ value::
+ """
+ class DegreeFormatter(Formatter):
+ def __call__(self, x, pos=None):
+ # \u00b0 : degree symbol
+ return u"%d\u00b0" % ((x / np.pi) * 180.0)
+
+ deg2rad = np.pi / 180.0
+ axis.set_major_locator(FixedLocator(
+ np.arange(-90, 90, 10) * deg2rad))
+ axis.set_major_formatter(DegreeFormatter())
+ axis.set_minor_formatter(DegreeFormatter())
+
+ def limit_range_for_scale(self, vmin, vmax, minpos):
+ """
+ Override to limit the bounds of the axis to the domain of the
+ transform. In the case of Mercator, the bounds should be
+ limited to the threshold that was passed in. Unlike the
+ autoscaling provided by the tick locators, this range limiting
+ will always be adhered to, whether the axis range is set
+ manually, determined automatically or changed through panning
+ and zooming.
+ """
+ return max(vmin, -self.thresh), min(vmax, self.thresh)
+
+ class MercatorLatitudeTransform(mtransforms.Transform):
+ # There are two value members that must be defined.
+ # ``input_dims`` and ``output_dims`` specify number of input
+ # dimensions and output dimensions to the transformation.
+ # These are used by the transformation framework to do some
+ # error checking and prevent incompatible transformations from
+ # being connected together. When defining transforms for a
+ # scale, which are, by definition, separable and have only one
+ # dimension, these members should always be set to 1.
+ input_dims = 1
+ output_dims = 1
+ is_separable = True
+
+ def __init__(self, thresh):
+ mtransforms.Transform.__init__(self)
+ self.thresh = thresh
+
+ def transform(self, a):
+ """
+ This transform takes an Nx1 ``numpy`` array and returns a
+ transformed copy. Since the range of the Mercator scale
+ is limited by the user-specified threshold, the input
+ array must be masked to contain only valid values.
+ ``matplotlib`` will handle masked arrays and remove the
+ out-of-range data from the plot. Importantly, the
+ ``transform`` method *must* return an array that is the
+ same shape as the input array, since these values need to
+ remain synchronized with values in the other dimension.
+ """
+ masked = ma.masked_where((a < -self.thresh) | (a > self.thresh), a)
+ if masked.mask.any():
+ return ma.log(np.abs(ma.tan(masked) + 1.0 / ma.cos(masked)))
+ else:
+ return np.log(np.abs(np.tan(a) + 1.0 / np.cos(a)))
+
+ def inverted(self):
+ """
+ Override this method so matplotlib knows how to get the
+ inverse transform for this transform.
+ """
+ return MercatorLatitudeScale.InvertedMercatorLatitudeTransform(self.thresh)
+
+ class InvertedMercatorLatitudeTransform(mtransforms.Transform):
+ input_dims = 1
+ output_dims = 1
+ is_separable = True
+
+ def __init__(self, thresh):
+ mtransforms.Transform.__init__(self)
+ self.thresh = thresh
+
+ def transform(self, a):
+ return np.arctan(np.sinh(a))
+
+ def inverted(self):
+ return MercatorLatitudeScale.MercatorLatitudeTransform(self.thresh)
+
+# Now that the Scale class has been defined, it must be registered so
+# that ``matplotlib`` can find it.
+mscale.register_scale(MercatorLatitudeScale)
+
+from pylab import *
+import numpy as np
+
+t = arange(-180.0, 180.0, 0.1)
+s = t / 360.0 * np.pi
+
+plot(t, s, '-', lw=2)
+gca().set_yscale('mercator')
+
+xlabel('Longitude')
+ylabel('Latitude')
+title('Mercator: Projection of the Oppressor')
+grid(True)
+
+show()
Deleted: trunk/matplotlib/examples/pylab/custom_projection_example.py
===================================================================
--- trunk/matplotlib/examples/pylab/custom_projection_example.py 2008-05-23 17:41:07 UTC (rev 5229)
+++ trunk/matplotlib/examples/pylab/custom_projection_example.py 2008-05-23 17:41:36 UTC (rev 5230)
@@ -1,475 +0,0 @@
-from matplotlib.axes import Axes
-from matplotlib import cbook
-from matplotlib.patches import Circle
-from matplotlib.path import Path
-from matplotlib.ticker import Formatter, Locator, NullLocator, FixedLocator, NullFormatter
-from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \
- BboxTransformTo, IdentityTransform, Transform, TransformWrapper
-from matplotlib.projections import register_projection
-
-import numpy as np
-
-# This example projection class is rather long, but it is designed to
-# illustrate many features, not all of which will be used every time.
-# It is also common to factor out a lot of these methods into common
-# code used by a number of projections with similar characteristics
-# (see geo.py).
-
-class HammerAxes(Axes):
- """
- A custom class for the Aitoff-Hammer projection, an equal-area map
- projection.
-
- http://en.wikipedia.org/wiki/Hammer_projection
- """
- # The projection must specify a name. This will be used be the
- # user to select the projection, i.e. ``subplot(111,
- # projection='hammer')``.
- name = 'hammer'
-
- # The number of interpolation steps when converting from straight
- # lines to curves. (See ``transform_path``).
- RESOLUTION = 75
-
- def __init__(self, *args, **kwargs):
- Axes.__init__(self, *args, **kwargs)
- self.set_aspect(0.5, adjustable='box', anchor='C')
- self.cla()
-
- def cla(self):
- """
- Override to set up some reasonable defaults.
- """
- # Don't forget to call the base class
- Axes.cla(self)
-
- # Set up a default grid spacing
- self.set_longitude_grid(30)
- self.set_latitude_grid(15)
- self.set_longitude_grid_ends(75)
-
- # Turn off minor ticking altogether
- self.xaxis.set_minor_locator(NullLocator())
- self.yaxis.set_minor_locator(NullLocator())
-
- # Do not display ticks -- we only want gridlines and text
- self.xaxis.set_ticks_position('none')
- self.yaxis.set_ticks_position('none')
-
- # The limits on this projection are fixed -- they are not to
- # be changed by the user. This makes the math in the
- # transformation itself easier, and since this is a toy
- # example, the easier, the better.
- Axes.set_xlim(self, -np.pi, np.pi)
- Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
-
- def cla(self):
- """
- Initialize the Axes object to reasonable defaults.
- """
- Axes.cla(self)
-
- self.set_longitude_grid(30)
- self.set_latitude_grid(15)
- self.set_longitude_grid_ends(75)
- self.xaxis.set_minor_locator(NullLocator())
- self.yaxis.set_minor_locator(NullLocator())
- self.xaxis.set_ticks_position('none')
- self.yaxis.set_ticks_position('none')
-
- # self.grid(rcParams['axes.grid'])
-
- Axes.set_xlim(self, -np.pi, np.pi)
- Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)
-
- def _set_lim_and_transforms(self):
- """
- This is called once when the plot is created to set up all the
- transforms for the data, text and grids.
- """
- # There are three important coordinate spaces going on here:
- #
- # 1. Data space: The space of the data itself
- #
- # 2. Axes space: The unit rectangle (0, 0) to (1, 1)
- # covering the entire plot area.
- #
- # 3. Display space: The coordinates of the resulting image,
- # often in pixels or dpi/inch.
-
- # This function makes heavy use of the Transform classes in
- # ``lib/matplotlib/transforms.py.`` For more information, see
- # the inline documentation there.
-
- # The goal of the first two transformations is to get from the
- # data space (in this case longitude and latitude) to axes
- # space. It is separated into a non-affine and affine part so
- # that the non-affine part does not have to be recomputed when
- # a simple affine change to the figure has been made (such as
- # resizing the window or changing the dpi).
-
- # 1) The core transformation from data space into
- # rectilinear space defined in ...
[truncated message content] |
|
From: <jd...@us...> - 2008-05-25 16:14:15
|
Revision: 5263
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5263&view=rev
Author: jdh2358
Date: 2008-05-25 09:09:25 -0700 (Sun, 25 May 2008)
Log Message:
-----------
added logo2
Added Paths:
-----------
trunk/matplotlib/examples/api/logo2.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab/logo2.py
Copied: trunk/matplotlib/examples/api/logo2.py (from rev 5262, trunk/matplotlib/examples/pylab/logo2.py)
===================================================================
--- trunk/matplotlib/examples/api/logo2.py (rev 0)
+++ trunk/matplotlib/examples/api/logo2.py 2008-05-25 16:09:25 UTC (rev 5263)
@@ -0,0 +1,65 @@
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.cm as cm
+import matplotlib.mlab as mlab
+
+axalpha = 0.05
+fig = plt.figure(figsize=(8, 2),dpi=80)
+fig.figurePatch.set_edgecolor('#FFFFCC')
+fig.figurePatch.set_facecolor('#FFFFCC')
+
+# the polar bar plot
+ax = fig.add_axes([0.05, 0.05, 0.2, 01], polar=True)
+ax.axesPatch.set_alpha(axalpha)
+N = 20
+theta = np.arange(0.0, 2*np.pi, 2*np.pi/N)
+radii = 10*np.random.rand(N)
+width = np.pi/4*np.random.rand(N)
+bars = ax.bar(theta, radii, width=width, bottom=0.0)
+for r,bar in zip(radii, bars):
+ bar.set_facecolor( cm.jet(r/10.))
+ bar.set_alpha(0.5)
+
+for label in ax.get_xticklabels() + ax.get_yticklabels():
+ label.set_visible(False)
+
+
+# the histogram
+axhist = fig.add_axes([0.275, 0.075, 0.2, 0.4])
+axhist.axesPatch.set_alpha(axalpha)
+mu, sigma = 100, 15
+x = mu + sigma*np.random.randn(10000)
+
+# the histogram of the data
+n, bins, patches = axhist.hist(x, 50, normed=1, facecolor='green', edgecolor='green', alpha=0.75)
+
+
+y = mlab.normpdf( bins, mu, sigma)
+l = axhist.plot(bins, y, 'r', lw=1)
+
+axhist.set_title('Density of IQ',fontsize=6)
+axhist.set_xlabel('IQ', fontsize=6)
+axhist.set_ylabel('P(IQ)', fontsize=6)
+ax.set_xlim(-2*sigma, 2*sigma)
+for label in axhist.get_xticklabels() + axhist.get_yticklabels():
+ label.set_visible(False)
+
+
+axback = fig.add_axes([0., 0., 1., 1.])
+
+#the math background
+tex = r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$"
+axback.text(0.5, 0.5, tex,
+ transform=axback.transAxes, color="0.5", alpha=0.5, fontsize=40,
+ ha='center', va='center')
+axback.set_axis_off()
+
+# the matplotlib title
+axback.text(0.3, 0.95, 'matplotlib', color='black', fontsize=75,
+ ha='left', va='top', alpha=1.0,
+ transform=axback.transAxes)
+
+
+
+plt.show()
+
Deleted: trunk/matplotlib/examples/pylab/logo2.py
===================================================================
--- trunk/matplotlib/examples/pylab/logo2.py 2008-05-25 16:07:58 UTC (rev 5262)
+++ trunk/matplotlib/examples/pylab/logo2.py 2008-05-25 16:09:25 UTC (rev 5263)
@@ -1,65 +0,0 @@
-import numpy as np
-import matplotlib.pyplot as plt
-import matplotlib.cm as cm
-import matplotlib.mlab as mlab
-
-axalpha = 0.05
-fig = plt.figure(figsize=(8, 2),dpi=80)
-fig.figurePatch.set_edgecolor('#FFFFCC')
-fig.figurePatch.set_facecolor('#FFFFCC')
-
-# the polar bar plot
-ax = fig.add_axes([0.05, 0.05, 0.2, 01], polar=True)
-ax.axesPatch.set_alpha(axalpha)
-N = 20
-theta = np.arange(0.0, 2*np.pi, 2*np.pi/N)
-radii = 10*np.random.rand(N)
-width = np.pi/4*np.random.rand(N)
-bars = ax.bar(theta, radii, width=width, bottom=0.0)
-for r,bar in zip(radii, bars):
- bar.set_facecolor( cm.jet(r/10.))
- bar.set_alpha(0.5)
-
-for label in ax.get_xticklabels() + ax.get_yticklabels():
- label.set_visible(False)
-
-
-# the histogram
-axhist = fig.add_axes([0.275, 0.075, 0.2, 0.4])
-axhist.axesPatch.set_alpha(axalpha)
-mu, sigma = 100, 15
-x = mu + sigma*np.random.randn(10000)
-
-# the histogram of the data
-n, bins, patches = axhist.hist(x, 50, normed=1, facecolor='green', edgecolor='green', alpha=0.75)
-
-
-y = mlab.normpdf( bins, mu, sigma)
-l = axhist.plot(bins, y, 'r', lw=1)
-
-axhist.set_title('Density of IQ',fontsize=6)
-axhist.set_xlabel('IQ', fontsize=6)
-axhist.set_ylabel('P(IQ)', fontsize=6)
-ax.set_xlim(-2*sigma, 2*sigma)
-for label in axhist.get_xticklabels() + axhist.get_yticklabels():
- label.set_visible(False)
-
-
-axback = fig.add_axes([0., 0., 1., 1.])
-
-#the math background
-tex = r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$"
-axback.text(0.5, 0.5, tex,
- transform=axback.transAxes, color="0.5", alpha=0.5, fontsize=40,
- ha='center', va='center')
-axback.set_axis_off()
-
-# the matplotlib title
-axback.text(0.3, 0.95, 'matplotlib', color='black', fontsize=75,
- ha='left', va='top', alpha=1.0,
- transform=axback.transAxes)
-
-
-
-plt.show()
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-29 21:38:00
|
Revision: 5311
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5311&view=rev
Author: jdh2358
Date: 2008-05-29 14:37:55 -0700 (Thu, 29 May 2008)
Log Message:
-----------
added path editor
Modified Paths:
--------------
trunk/matplotlib/examples/api/path_patch_demo.py
Added Paths:
-----------
trunk/matplotlib/examples/event_handling/path_editor.py
Modified: trunk/matplotlib/examples/api/path_patch_demo.py
===================================================================
--- trunk/matplotlib/examples/api/path_patch_demo.py 2008-05-29 21:12:59 UTC (rev 5310)
+++ trunk/matplotlib/examples/api/path_patch_demo.py 2008-05-29 21:37:55 UTC (rev 5311)
@@ -5,6 +5,9 @@
Path = mpath.Path
+fig = plt.figure()
+ax = fig.add_subplot(111)
+
pathdata = [
(Path.MOVETO, (0, 0)),
(Path.CURVE4, (-1, 0)),
@@ -19,13 +22,10 @@
codes, verts = zip(*pathdata)
path = mpath.Path(verts, codes)
-
patch = mpatches.PathPatch(path, facecolor='green', edgecolor='yellow', alpha=0.5)
-
-fig = plt.figure()
-ax = fig.add_subplot(111)
ax.add_patch(patch)
+
ax.set_xlim(-5,5)
ax.set_ylim(-5,5)
Added: trunk/matplotlib/examples/event_handling/path_editor.py
===================================================================
--- trunk/matplotlib/examples/event_handling/path_editor.py (rev 0)
+++ trunk/matplotlib/examples/event_handling/path_editor.py 2008-05-29 21:37:55 UTC (rev 5311)
@@ -0,0 +1,145 @@
+import numpy as np
+import matplotlib.path as mpath
+import matplotlib.patches as mpatches
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
+
+Path = mpath.Path
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+
+pathdata = [
+ (Path.MOVETO, (0, 0)),
+ (Path.CURVE4, (-1, 0.1)),
+ (Path.CURVE4, (-1, 0.9)),
+ (Path.CURVE4, (0, 1)),
+ (Path.LINETO, (2, 1)),
+ (Path.CURVE4, (3, 0.9)),
+ (Path.CURVE4, (3, 0.1)),
+ (Path.CURVE4, (2, 0)),
+ (Path.CLOSEPOLY, (0, 0)),
+ ]
+
+codes, verts = zip(*pathdata)
+path = mpath.Path(verts, codes)
+patch = mpatches.PathPatch(path, facecolor='green', edgecolor='yellow', alpha=0.5)
+ax.add_patch(patch)
+
+
+class PathInteractor:
+ """
+ An path editor.
+
+ Key-bindings
+
+ 't' toggle vertex markers on and off. When vertex markers are on,
+ you can move them, delete them
+
+
+ """
+
+ showverts = True
+ epsilon = 5 # max pixel distance to count as a vertex hit
+
+ def __init__(self, pathpatch):
+
+ self.ax = pathpatch.axes
+ canvas = self.ax.figure.canvas
+ self.pathpatch = pathpatch
+ self.pathpatch.set_animated(True)
+
+ x, y = zip(*self.pathpatch.get_path().vertices)
+
+ self.line, = ax.plot(x,y,marker='o', markerfacecolor='r', animated=True)
+
+ self._ind = None # the active vert
+
+ canvas.mpl_connect('draw_event', self.draw_callback)
+ canvas.mpl_connect('button_press_event', self.button_press_callback)
+ canvas.mpl_connect('key_press_event', self.key_press_callback)
+ canvas.mpl_connect('button_release_event', self.button_release_callback)
+ canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
+ self.canvas = canvas
+
+
+ def draw_callback(self, event):
+ self.background = self.canvas.copy_from_bbox(self.ax.bbox)
+ self.ax.draw_artist(self.pathpatch)
+ self.ax.draw_artist(self.line)
+ self.canvas.blit(self.ax.bbox)
+
+ def pathpatch_changed(self, pathpatch):
+ 'this method is called whenever the pathpatchgon object is called'
+ # only copy the artist props to the line (except visibility)
+ vis = self.line.get_visible()
+ Artist.update_from(self.line, pathpatch)
+ self.line.set_visible(vis) # don't use the pathpatch visibility state
+
+
+ def get_ind_under_point(self, event):
+ 'get the index of the vertex under point if within epsilon tolerance'
+
+ # display coords
+ xy = np.asarray(self.pathpatch.get_path().vertices)
+ xyt = self.pathpatch.get_transform().transform(xy)
+ xt, yt = xyt[:, 0], xyt[:, 1]
+ d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2)
+ ind = d.argmin()
+
+ if d[ind]>=self.epsilon:
+ ind = None
+
+ return ind
+
+ def button_press_callback(self, event):
+ 'whenever a mouse button is pressed'
+ if not self.showverts: return
+ if event.inaxes==None: return
+ if event.button != 1: return
+ self._ind = self.get_ind_under_point(event)
+
+ def button_release_callback(self, event):
+ 'whenever a mouse button is released'
+ if not self.showverts: return
+ if event.button != 1: return
+ self._ind = None
+
+ def key_press_callback(self, event):
+ 'whenever a key is pressed'
+ if not event.inaxes: return
+ if event.key=='t':
+ self.showverts = not self.showverts
+ self.line.set_visible(self.showverts)
+ if not self.showverts: self._ind = None
+
+ self.canvas.draw()
+
+ def motion_notify_callback(self, event):
+ 'on mouse movement'
+ if not self.showverts: return
+ if self._ind is None: return
+ if event.inaxes is None: return
+ if event.button != 1: return
+ x,y = event.xdata, event.ydata
+
+ # todo: expose me
+ vertices = self.pathpatch.get_path().vertices
+
+ vertices[self._ind] = x,y
+ self.line.set_data(zip(*vertices))
+
+ self.canvas.restore_region(self.background)
+ self.ax.draw_artist(self.pathpatch)
+ self.ax.draw_artist(self.line)
+ self.canvas.blit(self.ax.bbox)
+
+
+interactor = PathInteractor(patch)
+ax.set_title('drag vertices to update path')
+ax.set_xlim(-5,5)
+ax.set_ylim(-5,5)
+
+plt.show()
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-05-30 16:58:09
|
Revision: 5322
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5322&view=rev
Author: jdh2358
Date: 2008-05-30 09:58:02 -0700 (Fri, 30 May 2008)
Log Message:
-----------
updated path example
Modified Paths:
--------------
trunk/matplotlib/examples/api/path_patch_demo.py
trunk/matplotlib/examples/event_handling/path_editor.py
Modified: trunk/matplotlib/examples/api/path_patch_demo.py
===================================================================
--- trunk/matplotlib/examples/api/path_patch_demo.py 2008-05-30 16:57:43 UTC (rev 5321)
+++ trunk/matplotlib/examples/api/path_patch_demo.py 2008-05-30 16:58:02 UTC (rev 5322)
@@ -9,26 +9,28 @@
ax = fig.add_subplot(111)
pathdata = [
- (Path.MOVETO, (0, 0)),
- (Path.CURVE4, (-1, 0)),
- (Path.CURVE4, (-1, 1)),
- (Path.CURVE4, (0, 1)),
- (Path.LINETO, (2, 1)),
- (Path.CURVE4, (3, 1)),
- (Path.CURVE4, (3, 0)),
- (Path.CURVE4, (2, 0)),
- (Path.CLOSEPOLY, (0, 0)),
+ (Path.MOVETO, (1.58, -2.57)),
+ (Path.CURVE4, (0.35, -1.1)),
+ (Path.CURVE4, (-1.75, 2.0)),
+ (Path.CURVE4, (0.375, 2.0)),
+ (Path.LINETO, (0.85, 1.15)),
+ (Path.CURVE4, (2.2, 3.2)),
+ (Path.CURVE4, (3, 0.05)),
+ (Path.CURVE4, (2.0, -0.5)),
+ (Path.CLOSEPOLY, (1.58, -2.57)),
]
codes, verts = zip(*pathdata)
path = mpath.Path(verts, codes)
-patch = mpatches.PathPatch(path, facecolor='green', edgecolor='yellow', alpha=0.5)
+patch = mpatches.PathPatch(path, facecolor='red', edgecolor='yellow', alpha=0.5)
ax.add_patch(patch)
-
-ax.set_xlim(-5,5)
-ax.set_ylim(-5,5)
-
+x, y = zip(*path.vertices)
+line, = ax.plot(x, y, 'go-')
+ax.grid()
+ax.set_xlim(-3,4)
+ax.set_ylim(-3,4)
+ax.set_title('spline paths')
plt.show()
Modified: trunk/matplotlib/examples/event_handling/path_editor.py
===================================================================
--- trunk/matplotlib/examples/event_handling/path_editor.py 2008-05-30 16:57:43 UTC (rev 5321)
+++ trunk/matplotlib/examples/event_handling/path_editor.py 2008-05-30 16:58:02 UTC (rev 5322)
@@ -10,15 +10,15 @@
ax = fig.add_subplot(111)
pathdata = [
- (Path.MOVETO, (0, 0)),
- (Path.CURVE4, (-1, 0.1)),
- (Path.CURVE4, (-1, 0.9)),
- (Path.CURVE4, (0, 1)),
- (Path.LINETO, (2, 1)),
- (Path.CURVE4, (3, 0.9)),
- (Path.CURVE4, (3, 0.1)),
- (Path.CURVE4, (2, 0)),
- (Path.CLOSEPOLY, (0, 0)),
+ (Path.MOVETO, (1.58, -2.57)),
+ (Path.CURVE4, (0.35, -1.1)),
+ (Path.CURVE4, (-1.75, 2.0)),
+ (Path.CURVE4, (0.375, 2.0)),
+ (Path.LINETO, (0.85, 1.15)),
+ (Path.CURVE4, (2.2, 3.2)),
+ (Path.CURVE4, (3, 0.05)),
+ (Path.CURVE4, (2.0, -0.5)),
+ (Path.CLOSEPOLY, (1.58, -2.57)),
]
codes, verts = zip(*pathdata)
@@ -123,9 +123,8 @@
if event.button != 1: return
x,y = event.xdata, event.ydata
- # todo: expose me
vertices = self.pathpatch.get_path().vertices
-
+
vertices[self._ind] = x,y
self.line.set_data(zip(*vertices))
@@ -137,8 +136,8 @@
interactor = PathInteractor(patch)
ax.set_title('drag vertices to update path')
-ax.set_xlim(-5,5)
-ax.set_ylim(-5,5)
+ax.set_xlim(-3,4)
+ax.set_ylim(-3,4)
plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-03 20:30:40
|
Revision: 5376
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5376&view=rev
Author: jdh2358
Date: 2008-06-03 13:30:38 -0700 (Tue, 03 Jun 2008)
Log Message:
-----------
renamed pylab examples dir to fix import breaks
Added Paths:
-----------
trunk/matplotlib/examples/api_examples/
trunk/matplotlib/examples/pylab_examples/
Removed Paths:
-------------
trunk/matplotlib/examples/api/
trunk/matplotlib/examples/pylab/
Copied: trunk/matplotlib/examples/api_examples (from rev 5375, trunk/matplotlib/examples/api)
Copied: trunk/matplotlib/examples/pylab_examples (from rev 5375, trunk/matplotlib/examples/pylab)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-03 20:33:48
|
Revision: 5377
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5377&view=rev
Author: jdh2358
Date: 2008-06-03 13:33:41 -0700 (Tue, 03 Jun 2008)
Log Message:
-----------
api does not need to be renamed since it doesnt clash
Added Paths:
-----------
trunk/matplotlib/examples/api/
Removed Paths:
-------------
trunk/matplotlib/examples/api_examples/
Copied: trunk/matplotlib/examples/api (from rev 5376, trunk/matplotlib/examples/api_examples)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-06-24 18:58:44
|
Revision: 5669
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5669&view=rev
Author: jdh2358
Date: 2008-06-24 11:58:41 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
added simple watermark examples
Added Paths:
-----------
trunk/matplotlib/examples/api/watermark_image.py
trunk/matplotlib/examples/api/watermark_text.py
trunk/matplotlib/examples/data/logo2.png
Added: trunk/matplotlib/examples/api/watermark_image.py
===================================================================
--- trunk/matplotlib/examples/api/watermark_image.py (rev 0)
+++ trunk/matplotlib/examples/api/watermark_image.py 2008-06-24 18:58:41 UTC (rev 5669)
@@ -0,0 +1,22 @@
+"""
+Use a PNG file as a watermark
+"""
+import numpy as np
+import matplotlib
+matplotlib.use('Agg')
+
+import matplotlib.image as image
+import matplotlib.pyplot as plt
+
+im = image.imread('../data/logo2.png')
+im[:,:,-1] = 0.5 # set the alpha channel
+
+fig = plt.figure()
+ax = fig.add_subplot(111)
+
+ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange')
+ax.grid()
+fig.figimage(im, 10, 10)
+
+fig.savefig('watermarked', transparent=True)
+
Added: trunk/matplotlib/examples/api/watermark_text.py
===================================================================
--- trunk/matplotlib/examples/api/watermark_text.py (rev 0)
+++ trunk/matplotlib/examples/api/watermark_text.py 2008-06-24 18:58:41 UTC (rev 5669)
@@ -0,0 +1,34 @@
+"""
+Use a PNG file as a watermark
+"""
+import numpy as np
+import matplotlib
+matplotlib.use('Agg')
+
+import matplotlib.mathtext as mathtext
+import matplotlib.pyplot as plt
+import matplotlib
+matplotlib.rc('image', origin='upper')
+
+dpi = 100 # save dpi
+w, h = 8, 6 # inches
+
+parser = mathtext.MathTextParser("Bitmap")
+
+rgba, depth1 = parser.to_rgba(r'Property of MPL', color='gray',
+ fontsize=30, dpi=200)
+rgba[:,:,-1] *= 0.5
+fig = plt.figure(figsize=(w,h))
+
+ax = fig.add_subplot(111)
+ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange')
+ax.grid()
+
+imh, imw, tmp = rgba.shape
+
+# position image at bottom right
+fig.figimage(rgba.astype(float)/255., w*dpi-imw, 0)
+
+
+fig.savefig('watermarked_text', transparent=True, dpi=dpi)
+
Added: trunk/matplotlib/examples/data/logo2.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/examples/data/logo2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|