From: <ef...@us...> - 2007-09-10 01:42:43
|
Revision: 3820 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3820&view=rev Author: efiring Date: 2007-09-09 18:42:39 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Numpification and cleanup of examples Modified Paths: -------------- trunk/matplotlib/CHANGELOG 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/backend_driver.py trunk/matplotlib/examples/clippedline.py trunk/matplotlib/examples/collections_demo.py trunk/matplotlib/examples/color_by_yvalue.py trunk/matplotlib/examples/contourf_demo.py trunk/matplotlib/examples/data_helper.py trunk/matplotlib/examples/dynamic_demo_wx.py trunk/matplotlib/examples/dynamic_image_wxagg.py trunk/matplotlib/examples/dynamic_image_wxagg2.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/gtk_spreadsheet.py trunk/matplotlib/examples/histogram_demo_canvasagg.py trunk/matplotlib/examples/image_masked.py trunk/matplotlib/examples/mathtext_wx.py trunk/matplotlib/examples/mpl_with_glade.py trunk/matplotlib/examples/multi_image.py trunk/matplotlib/examples/pcolor_nonuniform.py trunk/matplotlib/examples/polar_bar.py trunk/matplotlib/examples/polar_demo.py trunk/matplotlib/examples/polar_legend.py trunk/matplotlib/examples/poly_editor.py trunk/matplotlib/examples/printing_in_wx.py trunk/matplotlib/examples/pythonic_matplotlib.py trunk/matplotlib/examples/scatter_masked.py trunk/matplotlib/examples/strip_chart_demo.py trunk/matplotlib/examples/tex_demo.py trunk/matplotlib/examples/tex_unicode_demo.py trunk/matplotlib/examples/vline_demo.py trunk/matplotlib/examples/webapp_demo.py trunk/matplotlib/examples/wxcursor_demo.py Removed Paths: ------------- trunk/matplotlib/examples/anim_tk.py trunk/matplotlib/examples/image_demo_na.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/CHANGELOG 2007-09-10 01:42:39 UTC (rev 3820) @@ -5,7 +5,9 @@ from pylab is nearly unchanged, but there is the new alternative of importing from pyplot to get the state-engine graphics without all the numeric - functions. - EF + functions. + Numpified examples; deleted two that were obsolete; + modified some to use pyplot. - EF 2007-09-08 Eliminated gd and paint backends - EF Deleted: trunk/matplotlib/examples/anim_tk.py =================================================================== --- trunk/matplotlib/examples/anim_tk.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/anim_tk.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,49 +0,0 @@ -# deprecated - this example is no longer needed. Follow the model of -# anim.py to use interaction = True to avoid all the cruft of timers, -# callbacks and the likes used here - -#!/usr/bin/env python2.3 - -import matplotlib -matplotlib.use('TkAgg') -import pylab - -#import Tkinter as Tk -import matplotlib.numerix as numerix -fig = pylab.figure(1) -ind = numerix.arange(60) - - - -x_tmp=[] -for i in range(100): - x_tmp.append(numerix.sin((ind+i)*numerix.pi/15.0)) - -X=numerix.array(x_tmp) - - -lines = pylab.plot(X[:,0],'o') - -manager = pylab.get_current_fig_manager() - -def updatefig(*args): - updatefig.count += 1 - lines[0].set_ydata(X[:,updatefig.count%60]) - manager.canvas.draw() - return updatefig.count -updatefig.count=-1 - -def run(*args): - print 'called run' - - import time - tstart = time.time() - while 1: - cnt = updatefig() - if cnt==100: break - print 'elapsed', 100.0/(time.time() - tstart) - -import Tkinter as Tk -manager.window.after(10, run) -manager.show() -Tk.mainloop() Modified: trunk/matplotlib/examples/animation_blit.py =================================================================== --- trunk/matplotlib/examples/animation_blit.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/animation_blit.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -10,7 +10,7 @@ import matplotlib matplotlib.use('GTKAgg') -import matplotlib.numerix as nx +import numpy as npy import pylab as p @@ -21,8 +21,8 @@ p.grid() # to ensure proper background restore # create the initial line -x = nx.arange(0,2*nx.pi,0.01) -line, = p.plot(x, nx.sin(x), animated=True, lw=2) +x = npy.arange(0,2*npy.pi,0.01) +line, = p.plot(x, npy.sin(x), animated=True, lw=2) # for profiling tstart = time.time() @@ -34,7 +34,7 @@ # restore the clean slate background canvas.restore_region(update_line.background) # update the data - line.set_ydata(nx.sin(x+update_line.cnt/10.0)) + line.set_ydata(npy.sin(x+update_line.cnt/10.0)) # just draw the animated artist try: ax.draw_artist(line) Modified: trunk/matplotlib/examples/animation_blit_fltk.py =================================================================== --- trunk/matplotlib/examples/animation_blit_fltk.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/animation_blit_fltk.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -3,7 +3,7 @@ import matplotlib matplotlib.use('FltkAgg') import pylab as p -import matplotlib.numerix as nx +import numpy as nx import time Modified: trunk/matplotlib/examples/animation_blit_qt.py =================================================================== --- trunk/matplotlib/examples/animation_blit_qt.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/animation_blit_qt.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -15,7 +15,7 @@ ITERS = 1000 import pylab as p -import matplotlib.numerix as nx +import numpy as npy import time class BlitQT(QObject): @@ -27,8 +27,8 @@ self.cnt = 0 # create the initial line - self.x = nx.arange(0,2*nx.pi,0.01) - self.line, = p.plot(self.x, nx.sin(self.x), animated=True, lw=2) + self.x = npy.arange(0,2*npy.pi,0.01) + self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2) self.background = None @@ -39,7 +39,7 @@ # restore the clean slate background self.canvas.restore_region(self.background) # update the data - self.line.set_ydata(nx.sin(self.x+self.cnt/10.0)) + self.line.set_ydata(npy.sin(self.x+self.cnt/10.0)) # just draw the animated artist self.ax.draw_artist(self.line) # just redraw the axes rectangle Modified: trunk/matplotlib/examples/animation_blit_qt4.py =================================================================== --- trunk/matplotlib/examples/animation_blit_qt4.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/animation_blit_qt4.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -10,7 +10,7 @@ ITERS = 1000 import pylab as p -import matplotlib.numerix as nx +import numpy as npy import time class BlitQT(QtCore.QObject): @@ -22,8 +22,8 @@ self.cnt = 0 # create the initial line - self.x = nx.arange(0,2*nx.pi,0.01) - self.line, = p.plot(self.x, nx.sin(self.x), animated=True, lw=2) + self.x = npy.arange(0,2*npy.pi,0.01) + self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2) self.background = None @@ -34,7 +34,7 @@ # restore the clean slate background self.canvas.restore_region(self.background) # update the data - self.line.set_ydata(nx.sin(self.x+self.cnt/10.0)) + self.line.set_ydata(npy.sin(self.x+self.cnt/10.0)) # just draw the animated artist self.ax.draw_artist(self.line) # just redraw the axes rectangle Modified: trunk/matplotlib/examples/animation_blit_tk.py =================================================================== --- trunk/matplotlib/examples/animation_blit_tk.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/animation_blit_tk.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -6,7 +6,7 @@ import sys import pylab as p -import matplotlib.numerix as nx +import numpy as npy import time ax = p.subplot(111) @@ -14,8 +14,8 @@ # create the initial line -x = nx.arange(0,2*nx.pi,0.01) -line, = p.plot(x, nx.sin(x), animated=True, lw=2) +x = npy.arange(0,2*npy.pi,0.01) +line, = p.plot(x, npy.sin(x), animated=True, lw=2) def run(*args): background = canvas.copy_from_bbox(ax.bbox) @@ -26,7 +26,7 @@ # restore the clean slate background canvas.restore_region(background) # update the data - line.set_ydata(nx.sin(x+run.cnt/10.0)) + line.set_ydata(npy.sin(x+run.cnt/10.0)) # just draw the animated artist ax.draw_artist(line) # just redraw the axes rectangle Modified: trunk/matplotlib/examples/animation_blit_wx.py =================================================================== --- trunk/matplotlib/examples/animation_blit_wx.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/animation_blit_wx.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -12,7 +12,7 @@ import wx import sys import pylab as p -import matplotlib.numerix as nx +import numpy as npy import time @@ -30,8 +30,8 @@ p.grid() # to ensure proper background restore # create the initial line -x = nx.arange(0,2*nx.pi,0.01) -line, = p.plot(x, nx.sin(x), animated=True, lw=2) +x = npy.arange(0,2*npy.pi,0.01) +line, = p.plot(x, npy.sin(x), animated=True, lw=2) # for profiling tstart = time.time() @@ -46,7 +46,7 @@ # restore the clean slate background canvas.restore_region(update_line.background) # update the data - line.set_ydata(nx.sin(x+update_line.cnt/10.0)) + line.set_ydata(npy.sin(x+update_line.cnt/10.0)) # just draw the animated artist ax.draw_artist(line) # just redraw the axes rectangle Modified: trunk/matplotlib/examples/backend_driver.py =================================================================== --- trunk/matplotlib/examples/backend_driver.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/backend_driver.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -42,7 +42,6 @@ 'histogram_demo.py', 'image_demo.py', 'image_demo2.py', - 'image_demo_na.py', 'image_masked.py', 'image_origin.py', 'invert_axes.py', @@ -158,7 +157,7 @@ if __name__ == '__main__': times = {} - default_backends = ['Agg', 'PS', 'SVG', 'Template'] + default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template'] if sys.platform == 'win32': python = r'c:\Python24\python.exe' else: Modified: trunk/matplotlib/examples/clippedline.py =================================================================== --- trunk/matplotlib/examples/clippedline.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/clippedline.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -4,7 +4,7 @@ """ from matplotlib.lines import Line2D -import matplotlib.numerix as nx +import numpy as npy from pylab import figure, show class ClippedLine(Line2D): @@ -19,13 +19,13 @@ def set_data(self, *args, **kwargs): Line2D.set_data(self, *args, **kwargs) - self.xorig = nx.array(self._x) - self.yorig = nx.array(self._y) + self.xorig = npy.array(self._x) + self.yorig = npy.array(self._y) def draw(self, renderer): xlim = self.ax.get_xlim() - ind0, ind1 = nx.searchsorted(self.xorig, xlim) + ind0, ind1 = npy.searchsorted(self.xorig, xlim) self._x = self.xorig[ind0:ind1] self._y = self.yorig[ind0:ind1] N = len(self._x) @@ -43,8 +43,8 @@ fig = figure() ax = fig.add_subplot(111, autoscale_on=False) -t = nx.arange(0.0, 100.0, 0.01) -s = nx.sin(2*nx.pi*t) +t = npy.arange(0.0, 100.0, 0.01) +s = npy.sin(2*npy.pi*t) line = ClippedLine(ax, t, s, color='g', ls='-', lw=2) ax.add_line(line) ax.set_xlim(10,30) Modified: trunk/matplotlib/examples/collections_demo.py =================================================================== --- trunk/matplotlib/examples/collections_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/collections_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -17,10 +17,10 @@ ''' -import pylab as P +import matplotlib.pyplot as P from matplotlib import collections, axes, transforms from matplotlib.colors import colorConverter -import matplotlib.numerix as N +import numpy as N nverts = 50 npts = 100 @@ -33,8 +33,8 @@ spiral = zip(xx,yy) # Make some offsets -xo = P.randn(npts) -yo = P.randn(npts) +xo = N.random.randn(npts) +yo = N.random.randn(npts) xyo = zip(xo, yo) # Make a list of colors cycling through the rgbcmyk series. @@ -90,7 +90,7 @@ a = fig.add_subplot(2,2,3) col = collections.RegularPolyCollection(fig.dpi, 7, - sizes = P.fabs(xx)*10, offsets=xyo, + sizes = N.fabs(xx)*10, offsets=xyo, transOffset=a.transData) a.add_collection(col, autolim=True) trans = transforms.scale_transform(fig.dpi/transforms.Value(72.), @@ -111,12 +111,12 @@ ncurves = 20 offs = (0.1, 0.0) -yy = P.linspace(0, 2*N.pi, nverts) -ym = P.amax(yy) +yy = N.linspace(0, 2*N.pi, nverts) +ym = N.amax(yy) xx = (0.2 + (ym-yy)/ym)**2 * N.cos(yy-0.4) * 0.5 segs = [] for i in range(ncurves): - xxx = xx + 0.02*P.randn(nverts) + xxx = xx + 0.02*N.random.randn(nverts) curve = zip(xxx, yy*100) segs.append(curve) Modified: trunk/matplotlib/examples/color_by_yvalue.py =================================================================== --- trunk/matplotlib/examples/color_by_yvalue.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/color_by_yvalue.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,7 +1,7 @@ # use masked arrays to plot a line with different colors by y-value -import matplotlib.numerix.ma as ma -from matplotlib.numerix import logical_or -from pylab import plot, show, arange, sin, pi +import matplotlib.numerix.npyma as ma +from numpy import logical_or, arange, sin, pi +from matplotlib.pyplot import plot, show t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) Modified: trunk/matplotlib/examples/contourf_demo.py =================================================================== --- trunk/matplotlib/examples/contourf_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/contourf_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,6 +1,6 @@ #!/usr/bin/env python from pylab import * -import matplotlib.numerix.ma as ma +import matplotlib.numerix.npyma as ma origin = 'lower' #origin = 'upper' Modified: trunk/matplotlib/examples/data_helper.py =================================================================== --- trunk/matplotlib/examples/data_helper.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/data_helper.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,7 +1,8 @@ #!/usr/bin/env python # Some functions to load a return data for the plot demos -from matplotlib.numerix import fromstring, argsort, take, array, resize +from numpy import fromstring, argsort, take, array, resize + def get_two_stock_data(): """ load stock time and price data for two stocks The return values Modified: trunk/matplotlib/examples/dynamic_demo_wx.py =================================================================== --- trunk/matplotlib/examples/dynamic_demo_wx.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/dynamic_demo_wx.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -63,7 +63,7 @@ from matplotlib.figure import Figure from matplotlib.axes import Subplot -import matplotlib.numerix as numpy +import numpy from wx import * Modified: trunk/matplotlib/examples/dynamic_image_wxagg.py =================================================================== --- trunk/matplotlib/examples/dynamic_image_wxagg.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/dynamic_image_wxagg.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -12,26 +12,13 @@ import matplotlib matplotlib.use('WXAgg') -# jdh: you need to control Numeric vs numarray with numerix, otherwise -# matplotlib may be using numeric under the hood and while you are -# using numarray and this isn't efficient. Also, if you use -# numerix=numarray, it is important to compile matplotlib for numarray -# by setting NUMERIX = 'numarray' in setup.py before building from matplotlib import rcParams -##rcParams['numerix'] = 'numarray' - - -# jdh: you can import cm directly, you don't need to go via -# pylab import matplotlib.cm as cm from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg -# jdh: you don't need a figure manager in the GUI - this class was -# designed for the pylab interface - from matplotlib.figure import Figure -import matplotlib.numerix as numerix +import numpy as npy import wx @@ -75,12 +62,12 @@ # jdh you can add a subplot directly from the fig rather than # the fig manager a = self.fig.add_subplot(111) - self.x = numerix.arange(120.0)*2*numerix.pi/120.0 + self.x = npy.arange(120.0)*2*npy.pi/120.0 self.x.resize((100,120)) - self.y = numerix.arange(100.0)*2*numerix.pi/100.0 + self.y = npy.arange(100.0)*2*npy.pi/100.0 self.y.resize((120,100)) - self.y = numerix.transpose(self.y) - z = numerix.sin(self.x) + numerix.cos(self.y) + self.y = npy.transpose(self.y) + z = npy.sin(self.x) + npy.cos(self.y) self.im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest') def GetToolBar(self): @@ -89,9 +76,9 @@ return self.toolbar def onTimer(self, evt): - self.x += numerix.pi/15 - self.y += numerix.pi/20 - z = numerix.sin(self.x) + numerix.cos(self.y) + self.x += npy.pi/15 + self.y += npy.pi/20 + z = npy.sin(self.x) + npy.cos(self.y) self.im.set_array(z) self.canvas.draw() #self.canvas.gui_repaint() # jdh wxagg_draw calls this already Modified: trunk/matplotlib/examples/dynamic_image_wxagg2.py =================================================================== --- trunk/matplotlib/examples/dynamic_image_wxagg2.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/dynamic_image_wxagg2.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -12,24 +12,14 @@ import matplotlib matplotlib.use('WXAgg') -# jdh: you need to control Numeric vs numarray with numerix, otherwise -# matplotlib may be using numeric under the hood and while you are -# using numarray and this isn't efficient. Also, if you use -# numerix=numarray, it is important to compile matplotlib for numarray -# by setting NUMERIX = 'numarray' in setup.py before building from matplotlib import rcParams import numpy as npy -# jdh: you can import cm directly, you don't need to go via -# pylab import matplotlib.cm as cm from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg from matplotlib.backends.backend_wx import NavigationToolbar2Wx -# jdh: you don't need a figure manager in the GUI - this class was -# designed for the pylab interface - from matplotlib.figure import Figure from wx import * Modified: trunk/matplotlib/examples/embedding_in_gtk.py =================================================================== --- trunk/matplotlib/examples/embedding_in_gtk.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_gtk.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -8,7 +8,7 @@ from matplotlib.axes import Subplot from matplotlib.figure import Figure -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi # uncomment to select /GTK/GTKAgg/GTKCairo from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas Modified: trunk/matplotlib/examples/embedding_in_gtk2.py =================================================================== --- trunk/matplotlib/examples/embedding_in_gtk2.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_gtk2.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -7,7 +7,7 @@ from matplotlib.axes import Subplot from matplotlib.figure import Figure -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi # uncomment to select /GTK/GTKAgg/GTKCairo from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas Modified: trunk/matplotlib/examples/embedding_in_gtk3.py =================================================================== --- trunk/matplotlib/examples/embedding_in_gtk3.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_gtk3.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -7,7 +7,7 @@ from matplotlib.axes import Subplot from matplotlib.figure import Figure -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi # uncomment to select /GTK/GTKAgg/GTKCairo #from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas Modified: trunk/matplotlib/examples/embedding_in_qt.py =================================================================== --- trunk/matplotlib/examples/embedding_in_qt.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_qt.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -11,7 +11,7 @@ import sys, os, random from qt import * -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure Modified: trunk/matplotlib/examples/embedding_in_qt4.py =================================================================== --- trunk/matplotlib/examples/embedding_in_qt4.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_qt4.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -12,7 +12,7 @@ import sys, os, random from PyQt4 import QtGui, QtCore -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure Modified: trunk/matplotlib/examples/embedding_in_tk.py =================================================================== --- trunk/matplotlib/examples/embedding_in_tk.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_tk.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -2,7 +2,7 @@ import matplotlib matplotlib.use('TkAgg') -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi from matplotlib.axes import Subplot from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure Modified: trunk/matplotlib/examples/embedding_in_tk2.py =================================================================== --- trunk/matplotlib/examples/embedding_in_tk2.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_tk2.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -2,7 +2,7 @@ import matplotlib matplotlib.use('TkAgg') -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi from matplotlib.axes import Subplot from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure Modified: trunk/matplotlib/examples/embedding_in_wx.py =================================================================== --- trunk/matplotlib/examples/embedding_in_wx.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_wx.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -44,7 +44,7 @@ from matplotlib.figure import Figure from matplotlib.axes import Subplot -import matplotlib.numerix as numpy +import numpy from wx import * Modified: trunk/matplotlib/examples/embedding_in_wx2.py =================================================================== --- trunk/matplotlib/examples/embedding_in_wx2.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_wx2.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -4,7 +4,7 @@ toolbar - comment out the setA_toolbar line for no toolbar """ -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi import matplotlib Modified: trunk/matplotlib/examples/embedding_in_wx3.py =================================================================== --- trunk/matplotlib/examples/embedding_in_wx3.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_wx3.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -25,8 +25,6 @@ from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg from matplotlib.figure import Figure import numpy as npy -import matplotlib.numerix.mlab as mlab -from matplotlib.mlab import meshgrid from wx import * from wx.xrc import * @@ -61,11 +59,11 @@ x = npy.arange(120.0)*2*npy.pi/60.0 y = npy.arange(100.0)*2*npy.pi/50.0 - self.x, self.y = meshgrid(x, y) + self.x, self.y = npy.meshgrid(x, y) z = npy.sin(self.x) + npy.cos(self.y) self.im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest') - zmax = mlab.max(mlab.max(z))-ERR_TOL + zmax = npy.amax(z) - ERR_TOL ymax_i, xmax_i = npy.nonzero(z >= zmax) if self.im.origin == 'upper': ymax_i = z.shape[0]-ymax_i @@ -84,7 +82,7 @@ z = npy.sin(self.x) + npy.cos(self.y) self.im.set_array(z) - zmax = mlab.max(mlab.max(z))-ERR_TOL + zmax = npy.amax(z) - ERR_TOL ymax_i, xmax_i = npy.nonzero(z >= zmax) if self.im.origin == 'upper': ymax_i = z.shape[0]-ymax_i Modified: trunk/matplotlib/examples/embedding_in_wx4.py =================================================================== --- trunk/matplotlib/examples/embedding_in_wx4.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/embedding_in_wx4.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -4,7 +4,7 @@ toolbar """ -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi import matplotlib @@ -19,7 +19,7 @@ from matplotlib.backends.backend_wx import _load_bitmap from matplotlib.figure import Figure -from matplotlib.numerix.mlab import rand +from numpy.random import rand from wx import * Modified: trunk/matplotlib/examples/gtk_spreadsheet.py =================================================================== --- trunk/matplotlib/examples/gtk_spreadsheet.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/gtk_spreadsheet.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -14,15 +14,13 @@ matplotlib.use('GTKAgg') # or 'GTK' from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas -#from matplotlib.numerix import rand -from matplotlib.numerix.random_array import random +from numpy.random import random from matplotlib.figure import Figure class DataManager(gtk.Window): numRows, numCols = 20,10 - #data = rand(numRows, numCols) data = random((numRows, numCols)) def __init__(self): Modified: trunk/matplotlib/examples/histogram_demo_canvasagg.py =================================================================== --- trunk/matplotlib/examples/histogram_demo_canvasagg.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/histogram_demo_canvasagg.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -13,7 +13,8 @@ from matplotlib.figure import Figure from matplotlib.axes import Subplot from matplotlib.mlab import normpdf -from matplotlib.numerix.mlab import randn +from numpy.random import randn +import numpy fig = Figure(figsize=(5,4), dpi=100) ax = fig.add_subplot(111) @@ -42,14 +43,14 @@ s = canvas.tostring_rgb() # save this and convert to bitmap as needed -# get the figure dimensions for creating bitmaps or numeric arrays, +# get the figure dimensions for creating bitmaps or numpy arrays, # etc. l,b,w,h = fig.bbox.get_bounds() w, h = int(w), int(h) if 0: - # convert to a Numeric array - X = fromstring(s, UInt8) + # convert to a numpy array + X = numpy.fromstring(s, numpy.uint8) X.shape = h, w, 3 if 0: Deleted: trunk/matplotlib/examples/image_demo_na.py =================================================================== --- trunk/matplotlib/examples/image_demo_na.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/image_demo_na.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,40 +0,0 @@ -#!/usr/bin/env python -from matplotlib import rcParams -rcParams['numerix'] = 'numarray' - -from pylab import * - - -def bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0, - mux=0.0, muy=0.0, sigmaxy=0.0): - """ - Bivariate gaussan distribution for equal shape X, Y - - http://mathworld.wolfram.com/BivariateNormalDistribution.html - """ - Xmu = X-mux - Ymu = Y-muy - - rho = sigmaxy/(sigmax*sigmay) - z = (1.0/sigmax**2)*Xmu**2 + (1.0/sigmay)*Ymu**2 - (2*rho/(sigmax*sigmay))*Xmu*Ymu - return 1.0/(2*pi*sigmax*sigmay*(1-rho**2)) * exp( -1/(2*(1-rho**2))*z) - - -delta = 0.025 -x = arange(-3.0, 3.0, delta) -y = arange(-3.0, 3.0, delta) -X,Y = meshgrid(x, y) -Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) -Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) - -# difference of Gaussians -im = imshow(Z2-Z1) - -# set the interpolation method: 'nearest', 'bilinear', 'bicubic' and much more -im.set_interpolation('bilinear') - - -axis('off') -#savefig('test') -show() - Modified: trunk/matplotlib/examples/image_masked.py =================================================================== --- trunk/matplotlib/examples/image_masked.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/image_masked.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -4,7 +4,7 @@ ''' from pylab import * -import matplotlib.numerix.ma as ma +import matplotlib.numerix.npyma as ma import matplotlib.colors as colors delta = 0.025 Modified: trunk/matplotlib/examples/mathtext_wx.py =================================================================== --- trunk/matplotlib/examples/mathtext_wx.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/mathtext_wx.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -5,7 +5,7 @@ import matplotlib matplotlib.use("WxAgg") -from matplotlib.numerix import arange, sin, pi, cos, log +from numpy import arange, sin, pi, cos, log from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure @@ -42,14 +42,14 @@ self.figure = Figure() self.axes = self.figure.add_subplot(111) self.change_plot(0) - + self.canvas = FigureCanvas(self, -1, self.figure) self.sizer = wx.BoxSizer(wx.VERTICAL) self.add_buttonbar() self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.add_toolbar() # comment this out for no toolbar - + menuBar = wx.MenuBar() # File Menu @@ -104,21 +104,21 @@ def OnChangePlot(self, event): self.change_plot(event.GetId() - 1000) - + def change_plot(self, plot_number): t = arange(1.0,3.0,0.01) s = functions[plot_number][1](t) self.axes.clear() self.axes.plot(t, s) self.Refresh() - + class MyApp(wx.App): def OnInit(self): frame = CanvasFrame(None, "wxPython mathtext demo app") self.SetTopWindow(frame) frame.Show(True) return True - + app = MyApp() app.MainLoop() Modified: trunk/matplotlib/examples/mpl_with_glade.py =================================================================== --- trunk/matplotlib/examples/mpl_with_glade.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/mpl_with_glade.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -8,7 +8,7 @@ from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar from matplotlib.widgets import SpanSelector -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi import gtk import gtk.glade Modified: trunk/matplotlib/examples/multi_image.py =================================================================== --- trunk/matplotlib/examples/multi_image.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/multi_image.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -5,19 +5,20 @@ It also illustrates colorbar tick labelling with a multiplier. ''' -import pylab +from matplotlib.pyplot import figure, show, sci from matplotlib import cm, colors from matplotlib.font_manager import FontProperties -from matplotlib.numerix.mlab import amin, amax +from numpy import amin, amax, ravel +from numpy.random import rand Nr = 3 Nc = 2 -fig = pylab.gcf() +fig = figure() cmap = cm.cool figtitle = 'Multiple images' -t = pylab.gcf().text(0.5, 0.95, figtitle, +t = fig.text(0.5, 0.95, figtitle, horizontalalignment='center', fontproperties=FontProperties(size=16)) @@ -37,8 +38,8 @@ a.set_xticklabels([]) # Make some fake data with a range that varies # somewhat from one plot to the next. - data =((1+i+j)/10.0)*pylab.rand(10,20)*1e-6 - dd = pylab.ravel(data) + data =((1+i+j)/10.0)*rand(10,20)*1e-6 + dd = ravel(data) # Manually find the min and max of all colors for # use in setting the color scale. vmin = min(vmin, amin(dd)) @@ -60,12 +61,13 @@ # We need the following only if we want to run this # script interactively and be able to change the colormap. -pylab.sci(images[0]) -pylab.show() +sci(images[0]) +show() + Modified: trunk/matplotlib/examples/pcolor_nonuniform.py =================================================================== --- trunk/matplotlib/examples/pcolor_nonuniform.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/pcolor_nonuniform.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,11 +1,11 @@ -from pylab import figure, show -import matplotlib.numerix as nx +from matplotlib.pyplot import figure, show +import numpy as npy from matplotlib.image import NonUniformImage -x = nx.arange(-4, 4, 0.005) -y = nx.arange(-4, 4, 0.005) +x = npy.arange(-4, 4, 0.005) +y = npy.arange(-4, 4, 0.005) print 'Size %d points' % (len(x) * len(y)) -z = nx.sqrt(x[nx.NewAxis,:]**2 + y[:,nx.NewAxis]**2) +z = npy.sqrt(x[npy.newaxis,:]**2 + y[:,npy.newaxis]**2) fig = figure() ax = fig.add_subplot(111) Modified: trunk/matplotlib/examples/polar_bar.py =================================================================== --- trunk/matplotlib/examples/polar_bar.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/polar_bar.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,9 +1,8 @@ #!/usr/bin/env python -import matplotlib.numerix as nx -from matplotlib.mlab import linspace +import numpy as npy import matplotlib.cm as cm -from pylab import figure, show, rc +from matplotlib.pyplot import figure, show, rc # force square figure and square axes looks better for polar, IMO @@ -11,9 +10,9 @@ ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True) N = 20 -theta = nx.arange(0.0, 2*nx.pi, 2*nx.pi/N) -radii = 10*nx.mlab.rand(N) -width = nx.pi/4*nx.mlab.rand(N) +theta = npy.arange(0.0, 2*npy.pi, 2*npy.pi/N) +radii = 10*npy.random.rand(N) +width = npy.pi/4*npy.random.rand(N) bars = ax.bar(theta, radii, width=width, bottom=0.1) for r,bar in zip(radii, bars): bar.set_facecolor( cm.jet(r/10.)) Modified: trunk/matplotlib/examples/polar_demo.py =================================================================== --- trunk/matplotlib/examples/polar_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/polar_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -39,8 +39,8 @@ # See the pylab rgrids and thetagrids functions for # information on how to customize the grid locations and labels -import matplotlib.numerix as nx -from pylab import figure, show, rc +import numpy as npy +from matplotlib.pyplot import figure, show, rc # radar green, solid grid lines rc('grid', color='#316931', linewidth=1, linestyle='-') @@ -51,8 +51,8 @@ fig = figure(figsize=(8,8)) ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') -r = nx.arange(0, 3.0, 0.01) -theta = 2*nx.pi*r +r = npy.arange(0, 3.0, 0.01) +theta = 2*npy.pi*r ax.plot(theta, r, color='#ee8d18', lw=3) ax.set_rmax(2.0) Modified: trunk/matplotlib/examples/polar_legend.py =================================================================== --- trunk/matplotlib/examples/polar_legend.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/polar_legend.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,7 +1,7 @@ #!/usr/bin/env python -import matplotlib.numerix as nx -from pylab import figure, show, rc +import numpy as npy +from matplotlib.pyplot import figure, show, rc # radar green, solid grid lines rc('grid', color='#316931', linewidth=1, linestyle='-') @@ -12,8 +12,8 @@ fig = figure(figsize=(8,8)) ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') -r = nx.arange(0, 3.0, 0.01) -theta = 2*nx.pi*r +r = npy.arange(0, 3.0, 0.01) +theta = 2*npy.pi*r ax.plot(theta, r, color='#ee8d18', lw=3, label='a line') ax.plot(0.5*theta, r, color='blue', ls='--', lw=3, label='another line') ax.legend() Modified: trunk/matplotlib/examples/poly_editor.py =================================================================== --- trunk/matplotlib/examples/poly_editor.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/poly_editor.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -5,8 +5,7 @@ """ from matplotlib.artist import Artist from matplotlib.patches import Polygon, CirclePolygon -from matplotlib.numerix import sqrt, nonzero, equal, asarray, dot, Float -from matplotlib.numerix.mlab import amin +from numpy import sqrt, nonzero, equal, asarray, dot, amin from matplotlib.mlab import dist_point_to_segment Modified: trunk/matplotlib/examples/printing_in_wx.py =================================================================== --- trunk/matplotlib/examples/printing_in_wx.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/printing_in_wx.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -39,7 +39,7 @@ from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigCanvas from matplotlib.figure import Figure -import matplotlib.numerix as numpy +import numpy class PlotFrame(wx.Frame): help_msg=""" Menus for Modified: trunk/matplotlib/examples/pythonic_matplotlib.py =================================================================== --- trunk/matplotlib/examples/pythonic_matplotlib.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/pythonic_matplotlib.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -54,7 +54,7 @@ from pylab import figure, close, axes, subplot, show -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi t = arange(0.0, 1.0, 0.01) Modified: trunk/matplotlib/examples/scatter_masked.py =================================================================== --- trunk/matplotlib/examples/scatter_masked.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/scatter_masked.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,6 +1,6 @@ #!/usr/bin/env python from pylab import * -import matplotlib.numerix.ma as ma +import matplotlib.numerix.npyma as ma N = 100 r0 = 0.6 Modified: trunk/matplotlib/examples/strip_chart_demo.py =================================================================== --- trunk/matplotlib/examples/strip_chart_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/strip_chart_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -12,7 +12,7 @@ import gobject, gtk import matplotlib matplotlib.use('GTKAgg') -import matplotlib.numerix as nx +import numpy as npy from matplotlib.lines import Line2D @@ -36,9 +36,9 @@ def emitter(self, p=0.01): 'return a random value with probability p, else 0' - v = nx.mlab.rand(1) + v = npy.random.rand(1) if v>p: return 0. - else: return nx.mlab.rand(1) + else: return npy.random.rand(1) def update(self, *args): if self.background is None: return True Modified: trunk/matplotlib/examples/tex_demo.py =================================================================== --- trunk/matplotlib/examples/tex_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/tex_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -11,8 +11,8 @@ """ from matplotlib import rc -from matplotlib.numerix import arange, cos, pi -from pylab import figure, axes, plot, xlabel, ylabel, title, \ +from numpy import arange, cos, pi +from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \ grid, savefig, show Modified: trunk/matplotlib/examples/tex_unicode_demo.py =================================================================== --- trunk/matplotlib/examples/tex_unicode_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/tex_unicode_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -7,8 +7,8 @@ from matplotlib import rcParams rcParams['text.usetex']=True rcParams['text.latex.unicode']=True -from matplotlib.numerix import arange, cos, pi -from pylab import figure, axes, plot, xlabel, ylabel, title, \ +from numpy import arange, cos, pi +from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \ grid, savefig, show figure(1) Modified: trunk/matplotlib/examples/vline_demo.py =================================================================== --- trunk/matplotlib/examples/vline_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/vline_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -1,17 +1,17 @@ #!/usr/bin/env python -from pylab import * -from matplotlib.numerix import sin, exp, multiply, absolute, pi -from matplotlib.numerix.random_array import normal +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(multiply(s1,e1))+.05 + return absolute((s1*e1))+.05 t = arange(0.0, 5.0, 0.1) s = f(t) -nse = multiply(normal(0.0, 0.3, t.shape), s) +nse = normal(0.0, 0.3, t.shape) * s plot(t, s+nse, 'b^') vlines(t, [0], s) Modified: trunk/matplotlib/examples/webapp_demo.py =================================================================== --- trunk/matplotlib/examples/webapp_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/webapp_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -21,7 +21,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg from matplotlib.figure import Figure from matplotlib.cbook import iterable -import matplotlib.numerix as nx +import numpy as npy def make_fig(): """ @@ -40,9 +40,9 @@ line, = ax.plot([1,2,3], 'ro--', markersize=12, markerfacecolor='g') # make a translucent scatter collection - x = nx.mlab.rand(100) - y = nx.mlab.rand(100) - area = nx.pi*(10 * nx.mlab.rand(100))**2 # 0 to 10 point radiuses + x = npy.random.rand(100) + y = npy.random.rand(100) + area = npy.pi*(10 * npy.random.rand(100))**2 # 0 to 10 point radiuses c = ax.scatter(x,y,area) c.set_alpha(0.5) Modified: trunk/matplotlib/examples/wxcursor_demo.py =================================================================== --- trunk/matplotlib/examples/wxcursor_demo.py 2007-09-09 22:41:36 UTC (rev 3819) +++ trunk/matplotlib/examples/wxcursor_demo.py 2007-09-10 01:42:39 UTC (rev 3820) @@ -6,7 +6,7 @@ from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure -from matplotlib.numerix import arange, sin, pi +from numpy import arange, sin, pi import wx This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |