From: <jd...@us...> - 2007-11-12 16:31:32
|
Revision: 4223 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4223&view=rev Author: jdh2358 Date: 2007-11-12 08:31:28 -0800 (Mon, 12 Nov 2007) Log Message: ----------- added some mlab imports back to pylab Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/Makefile trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/matplotlib/pylab.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-11-12 15:36:08 UTC (rev 4222) +++ trunk/matplotlib/API_CHANGES 2007-11-12 16:31:28 UTC (rev 4223) @@ -1,4 +1,3 @@ - Moved mlab.csv2rec -> recutils.csv2rec Added ax kwarg to pyplot.colorbar and Figure.colorbar so that one can specify the axes object from which space for the colorbar Modified: trunk/matplotlib/Makefile =================================================================== --- trunk/matplotlib/Makefile 2007-11-12 15:36:08 UTC (rev 4222) +++ trunk/matplotlib/Makefile 2007-11-12 16:31:28 UTC (rev 4223) @@ -1,6 +1,6 @@ # Makefile for matplotlib -PYTHON = /usr/bin/python2.5 +PYTHON = `which python` VERSION = `${PYTHON} setup.py --version` DISTFILES = API_CHANGES KNOWN_BUGS INSTALL README TODO license \ @@ -12,11 +12,11 @@ clean: ${PYTHON} setup.py clean;\ - rm -f *.png *.ps *.eps *.svg *.jpg + rm -f *.png *.ps *.eps *.svg *.jpg *.pdf find . -name "_tmp*.py" | xargs rm -f;\ find . \( -name "*~" -o -name "*.pyc" \) | xargs rm -f;\ - find examples \( -name "*.svg" -o -name "*.png" -o -name "*.ps" -o -name "*.eps" -o -name "*.tar" -o -name "*.gz" -o -name "*.log" -o -name "*.aux" -o -name "*.tex" \) | xargs rm -f - find unit \( -name "*.png" -o -name "*.ps" -o -name "*.eps" \) | xargs rm -f + find examples \( -name "*.svg" C-o -name "*.png" -o -name "*.pdf" -o -name "*.ps" -o -name "*.eps" -o -name "*.tar" -o -name "*.gz" -o -name "*.log" -o -name "*.aux" -o -name "*.tex" \) | xargs rm -f + find unit \( -name "*.png" -o -name "*.ps" -o -name "*.pdf" -o -name "*.eps" \) | xargs rm -f find . \( -name "#*" -o -name ".#*" -o -name ".*~" -o -name "*~" \) | xargs rm -f Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007-11-12 15:36:08 UTC (rev 4222) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007-11-12 16:31:28 UTC (rev 4223) @@ -4798,6 +4798,39 @@ return mtable.table(self, **kwargs) table.__doc__ = cbook.dedent(table.__doc__) % martist.kwdocd + def twinx(self): + """ + ax = twinx() + + create a twin of Axes for generating a plot with a sharex + x-axis but independent y axis. The y-axis of self will have + ticks on left and the returned axes will have ticks on the + right + """ + + ax2 = self.figure.add_axes(self.get_position(), sharex=self, frameon=False) + ax2.yaxis.tick_right() + ax2.yaxis.set_label_position('right') + self.yaxis.tick_left() + return ax2 + + def twiny(self): + """ + ax = twiny() + + create a twin of Axes for generating a plot with a shared + y-axis but independent x axis. The x-axis of self will have + ticks on bottom and the returned axes will have ticks on the + top + """ + + ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False) + ax2.xaxis.tick_top() + ax2.xaxis.set_label_position('top') + self.xaxis.tick_bottom() + return ax2 + + #### Data analysis Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-11-12 15:36:08 UTC (rev 4222) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-11-12 16:31:28 UTC (rev 4223) @@ -442,8 +442,9 @@ kw = dict(rowvar=False) return npy.corrcoef(*args, **kw) -def polyfit(x,y,N): +def polyfit(*args, **kwargs): """ + def polyfit(x,y,N) Do a best fit polynomial of order N of y to x. Return value is a vector of polynomial coefficients [pk ... p1 p0]. Eg, for N=2 @@ -480,21 +481,13 @@ See also polyval """ - x = npy.asarray(x, dtype=npy.float_) - #y = npy.asarray(y, dtype=npy.float_) - #y.shape = (len(y),1) - #X = npy.matrix(npy.vander(x, N+1)) - #Xt = npy.matrix(X.transpose()) - #c = npy.array(npy.linalg.inv(Xt*X)*Xt*y) # convert back to array - #c.shape = (N+1,) - #return c - X = npy.vander(x, N+1) - return npy.linalg.lstsq(X, y)[0] + warnings.warn("use numpy.poyfit", DeprecationWarning) + return npy.polyfit(*args, **kw) -def polyval(p,x): +def polyval(*args, **kwargs): """ y = polyval(p,x) @@ -510,14 +503,11 @@ See also polyfit """ - x = npy.asarray(x, dtype=npy.float_) - p = npy.asarray(p, dtype=npy.float_).reshape((len(p),1)) - X = npy.vander(x,len(p)) - y = npy.dot(X,p) - return y.reshape(x.shape) + warnings.warn("use numpy.polyval", DeprecationWarning) + return npy.polyval(*args, **kw) -def vander(x,N=None): +def vander(*args, **kwargs): """ X = vander(x,N=None) @@ -527,7 +517,7 @@ """ warnings.warn("Use numpy.vander()", DeprecationWarning) - return npy.vander(x, N) + return npy.vander(*args, **kwargs) def donothing_callback(*args): @@ -1262,6 +1252,17 @@ fh = cbook.to_filehandle(fname) X = [] + if delimiter==' ': + # space splitting is a special case since x.split() is what + # you want, not x.split(' ') + def splitfunc(x): + return x.split() + else: + def splitfunc(x): + return x.split(delimiter) + + + converterseq = None for i,line in enumerate(fh): if i<skiprows: continue @@ -1269,13 +1270,13 @@ if not len(line): continue if converterseq is None: converterseq = [converters.get(j,float) - for j,val in enumerate(line.split(delimiter))] + for j,val in enumerate(splitfunc(line))] if usecols is not None: vals = line.split(delimiter) row = [converterseq[j](vals[j]) for j in usecols] else: row = [converterseq[j](val) - for j,val in enumerate(line.split(delimiter))] + for j,val in enumerate(splitfunc(line))] thisLen = len(row) X.append(row) @@ -2281,7 +2282,7 @@ FormatFloat.__init__(self, precision, scale=1e-6) -class FormatDate(FormatString): +class FormatDate(FormatObj): def __init__(self, fmt): self.fmt = fmt @@ -2301,7 +2302,7 @@ npy.float32 : FormatFloat(), npy.float64 : FormatFloat(), npy.object_ : FormatObj(), - npy.string_ : FormatString(), + npy.string_ : FormatObj(), } def get_formatd(r, formatd=None): @@ -2658,7 +2659,7 @@ - def rec2gtk(r, formatd=None, rownum=0): + def rec2gtk(r, formatd=None, rownum=0, autowin=True): """ save record array r to excel pyExcelerator worksheet ws starting at rownum. if ws is string like, assume it is a @@ -2666,7 +2667,13 @@ formatd is a dictionary mapping dtype name -> FormatXL instances - The next rownum after writing is returned + This function creates a SortedStringsScrolledWindow (derived + from gtk.ScrolledWindow) and returns it. if autowin is True, + a gtk.Window is created, attached to the + SortedStringsScrolledWindow instance, shown and returned. If + autowin=False, the caller is responsible for adding the + SortedStringsScrolledWindow instance to a gtk widget and + showing it. """ @@ -2692,6 +2699,14 @@ for row in r: scroll.add_row(row) + + if autowin: + win = gtk.Window() + win.set_default_size(800,600) + win.add(scroll) + win.show_all() + scroll.win = win + return scroll Modified: trunk/matplotlib/lib/matplotlib/pylab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pylab.py 2007-11-12 15:36:08 UTC (rev 4222) +++ trunk/matplotlib/lib/matplotlib/pylab.py 2007-11-12 16:31:28 UTC (rev 4223) @@ -249,6 +249,19 @@ from numpy.random import * from numpy.linalg import * +from matplotlib.mlab import load, window_hanning, window_none, conv, detrend, demean, \ + detrend_mean, detrend_none, detrend_linear, entropy, normpdf, levypdf, \ + find, longest_contiguous_ones, longest_ones, prepca, prctile, prctile_rank, \ + center_matrix, rk4, bivariate_normal, get_xyz_where, get_sparse_matrix, dist, \ + dist_point_to_segment, segments_intersect, fftsurr, liaupunov, movavg, \ + save, load, slopes, stineman_interp, inside_poly, poly_below, poly_between, exp_safe, \ + amap, rms_flat, l1norm, l2norm, norm_flat, frange, diagonal_matrix, identity, \ + base_repr, binary_repr, log2, ispower2, fromfunction_kw, rem, norm, orth, rank, sqrtm,\ + mfuncC, approx_real, rec_append_field, rec_drop_fields, rec_join, csv2rec, rec2csv + + + + # old style--if True, override standard numpy with oldnumeric if False: from numpy.oldnumeric import array, zeros, shape, rank, size, fromstring,\ Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2007-11-12 15:36:08 UTC (rev 4222) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2007-11-12 16:31:28 UTC (rev 4223) @@ -492,14 +492,8 @@ """ if ax is None: ax=gca() - - - ax2 = gcf().add_axes(ax.get_position(), sharex=ax, frameon=False) - ax2.yaxis.tick_right() - ax2.yaxis.set_label_position('right') - ax.yaxis.tick_left() draw_if_interactive() - return ax2 + return ax.twinx() def twiny(ax=None): @@ -510,14 +504,8 @@ """ if ax is None: ax=gca() - - - ax2 = gcf().add_axes(ax.get_position(), sharey=ax, frameon=False) - ax2.xaxis.tick_top() - ax2.xaxis.set_label_position('top') - ax.xaxis.tick_bottom() draw_if_interactive() - return ax2 + return ax.twiny() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |