From: <ef...@us...> - 2007-11-09 19:37:20
|
Revision: 4191 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4191&view=rev Author: efiring Date: 2007-11-09 11:37:15 -0800 (Fri, 09 Nov 2007) Log Message: ----------- Remove numerix as nx from pylab Modified Paths: -------------- trunk/matplotlib/examples/animation_blit_fltk.py trunk/matplotlib/examples/annotation_demo.py trunk/matplotlib/examples/barcode_demo.py trunk/matplotlib/examples/broken_barh.py trunk/matplotlib/examples/clippath_test.py trunk/matplotlib/examples/custom_figure_class.py trunk/matplotlib/examples/date_demo_convert.py trunk/matplotlib/examples/dynamic_collection.py trunk/matplotlib/examples/fill_demo2.py trunk/matplotlib/examples/gradient_bar.py trunk/matplotlib/examples/interp_demo.py trunk/matplotlib/examples/lasso_demo.py trunk/matplotlib/examples/pick_event_demo.py trunk/matplotlib/examples/scatter_custom_symbol.py trunk/matplotlib/examples/scatter_star_poly.py trunk/matplotlib/examples/spy_demos.py trunk/matplotlib/examples/xcorr_demo.py trunk/matplotlib/examples/zoom_window.py trunk/matplotlib/lib/matplotlib/pylab.py Modified: trunk/matplotlib/examples/animation_blit_fltk.py =================================================================== --- trunk/matplotlib/examples/animation_blit_fltk.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/animation_blit_fltk.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -3,7 +3,7 @@ import matplotlib matplotlib.use('FltkAgg') import pylab as p -import numpy as nx +import numpy as npy import time @@ -29,7 +29,7 @@ self.background = self.canvas.copy_from_bbox(self.ax.bbox) self.canvas.restore_region(self.background) # update the data - line.set_ydata(nx.sin(x+self.cnt/10.0)) + line.set_ydata(npy.sin(x+self.cnt/10.0)) # just draw the animated artist self.ax.draw_artist(line) # just redraw the axes rectangle @@ -45,8 +45,8 @@ p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs 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) +x = npy.arange(0,2*npy.pi,0.01) +line, = p.plot(x, npy.sin(x), animated=True) p.draw() anim=animator(ax) Modified: trunk/matplotlib/examples/annotation_demo.py =================================================================== --- trunk/matplotlib/examples/annotation_demo.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/annotation_demo.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -32,17 +32,19 @@ """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.patches import Ellipse +import numpy as npy + if 1: # if only one location is given, the text and xypoint being # annotated are assumed to be the same fig = figure() ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5)) - t = nx.arange(0.0, 5.0, 0.01) - s = nx.cos(2*nx.pi*t) + t = npy.arange(0.0, 5.0, 0.01) + s = npy.cos(2*npy.pi*t) line, = ax.plot(t, s, lw=3, color='purple') ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction', @@ -85,8 +87,8 @@ # respected fig = figure() ax = fig.add_subplot(111, polar=True) - r = nx.arange(0,1,0.001) - theta = 2*2*nx.pi*r + r = npy.arange(0,1,0.001) + theta = 2*2*npy.pi*r line, = ax.plot(theta, r, color='#ee8d18', lw=3) ind = 800 @@ -115,8 +117,8 @@ ax.add_artist(el) el.set_clip_box(ax.bbox) ax.annotate('the top', - xy=(nx.pi/2., 10.), # theta, radius - xytext=(nx.pi/3, 20.), # theta, radius + xy=(npy.pi/2., 10.), # theta, radius + xytext=(npy.pi/3, 20.), # theta, radius xycoords='polar', textcoords='polar', arrowprops=dict(facecolor='black', shrink=0.05), Modified: trunk/matplotlib/examples/barcode_demo.py =================================================================== --- trunk/matplotlib/examples/barcode_demo.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/barcode_demo.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,14 +1,16 @@ -from pylab import figure, show, cm, nx +from matplotlib.pyplot import figure, show, cm +from numpy import where +from numpy.random import rand # the bar -x = nx.where(nx.mlab.rand(500)>0.7, 1.0, 0.0) +x = where(rand(500)>0.7, 1.0, 0.0) axprops = dict(xticks=[], yticks=[]) barprops = dict(aspect='auto', cmap=cm.binary, interpolation='nearest') fig = figure() -# a vertical barcode +# a vertical barcode -- this is broken at present x.shape = len(x), 1 ax = fig.add_axes([0.1, 0.3, 0.1, 0.6], **axprops) ax.imshow(x, **barprops) Modified: trunk/matplotlib/examples/broken_barh.py =================================================================== --- trunk/matplotlib/examples/broken_barh.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/broken_barh.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -2,7 +2,7 @@ """ Make a "broken" horizontal bar plot, ie one with gaps """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show fig = figure() ax = fig.add_subplot(111) Modified: trunk/matplotlib/examples/clippath_test.py =================================================================== --- trunk/matplotlib/examples/clippath_test.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/clippath_test.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,9 +1,10 @@ -from pylab import figure, show, nx +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 @@ -58,9 +59,9 @@ fig = figure(figsize=(8,8)) ax = fig.add_subplot(111) -t = nx.arange(0.0, 4.0, 0.01) -s = 2*nx.sin(2*nx.pi*8*t) +t = arange(0.0, 4.0, 0.01) +s = 2*sin(2*pi*8*t) -line, = ax.plot(t, 2*(nx.mlab.rand(len(t))-0.5), 'b-') +line, = ax.plot(t, 2*(rand(len(t))-0.5), 'b-') clipwin = ClipWindow(ax, line) show() Modified: trunk/matplotlib/examples/custom_figure_class.py =================================================================== --- trunk/matplotlib/examples/custom_figure_class.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/custom_figure_class.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,7 +1,7 @@ """ You can pass a custom Figure constructor to figure if youy want to derive from the default Figure. This simple example creates a figure with a figure title """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.figure import Figure class MyFigure(Figure): Modified: trunk/matplotlib/examples/date_demo_convert.py =================================================================== --- trunk/matplotlib/examples/date_demo_convert.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/date_demo_convert.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,16 +1,16 @@ #!/usr/bin/env python import datetime -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange +from numpy import arange - date1 = datetime.datetime( 2000, 3, 2) date2 = datetime.datetime( 2000, 3, 6) delta = datetime.timedelta(hours=6) dates = drange(date1, date2, delta) -y = nx.arange( len(dates)*1.0) +y = arange( len(dates)*1.0) fig = figure() ax = fig.add_subplot(111) @@ -25,7 +25,7 @@ # tick, not the base multiple ax.xaxis.set_major_locator( DayLocator() ) -ax.xaxis.set_minor_locator( HourLocator(nx.arange(0,25,6)) ) +ax.xaxis.set_minor_locator( HourLocator(arange(0,25,6)) ) ax.xaxis.set_major_formatter( DateFormatter('%Y-%m-%d') ) ax.fmt_xdata = DateFormatter('%Y-%m-%d %H:%M:%S') Modified: trunk/matplotlib/examples/dynamic_collection.py =================================================================== --- trunk/matplotlib/examples/dynamic_collection.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/dynamic_collection.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,7 +1,8 @@ import random from matplotlib.collections import RegularPolyCollection import matplotlib.cm as cm -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +from numpy.random import rand fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) @@ -29,8 +30,8 @@ press 'a' to add a random point from the collection, 'd' to delete one """ if event.key=='a': - x,y = nx.mlab.rand(2) - color = cm.jet(nx.mlab.rand()) + x,y = rand(2) + color = cm.jet(rand()) offsets.append((x,y)) facecolors.append(color) fig.canvas.draw() Modified: trunk/matplotlib/examples/fill_demo2.py =================================================================== --- trunk/matplotlib/examples/fill_demo2.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/fill_demo2.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,8 +1,10 @@ -from pylab import figure, nx, show +from matplotlib.pyplot import figure, show +from numpy import arange, sin, pi + fig = figure() ax = fig.add_subplot(111) -t = nx.arange(0.0,3.01,0.01) -s = nx.sin(2*nx.pi*t) -c = nx.sin(4*nx.pi*t) +t = arange(0.0,3.01,0.01) +s = sin(2*pi*t) +c = sin(4*pi*t) ax.fill(t, s, 'b', t, c, 'g', alpha=0.2) show() Modified: trunk/matplotlib/examples/gradient_bar.py =================================================================== --- trunk/matplotlib/examples/gradient_bar.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/gradient_bar.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,4 +1,6 @@ -from pylab import figure, show, nx, cm +from matplotlib.pyplot import figure, show, cm +from numpy import arange +from numpy.random import rand def gbar(ax, x, y, width=0.5, bottom=0): X = [[.6, .6],[.7,.7]] @@ -19,8 +21,8 @@ extent=(xmin, xmax, ymin, ymax), alpha=1) N = 10 -x = nx.arange(N)+0.25 -y = nx.mlab.rand(N) +x = arange(N)+0.25 +y = rand(N) gbar(ax, x, y, width=0.7) ax.set_aspect('normal') show() Modified: trunk/matplotlib/examples/interp_demo.py =================================================================== --- trunk/matplotlib/examples/interp_demo.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/interp_demo.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,6 +1,9 @@ -from pylab import figure, show, nx, linspace, stineman_interp -x = linspace(0,2*nx.pi,20); -y = nx.sin(x); yp = None +from matplotlib.pyplot import figure, show +from numpy import pi, sin, linspace +from matplotlib.mlab import stineman_interp + +x = linspace(0,2*pi,20); +y = sin(x); yp = None xi = linspace(x[0],x[-1],100); yi = stineman_interp(xi,x,y,yp); Modified: trunk/matplotlib/examples/lasso_demo.py =================================================================== --- trunk/matplotlib/examples/lasso_demo.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/lasso_demo.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -13,7 +13,9 @@ from matplotlib.colors import colorConverter from matplotlib.collections import RegularPolyCollection -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +from numpy import nonzero +from numpy.random import rand class Datum: colorin = colorConverter.to_rgba('red') @@ -47,9 +49,7 @@ self.cid = self.canvas.mpl_connect('button_press_event', self.onpress) def callback(self, verts): - #print 'all done', verts - #ind = matplotlib.mlab._inside_poly_deprecated(self.xys, verts) - ind = nx.nonzero(points_inside_poly(self.xys, verts)) + ind = nonzero(points_inside_poly(self.xys, verts))[0] for i in range(self.Nxy): if i in ind: self.facecolors[i] = Datum.colorin @@ -66,7 +66,7 @@ # acquire a lock on the widget drawing self.canvas.widgetlock(self.lasso) -data = [Datum(*xy) for xy in nx.mlab.rand(100, 2)] +data = [Datum(*xy) for xy in rand(100, 2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) Modified: trunk/matplotlib/examples/pick_event_demo.py =================================================================== --- trunk/matplotlib/examples/pick_event_demo.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/pick_event_demo.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -63,23 +63,25 @@ The examples below illustrate each of these methods. """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.lines import Line2D from matplotlib.patches import Patch, Rectangle from matplotlib.text import Text from matplotlib.image import AxesImage +import numpy as npy +from numpy.random import rand if 1: # simple picking, lines, rectangles and text fig = figure() ax1 = fig.add_subplot(211) ax1.set_title('click on points, rectangles or text', picker=True) ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) - line, = ax1.plot(nx.mlab.rand(100), 'o', picker=5) # 5 points tolerance + line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance # pick the rectangle ax2 = fig.add_subplot(212) - bars = ax2.bar(range(10), nx.mlab.rand(10), picker=True) + bars = ax2.bar(range(10), rand(10), picker=True) for label in ax2.get_xticklabels(): # make the xtick labels pickable label.set_picker(True) @@ -90,7 +92,7 @@ xdata = thisline.get_xdata() ydata = thisline.get_ydata() ind = event.ind - print 'onpick1 line:', zip(nx.take(xdata, ind), nx.take(ydata, ind)) + print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind)) elif isinstance(event.artist, Rectangle): patch = event.artist print 'onpick1 patch:', patch.get_verts() @@ -122,12 +124,12 @@ xdata = line.get_xdata() ydata = line.get_ydata() maxd = 0.05 - d = nx.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.) + d = npy.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.) - ind = nx.nonzero(nx.less_equal(d, maxd)) + ind = npy.nonzero(npy.less_equal(d, maxd)) if len(ind): - pickx = nx.take(xdata, ind) - picky = nx.take(ydata, ind) + pickx = npy.take(xdata, ind) + picky = npy.take(ydata, ind) props = dict(ind=ind, pickx=pickx, picky=picky) return True, props else: @@ -139,16 +141,16 @@ fig = figure() ax1 = fig.add_subplot(111) ax1.set_title('custom picker for line data') - line, = ax1.plot(nx.mlab.rand(100), nx.mlab.rand(100), 'o', picker=line_picker) + line, = ax1.plot(rand(100), rand(100), 'o', picker=line_picker) fig.canvas.mpl_connect('pick_event', onpick2) if 1: # picking on a scatter plot (matplotlib.collections.RegularPolyCollection) - x, y, c, s = nx.mlab.rand(4, 100) + x, y, c, s = rand(4, 100) def onpick3(event): ind = event.ind - print 'onpick3 scatter:', ind, nx.take(x, ind), nx.take(y, ind) + print 'onpick3 scatter:', ind, npy.take(x, ind), npy.take(y, ind) fig = figure() ax1 = fig.add_subplot(111) @@ -159,10 +161,10 @@ if 1: # picking images (matplotlib.image.AxesImage) fig = figure() ax1 = fig.add_subplot(111) - im1 = ax1.imshow(nx.rand(10,5), extent=(1,2,1,2), picker=True) - im2 = ax1.imshow(nx.rand(5,10), extent=(3,4,1,2), picker=True) - im3 = ax1.imshow(nx.rand(20,25), extent=(1,2,3,4), picker=True) - im4 = ax1.imshow(nx.rand(30,12), extent=(3,4,3,4), picker=True) + im1 = ax1.imshow(rand(10,5), extent=(1,2,1,2), picker=True) + im2 = ax1.imshow(rand(5,10), extent=(3,4,1,2), picker=True) + im3 = ax1.imshow(rand(20,25), extent=(1,2,3,4), picker=True) + im4 = ax1.imshow(rand(30,12), extent=(3,4,3,4), picker=True) ax1.axis([0,5,0,5]) def onpick4(event): Modified: trunk/matplotlib/examples/scatter_custom_symbol.py =================================================================== --- trunk/matplotlib/examples/scatter_custom_symbol.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/scatter_custom_symbol.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,12 +1,14 @@ -from pylab import figure, nx, show +from matplotlib.pyplot import figure, show +from numpy import arange, pi, cos, sin, pi +from numpy.random import rand # unit area ellipse rx, ry = 3., 1. -area = rx * ry * nx.pi -theta = nx.arange(0, 2*nx.pi+0.01, 0.1) -verts = zip(rx/area*nx.cos(theta), ry/area*nx.sin(theta)) +area = rx * ry * pi +theta = arange(0, 2*pi+0.01, 0.1) +verts = zip(rx/area*cos(theta), ry/area*sin(theta)) -x,y,s,c = nx.mlab.rand(4, 30) +x,y,s,c = rand(4, 30) s*= 10**2. fig = figure() Modified: trunk/matplotlib/examples/scatter_star_poly.py =================================================================== --- trunk/matplotlib/examples/scatter_star_poly.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/scatter_star_poly.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,7 +1,7 @@ import pylab -x = pylab.nx.mlab.rand(10) -y = pylab.nx.mlab.rand(10) +x = pylab.rand(10) +y = pylab.rand(10) pylab.subplot(321) pylab.scatter(x,y,s=80,marker=">") Modified: trunk/matplotlib/examples/spy_demos.py =================================================================== --- trunk/matplotlib/examples/spy_demos.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/spy_demos.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -2,7 +2,8 @@ Plot the sparsity pattern of arrays """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +import numpy fig = figure() ax1 = fig.add_subplot(221) @@ -10,7 +11,7 @@ ax3 = fig.add_subplot(223) ax4 = fig.add_subplot(224) -x = nx.mlab.randn(20,20) +x = numpy.random.randn(20,20) x[5] = 0. x[:,12] = 0. Modified: trunk/matplotlib/examples/xcorr_demo.py =================================================================== --- trunk/matplotlib/examples/xcorr_demo.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/xcorr_demo.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -1,6 +1,7 @@ -from pylab import figure, show, nx +from matplotlib.pylab import figure, show +import numpy -x,y = nx.mlab.randn(2,100) +x,y = numpy.random.randn(2,100) fig = figure() ax1 = fig.add_subplot(211) ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True) @@ -13,3 +14,4 @@ ax2.axhline(0, color='black', lw=2) show() + Modified: trunk/matplotlib/examples/zoom_window.py =================================================================== --- trunk/matplotlib/examples/zoom_window.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/examples/zoom_window.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -9,15 +9,17 @@ Note the diameter of the circles in the scatter are defined in points**2, so their size is independent of the zoom """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +import numpy figsrc = figure() figzoom = figure() axsrc = figsrc.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) -axzoom = figzoom.add_subplot(111, xlim=(0.45,0.55), ylim=(0.4,.6), autoscale_on=False) +axzoom = figzoom.add_subplot(111, xlim=(0.45,0.55), ylim=(0.4,.6), + autoscale_on=False) axsrc.set_title('Click to zoom') axzoom.set_title('zoom window') -x,y,s,c = nx.mlab.rand(4,200) +x,y,s,c = numpy.random.rand(4,200) s *= 200 Modified: trunk/matplotlib/lib/matplotlib/pylab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pylab.py 2007-11-09 19:23:42 UTC (rev 4190) +++ trunk/matplotlib/lib/matplotlib/pylab.py 2007-11-09 19:37:15 UTC (rev 4191) @@ -202,8 +202,13 @@ from cbook import flatten, is_string_like, exception_to_str, popd, \ silent_list, iterable, enumerate, dedent -import matplotlib.numerix as nx import numpy as npy +# The masked array namespace is brought in as ma; getting +# this from numerix allows one to select either numpy.ma or +# Pierre G-M's maskedarray implementation, which may +# replace the present numpy.ma implementation in a future +# numpy release. +from matplotlib.numerix import npyma as ma from matplotlib import mpl # pulls in most modules This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |