You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jd...@us...> - 2007-10-29 18:53:06
|
Revision: 4061 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4061&view=rev Author: jdh2358 Date: 2007-10-29 11:52:41 -0700 (Mon, 29 Oct 2007) Log Message: ----------- fixed some examples bugs Modified Paths: -------------- trunk/matplotlib/examples/keypress_demo.py trunk/matplotlib/examples/units/bar_unit_demo.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/matplotlib/patches.py Modified: trunk/matplotlib/examples/keypress_demo.py =================================================================== --- trunk/matplotlib/examples/keypress_demo.py 2007-10-29 18:37:17 UTC (rev 4060) +++ trunk/matplotlib/examples/keypress_demo.py 2007-10-29 18:52:41 UTC (rev 4061) @@ -1,21 +1,23 @@ #!/usr/bin/env python """ Show how to connect to keypress events - -Note, on the wx backend on some platforms (eg linux), you have to -first click on the figure before the keypress events are activated. -If you know how to fix this, please email us! """ -from pylab import * +import numpy as n +from pylab import figure, show def press(event): print 'press', event.key - if event.key=='g': - grid() - draw() + if event.key=='x': + visible = xl.get_visible() + xl.set_visible(not visible) + fig.canvas.draw() -connect('key_press_event', press) +fig = figure() +ax = fig.add_subplot(111) -title('press g to toggle grid') -plot(rand(12), rand(12), 'go') +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() Modified: trunk/matplotlib/examples/units/bar_unit_demo.py =================================================================== --- trunk/matplotlib/examples/units/bar_unit_demo.py 2007-10-29 18:37:17 UTC (rev 4060) +++ trunk/matplotlib/examples/units/bar_unit_demo.py 2007-10-29 18:52:41 UTC (rev 4061) @@ -4,15 +4,16 @@ N = 5 menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm) -menStd = (20*cm, 30*cm, 32*cm, 10*cm, 20*cm) +menStd = ( 20*cm, 30*cm, 32*cm, 10*cm, 20*cm) fig = figure() ax = fig.add_subplot(111) ind = nx.arange(N) # the x locations for the groups -width = 0.35 # the width of the bars +width = 0.35 # the width of the bars p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd) + womenMeans = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm) womenStd = (30*cm, 25*cm, 20*cm, 31*cm, 22*cm) p2 = ax.bar(ind+width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007-10-29 18:37:17 UTC (rev 4060) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007-10-29 18:52:41 UTC (rev 4061) @@ -1173,6 +1173,8 @@ # Otherwise, it will compute the bounds of it's current data # and the data in xydata xys = npy.asarray(xys) + + self.dataLim.update_numerix_xy(xys, -1) @@ -3242,22 +3244,7 @@ patches = [] - # lets do some conversions now - if self.xaxis is not None: - xconv = self.xaxis.converter - if xconv is not None: - units = self.xaxis.get_units() - left = xconv.convert( left, units ) - width = xconv.convert( width, units ) - if self.yaxis is not None: - yconv = self.yaxis.converter - if yconv is not None : - units = self.yaxis.get_units() - bottom = yconv.convert( bottom, units ) - height = yconv.convert( height, units ) - - if align == 'edge': pass elif align == 'center': @@ -3645,23 +3632,24 @@ a list of error bar cap lines, the third element is a list of line collections for the horizontal and vertical error ranges """ + self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) if not self._hold: self.cla() - # make sure all the args are iterable arrays - if not iterable(x): x = npy.array([x]) - else: x = npy.asarray(x) + # make sure all the args are iterable; use lists not arrays to preserve units + if not iterable(x): + x = [x] - if not iterable(y): y = npy.array([y]) - else: y = npy.asarray(y) + if not iterable(y): + y = [y] if xerr is not None: - if not iterable(xerr): xerr = npy.array([xerr]) - else: xerr = npy.asarray(xerr) + if not iterable(xerr): + xerr = [xerr] if yerr is not None: - if not iterable(yerr): yerr = npy.array([yerr]) - else: yerr = npy.asarray(yerr) + if not iterable(yerr): + yerr = [yerr] l0 = None @@ -3677,7 +3665,9 @@ if 'lw' in kwargs: lines_kw['lw']=kwargs['lw'] - if not iterable(lolims): lolims = npy.array([lolims]*len(x), bool) + # arrays fine here, they are booleans and hence not units + if not iterable(lolims): + lolims = npy.asarray([lolims]*len(x), bool) else: lolims = npy.asarray(lolims, bool) if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool) @@ -3699,12 +3689,14 @@ plot_kw['mew']=kwargs['mew'] if xerr is not None: - if len(xerr.shape) == 1: - left = x-xerr - right = x+xerr + if iterable(xerr) and len(xerr)==2: + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in zip(x,xerr[0])] + right = [thisx+thiserr for (thisx, thiserr) in zip(x,xerr[1])] else: - left = x-xerr[0] - right = x+xerr[1] + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in zip(x,xerr)] + right = [thisx+thiserr for (thisx, thiserr) in zip(x,xerr)] barcols.append( self.hlines(y, left, right, **lines_kw ) ) if capsize > 0: @@ -3723,12 +3715,14 @@ caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) if yerr is not None: - if len(yerr.shape) == 1: - lower = y-yerr - upper = y+yerr + if iterable(yerr) and len(yerr)==2: + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in zip(y,yerr[0])] + upper = [thisy+thiserr for (thisy, thiserr) in zip(y,yerr[1])] else: - lower = y-yerr[0] - upper = y+yerr[1] + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in zip(y,yerr)] + upper = [thisy+thiserr for (thisy, thiserr) in zip(y,yerr)] barcols.append( self.vlines(x, lower, upper, **lines_kw) ) if capsize > 0: Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-10-29 18:37:17 UTC (rev 4060) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-10-29 18:52:41 UTC (rev 4061) @@ -1455,7 +1455,116 @@ for row in r: writer.writerow(map(str, row)) fh.close() + +try: + import pyExcelerator as excel +except ImportError: + pass +else: + class Format: + xlstyle = None + def convert(self, x): + return x + + class FormatFloat(Format): + def __init__(self, precision=4): + self.xlstyle = excel.XFStyle() + zeros = ''.join(['0']*precision) + self.xlstyle.num_format_str = '#,##0.%s;[RED]-#,##0.%s'%(zeros, zeros) + + class FormatInt(Format): + convert = int + def __init__(self): + + self.xlstyle = excel.XFStyle() + self.xlstyle.num_format_str = '#,##;[RED]-#,##' + + class FormatPercent(Format): + def __init__(self, precision=4): + self.xlstyle = excel.XFStyle() + zeros = ''.join(['0']*precision) + self.xlstyle.num_format_str = '0.%s%;[RED]-0.%s%'%(zeros, zeros) + + class FormatThousands(FormatFloat): + def __init__(self, precision=1): + FormatFloat.__init__(self, precision) + + def convert(self, x): + return x/1e3 + + class FormatMillions(FormatFloat): + def __init__(self, precision=1): + FormatFloat.__init__(self, precision) + + def convert(self, x): + return x/1e6 + + class FormatDate(Format): + def __init__(self, fmt='%Y-%m-%d'): + self.fmt = fmt + + def convert(self, val): + return val.strftime(self.fmt) + + class FormatDatetime(Format): + def __init__(self, fmt='%Y-%m-%d %H:%M:%S'): + self.fmt = fmt + + def convert(self, val): + return val.strftime(self.fmt) + + class FormatObject(Format): + + def convert(self, x): + return str(x) + + def rec2excel(ws, r, formatd=None, rownum=0): + """ + save record array r to excel pyExcelerator worksheet ws + starting at rownum + + formatd is a dictionary mapping dtype name -> Format instances + """ + + if formatd is None: + formatd = dict() + + formats = [] + for i, name in enumerate(r.dtype.names): + dt = r.dtype[name] + format = formatd.get(name) + if format is None: + format = rec2excel.formatd.get(dt.type, FormatObject()) + + ws.write(rownum, i, name) + formats.append(format) + + rownum+=1 + + ind = npy.arange(len(r.dtype.names)) + for row in r: + for i in ind: + val = row[i] + format = formats[i] + val = format.convert(val) + if format.xlstyle is None: + ws.write(rownum, i, val) + else: + ws.write(rownum, i, val, format.xlstyle) + rownum += 1 + rec2excel.formatd = { + npy.int16 : FormatInt(), + npy.int32 : FormatInt(), + npy.int64 : FormatInt(), + npy.float32 : FormatFloat(), + npy.float64 : FormatFloat(), + npy.object_ : FormatObject(), + npy.string_ : Format(), + } + + + # some record array helpers def rec_append_field(rec, name, arr, dtype=None): 'return a new record array with field name populated with data from array arr' Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2007-10-29 18:37:17 UTC (rev 4060) +++ trunk/matplotlib/lib/matplotlib/patches.py 2007-10-29 18:52:41 UTC (rev 4061) @@ -350,8 +350,10 @@ Return the vertices of the rectangle """ x, y = self.xy - left, right = self.convert_xunits((x, x + self.width)) - bottom, top = self.convert_yunits((y, y + self.height)) + left = self.convert_xunits(x) + right = self.convert_xunits(x + self.width) + bottom = self.convert_yunits(y) + top = self.convert_yunits(y+self.height) return ( (left, bottom), (left, top), (right, top), (right, bottom), @@ -806,8 +808,15 @@ def get_verts(self): xcenter, ycenter = self.center + width, height = self.width, self.height - width, height = self.width, self.height + xcenter = self.convert_xunits(xcenter) + width = self.convert_xunits(width) + ycenter = self.convert_yunits(ycenter) + height = self.convert_xunits(height) + + + angle = self.angle theta = npy.arange(0.0, 360.0, 1.0)*npy.pi/180.0 @@ -820,8 +829,6 @@ [npy.sin(rtheta), npy.cos(rtheta)], ]) - x = self.convert_xunits(x) - y = self.convert_yunits(y) x, y = npy.dot(R, npy.array([x, y])) x += xcenter @@ -857,6 +864,8 @@ x, y = self.center x = self.convert_xunits(x) y = self.convert_yunits(y) + w = self.convert_xunits(self.width)/2. + h = self.convert_yunits(self.height)/2. theta = self.angle * npy.pi/180. T = npy.array([ @@ -864,10 +873,8 @@ [0, 1, y], [0, 0, 1]]) - w, h = self.width/2, self.height/2. - w = self.convert_xunits(w) - h = self.convert_yunits(h) + S = npy.array([ [w, 0, 0], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 18:37:24
|
Revision: 4060 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4060&view=rev Author: mdboom Date: 2007-10-29 11:37:17 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Fix clip path in polar plot legend. Modified Paths: -------------- branches/transforms/lib/matplotlib/artist.py branches/transforms/lib/matplotlib/backend_bases.py Modified: branches/transforms/lib/matplotlib/artist.py =================================================================== --- branches/transforms/lib/matplotlib/artist.py 2007-10-29 18:23:24 UTC (rev 4059) +++ branches/transforms/lib/matplotlib/artist.py 2007-10-29 18:37:17 UTC (rev 4060) @@ -309,6 +309,7 @@ if transform is None: if isinstance(path, Rectangle): self.clipbox = TransformedBbox(Bbox.unit(), path.get_transform()) + self._clippath = None success = True elif isinstance(path, Patch): self._clippath = TransformedPath( Modified: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-10-29 18:23:24 UTC (rev 4059) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-10-29 18:37:17 UTC (rev 4060) @@ -326,13 +326,15 @@ def get_clip_rectangle(self): """ - Return the clip rectangle as (left, bottom, width, height) + Return the clip rectangle as a Bbox instance """ return self._cliprect def get_clip_path(self): """ - Return the clip path + Return the clip path in the form (path, transform), where path + is a path.Path instance, and transform as an affine transform + to apply to the path before clipping. """ if self._clippath is not None: return self._clippath.get_transformed_path_and_affine() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 18:23:41
|
Revision: 4059 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4059&view=rev Author: mdboom Date: 2007-10-29 11:23:24 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Merged revisions 4001-4058 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4020 | mdboom | 2007-10-26 14:44:16 -0400 (Fri, 26 Oct 2007) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-3806" from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/transforms ........ r4039 | jdh2358 | 2007-10-28 11:18:02 -0400 (Sun, 28 Oct 2007) | 1 line added time series to specgram ........ r4046 | mdboom | 2007-10-29 10:30:51 -0400 (Mon, 29 Oct 2007) | 3 lines Fixing bug in font rendering -- the patented freetype hinter appears to be unable to deal with the non-square hinting grid hack. ........ r4047 | mdboom | 2007-10-29 10:44:18 -0400 (Mon, 29 Oct 2007) | 4 lines Fixing bug in font rendering -- the patented freetype hinter appears to be unable to deal with the non-square hinting grid hack. [Forgot this file]. ........ r4057 | mdboom | 2007-10-29 13:47:10 -0400 (Mon, 29 Oct 2007) | 2 lines Improve the code coverage of backend_driver.py ........ Modified Paths: -------------- branches/transforms/examples/specgram_demo.py branches/transforms/lib/matplotlib/backends/backend_agg.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/src/ft2font.cpp Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4000 + /trunk/matplotlib:1-4058 Modified: branches/transforms/examples/specgram_demo.py =================================================================== --- branches/transforms/examples/specgram_demo.py 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/examples/specgram_demo.py 2007-10-29 18:23:24 UTC (rev 4059) @@ -21,6 +21,9 @@ # the frequency vector, bins are the centers of the time bins in which # the power is computed, and im is the matplotlib.image.AxesImage # instance + +ax1 = subplot(211) +plot(t, x) +subplot(212, sharex=ax1) Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900) -colorbar() show() Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-10-29 18:23:24 UTC (rev 4059) @@ -82,7 +82,7 @@ from matplotlib.cbook import enumerate, is_string_like, exception_to_str from matplotlib.figure import Figure from matplotlib.font_manager import findfont -from matplotlib.ft2font import FT2Font, LOAD_DEFAULT +from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT from matplotlib.mathtext import MathTextParser from matplotlib.path import Path from matplotlib.transforms import Affine2D, Bbox @@ -147,11 +147,11 @@ font = self._get_agg_font(prop) if font is None: return None if len(s) == 1 and ord(s) > 127: - font.load_char(ord(s), flags=LOAD_DEFAULT) + font.load_char(ord(s), flags=LOAD_FORCE_AUTOHINT) else: # We pass '0' for angle here, since it will be rotated (in raster # space) in the following call to draw_text_image). - font.set_text(s, 0, flags=LOAD_DEFAULT) + font.set_text(s, 0, flags=LOAD_FORCE_AUTOHINT) font.draw_glyphs_to_bitmap() #print x, y, int(x), int(y) @@ -181,7 +181,7 @@ self.mathtext_parser.parse(s, self.dpi, prop) return width, height, descent font = self._get_agg_font(prop) - font.set_text(s, 0.0, flags=LOAD_DEFAULT) # the width and height of unrotated string + font.set_text(s, 0.0, flags=LOAD_FORCE_AUTOHINT) # the width and height of unrotated string w, h = font.get_width_height() d = font.get_descent() w /= 64.0 # convert from subpixels Modified: branches/transforms/lib/matplotlib/mathtext.py =================================================================== --- branches/transforms/lib/matplotlib/mathtext.py 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/lib/matplotlib/mathtext.py 2007-10-29 18:23:24 UTC (rev 4059) @@ -141,7 +141,7 @@ from matplotlib.afm import AFM from matplotlib.cbook import Bunch, get_realpath_and_stat, \ is_string_like -from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_DEFAULT, LOAD_NO_HINTING +from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING from matplotlib.font_manager import findfont, FontProperties from matplotlib._mathtext_data import latex_to_bakoma, \ latex_to_standard, tex2uni, tex2type1, uni2type1, \ @@ -304,7 +304,7 @@ self.fonts_object.get_used_characters()) def get_hinting_type(self): - return LOAD_DEFAULT + return LOAD_FORCE_AUTOHINT def MathtextBackendAgg(): return MathtextBackendBbox(MathtextBackendAggRender()) Modified: branches/transforms/src/ft2font.cpp =================================================================== --- branches/transforms/src/ft2font.cpp 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/src/ft2font.cpp 2007-10-29 18:23:24 UTC (rev 4059) @@ -943,7 +943,7 @@ angle = angle/360.0*2*3.14159; - long flags = FT_LOAD_DEFAULT; + long flags = FT_LOAD_FORCE_AUTOHINT; if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); @@ -1054,7 +1054,7 @@ } char FT2Font::load_char__doc__[] = -"load_char(charcode, flags=LOAD_LOAD_DEFAULT)\n" +"load_char(charcode, flags=LOAD_FORCE_AUTOHINT)\n" "\n" "Load character with charcode in current fontfile and set glyph.\n" "The flags argument can be a bitwise-or of the LOAD_XXX constants.\n" @@ -1075,7 +1075,7 @@ //load a char using the unsigned long charcode args.verify_length(1); - long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_DEFAULT); + long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT); if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 18:20:16
|
Revision: 4058 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4058&view=rev Author: mdboom Date: 2007-10-29 11:20:11 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Updated. Modified Paths: -------------- branches/transforms/PASSED_DEMOS Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-29 17:47:10 UTC (rev 4057) +++ branches/transforms/PASSED_DEMOS 2007-10-29 18:20:11 UTC (rev 4058) @@ -22,7 +22,7 @@ backend_driver.py [N/A] barchart_demo.py O barcode_demo.py O -barh_demo.py [BROKEN IN TRUNK] +barh_demo.py O bar_stacked.py O boxplot_demo.py O break.py O 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: <md...@us...> - 2007-10-29 17:39:11
|
Revision: 4056 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4056&view=rev Author: mdboom Date: 2007-10-29 10:39:06 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Oops -- this shouldn't have been committed. Modified Paths: -------------- branches/transforms/lib/matplotlib/collections.py Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-29 17:31:24 UTC (rev 4055) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-29 17:39:06 UTC (rev 4056) @@ -608,7 +608,7 @@ def set_segments(self, segments): if segments is None: return - segments = [npy.asarray([[y.get_value() for y in x] for x in seg], npy.float_) for seg in segments] + segments = [npy.asarray(seg, npy.float_) for seg in segments] if self._uniform_offsets is not None: segments = self._add_offsets(segments) self._paths = [mpath.Path(seg, closed=False) for seg in segments] 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:31:40
|
Revision: 4055 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4055&view=rev Author: mdboom Date: 2007-10-29 10:31:24 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Massive CHANGELOG and API_CHANGES entries about this refactoring. Modified Paths: -------------- branches/transforms/API_CHANGES branches/transforms/CHANGELOG Modified: branches/transforms/API_CHANGES =================================================================== --- branches/transforms/API_CHANGES 2007-10-29 16:55:53 UTC (rev 4054) +++ branches/transforms/API_CHANGES 2007-10-29 17:31:24 UTC (rev 4055) @@ -1,3 +1,174 @@ +TRANSFORMS REFACTORING + + The primary goal of this refactoring was to make it easier to + extend matplotlib to support new kinds of projections. This is + primarily an internal improvement, and the possible user-visible + changes it allows are yet to come. + + See transforms.py for a description of the design of the new + transformation framework. + + The view intervals are now stored only in one place -- in the Axes + instance, not in the formatter instances as well. This means + formatters must get their limits from their Axis, which in turn + looks up its limits from the Axes. If a Locator is used + temporarily and not assigned to an Axis or Axes, (e.g. in + contour.py), a dummy axis must be created to store its bounds. + Call Locator.create_dummy_axis() to do so. + + The functionality of Pbox has been merged with Bbox. Its methods + now all return copies rather than modifying in place. + + The following lists many of the simple changes necessary to update + code from the old transformation framework to the new one. In + particular, methods that return a copy are named with a verb in + the past tense, whereas methods that alter an object in place are + named with a very in the present tense. + + transforms.py + Bbox.get_bounds() Bbox.bounds + + Bbox.width() Bbox.width + + Bbox.height() Bbox.height + + Bbox.intervalx().get_bounds() Bbox.intervalx + Bbox.intervalx().set_bounds() + [Bbox.intervalx is now a property.] + + Bbox.intervaly().get_bounds() Bbox.intervaly + Bbox.intervaly().set_bounds() + [Bbox.intervaly is now a property.] + + Bbox.xmin() Bbox.x0 or Bbox.xmin + Bbox.ymin() Bbox.y0 or Bbox.ymin + Bbox.xmax() Bbox.x1 or Bbox.xmax + Bbox.ymax() Bbox.y1 or Bbox.ymax + [The Bbox is bound by the points (x0, y0) to (x1, y1) and + there is no defined order to these points, that is, x0 is not + necessarily the left edge of the box. To get the left edge of + the Bbox, use the read-only property xmin.] + + Bbox.overlaps(bboxes) Bbox.count_overlaps(bboxes) + + bbox_all(bboxes) Bbox.union(bboxes) + [Bbox.union is a staticmethod.] + + lbwh_to_bbox(l, b, w, h) Bbox.from_bounds(x0, y0, w, h) + + inverse_transform_bbox(trans, bbox) bbox.inverse_transformed(trans) + + Interval.contains_open(v) interval_contains_open(tuple, v) + Interval.contains(v) interval_contains_open(tuple, v) + + identity_transform() IdentityTransform() + + blend_xy_sep_transform(xtrans, ytrans) blended_transform_factory(xtrans, ytrans) + + scale_transform(xs, ys) Affine2D().scale(xs[, ys]) + + get_bbox_transform(boxin, boxout) BboxTransform(boxin, boxout) or + BboxTransformFrom(boxin) or + BboxTransformTo(boxout) + + Transform.seq_xy_tup(points) Transform.transform(points) + + Transform.inverse_xy_tup(points) Transform.inverted().transform(points) + + axes.py + Axes.get_position() Axes.get_position() + [Axes.get_position() used to return a list of points, not it + returns a transforms.Bbox instance.] + + Axes.set_position() Axes.set_position() + [Axes.set_position() now accepts either four scalars or a + transforms Bbox instance.] + + [also returns a Bbox] + Axes.toggle_log_lineary() Axes.set_yscale() + [Since the recfactoring allows for more than two scale types + ('log' or 'linear'), it no longer makes sense to have a + toggle. Axes.toggle_log_lineary() has been removed.] + + Axes.hlines(linestyle=) Axes.hlines(linestyles=) + Axes.vlines(linestyle=) Axes.vlines(linestyles=) + [The kwarg 'linestyle' has been replaced with 'linestyles', + which accepts either a single linestyle or a list of + linestyles to use.] + + Subplot class is gone -- now there is only SubplotBase. + + The Polar class has moved to projections/polar.py + + artist.py + Artist.set_clip_path(path) Artist.set_clip_path(path, transform) + [set_clip_path now accepts a path.Path instance and a + transformation that will be applied to the path immediately + before clipping.] + + collections.py + linestyle linestyles + [Linestyles are now treated like all other collection + attributes -- a single value or multiple values may be + provided.] + + colors.py + ColorConvertor.to_rgba_list(c) ColorConvertor.to_rgba_array(c) + [ColorConvertor.to_rgba_array(c) returns an Nx4 Numpy array of + RGBA color quadruples.] + + contour.py + Contour._segments Contour.get_paths() + [Contour.get_paths() now returns a list of path.Path instances.] + + figure.py + Figure.dpi.get()/set() Figure.dpi (a property) + + patches.py + get_verts() get_path() + [Patch.get_path() returns a path.Path instance.] + + backend_bases.py + GraphicsContext.set_clip_rectangle(tuple) GraphicsContext.set_clip_rectangle(bbox) + + GraphicsContext.get_clip_path() GraphicsContext.get_clip_path() + [GraphicsContext.get_clip_path() returns a tuple of the form + (path, affine_transform), where path is a path.Path instance + and affine_transform is a transforms.Affine2D instance.] + + GraphicsContext.set_clip_path(clippath) GraphicsContext.set_clip_path(clippath) + [Now accepts only an instance of transforms.TransformedPath.] + + RendererBase class: + **new methods** ---> + draw_path(self, gc, path, transform, rgbFace) + + draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace) + + draw_path_collection(self, master_transform, cliprect, clippath, + clippath_trans, paths, all_transforms, offsets, + offsetTrans, facecolors, edgecolors, linewidths, + linestyles, antialiaseds) [optional] + + + **changed methods** ---> + draw_image(self, x, y, im, bbox) draw_image(self, x, y, im, bbox, + clippath, clippath_trans) + + **removed methods** ---> + draw_arc + draw_line_collection + draw_line + draw_lines + draw_point + draw_quad_mesh + draw_poly_collection + draw_polygon + draw_rectangle + draw_regpoly_collection + +END OF TRANSFORMS REFACTORING + Added ax kwarg to pyplot.colorbar and Figure.colorbar so that one can specify the axes object from which space for the colorbar is to be taken, if one does not want to make the colorbar axes Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-10-29 16:55:53 UTC (rev 4054) +++ branches/transforms/CHANGELOG 2007-10-29 17:31:24 UTC (rev 4055) @@ -1,3 +1,73 @@ +2007-10-29 TRANSFORMS REFACTORING + + The primary goal of this refactoring was to make it easier + to extend matplotlib to support new kinds of projections. + This is primarily an internal improvement, and the possible + user-visible changes it allows are yet to come. + + The transformation framework was completely rewritten in + Python (with Numpy). This will make it easier to add news + kinds of transformations without writing C/C++ code. + + Transforms are composed into a 'transform tree', made of + transforms whose value depends on other transforms (their + children). When the contents of children change, their + parents are automatically updated to reflect those changes. + To do this an "invalidation" method is used: when children + change, all of their ancestors are marked as "invalid". + When the value of a transform is accessed at a later time, + its value is recomputed only if it is invalid, otherwise a + cached value may be used. This prevents unnecessary + recomputations of transforms, and contributes to better + interactive performance. + + The framework can be used for both affine and non-affine + transformations. However, for speed, we want use the + backend renderers to perform affine transformations + whenever possible. Therefore, it is possible to perform + just the affine or non-affine part of a transformation on a + set of data. The affine is always assumed to occur after + the non-affine. For any transform: + + full transform == non-affine + affine + + Much of the drawing has been refactored in terms of + compound paths. Therefore, many methods have been removed + from the backend interface and replaced with a a handful to + draw compound paths. This will make updating the backends + easier, since there is less to update. It also should make + the backends more consistent in terms of functionality. + + User visible changes: + + - POLAR PLOTS: Polar plots are now interactively zoomable, + and the r-axis labels can be interactively rotated. + Straight line segments are now interpolated to follow the + curve of the r-axis. + + - Non-rectangular clipping works in more backends and with + more types of objects. + + - Sharing an axis across figures is now done in exactly + the same way as sharing an axis between two axes in the + same figure: + + fig1 = figure() + fig2 = figure() + + ax1 = fig1.add_subplot(111) + ax2 = fig2.add_subplot(111, sharex=ax1, sharey=ax1) + + - linestyles now include steps-pre, steps-post and + steps-mid. The old step still works and is equivalent to + step-pre. + + - Multiple line styles may be provided to a collection. + + See API_CHANGES for more low-level information about this + refactoring. + + 2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF 2007-10-19 Removed a gsave/grestore pair surrounding _draw_ps, which This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 16:55:57
|
Revision: 4054 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4054&view=rev Author: mdboom Date: 2007-10-29 09:55:53 -0700 (Mon, 29 Oct 2007) Log Message: ----------- More examples working. Modified Paths: -------------- branches/transforms/PASSED_DEMOS branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/ticker.py Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-29 15:21:49 UTC (rev 4053) +++ branches/transforms/PASSED_DEMOS 2007-10-29 16:55:53 UTC (rev 4054) @@ -209,4 +209,20 @@ zoom_window.py O zorder_demo.py O -MGDTODO: units directory \ No newline at end of file + +units directory ----- + +annotate_with_units.py O +artist_tests.py O +bar_demo2.py O +bar_unit_demo.py [BROKEN IN TRUNK] +basic_units.py [N/A] +date_converter.py O +date_support.py [N/A] +ellipse_with_units.py [BROKEN IN TRUNK] +evans_test2.py O +evans_test.py O +__init__.py [N/A] +radian_demo.py O +units_sample.py O +units_scatter.py Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-29 15:21:49 UTC (rev 4053) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-29 16:55:53 UTC (rev 4054) @@ -16,7 +16,7 @@ import matplotlib.transforms as transforms import matplotlib.artist as artist import matplotlib.backend_bases as backend_bases -import matplotlib.path as path +import matplotlib.path as mpath class Collection(artist.Artist, cm.ScalarMappable): """ @@ -136,7 +136,7 @@ offsets = transOffset.transform_non_affine(offsets) transOffset = transOffset.get_affine() - result = path.get_path_collection_extents( + result = mpath.get_path_collection_extents( transform.frozen(), paths, self.get_transforms(), npy.asarray(offsets, npy.float_), transOffset.frozen()) result = result.inverse_transformed(transData) @@ -154,15 +154,19 @@ paths = [] for path in self._paths: vertices = path.vertices - xs, ys = zip(*segment) + xs, ys = vertices[:, 0], vertices[:, 1] xs = self.convert_xunits(xs) ys = self.convert_yunits(ys) - paths.append(path.Path(zip(xs, ys), path.codes)) + paths.append(mpath.Path(zip(xs, ys), path.codes)) if self._offsets is not None: xs = self.convert_xunits(self._offsets[:0]) ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) - + if len(offsets) == 0: + offsets = npy.zeros((1, 2)) + else: + offsets = npy.asarray(offsets, npy.float_) + self.update_scalarmappable() clippath, clippath_trans = self.get_transformed_clip_path_and_affine() @@ -179,7 +183,7 @@ renderer.draw_path_collection( transform.frozen(), self.clipbox, clippath, clippath_trans, paths, self.get_transforms(), - npy.asarray(offsets, npy.float_), transOffset, + offsets, transOffset, self._facecolors, self._edgecolors, self._linewidths, self._linestyles, self._antialiaseds) renderer.close_group(self.__class__.__name__) @@ -198,7 +202,7 @@ paths = [transform.transform_path_non_affine(path) for path in paths] transform = transform.get_affine() - ind = path.point_in_path_collection( + ind = mpath.point_in_path_collection( mouseevent.x, mouseevent.y, self._pickradius, transform.frozen(), paths, self.get_transforms(), npy.asarray(self._offsets, npy.float_), @@ -372,7 +376,7 @@ (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on. """ def __init__(self, meshWidth, meshHeight, coordinates, showedges): - Path = path.Path + Path = mpath.Path Collection.__init__(self) self._meshWidth = meshWidth @@ -426,7 +430,7 @@ def set_verts(self, verts): '''This allows one to delay initialization of the vertices.''' - self._paths = [path.Path(v, closed=True) for v in verts] + self._paths = [mpath.Path(v, closed=True) for v in verts] def get_paths(self): return self._paths @@ -450,7 +454,7 @@ __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd class RegularPolyCollection(Collection): - _path_generator = path.Path.unit_regular_polygon + _path_generator = mpath.Path.unit_regular_polygon def __init__(self, dpi, @@ -510,11 +514,11 @@ class StarPolygonCollection(RegularPolyCollection): - _path_generator = path.Path.unit_regular_star + _path_generator = mpath.Path.unit_regular_star class AsteriskPolygonCollection(RegularPolyCollection): - _path_generator = path.Path.unit_regular_asterisk + _path_generator = mpath.Path.unit_regular_asterisk class LineCollection(Collection, cm.ScalarMappable): @@ -604,10 +608,10 @@ def set_segments(self, segments): if segments is None: return - segments = [npy.asarray(seg, npy.float_) for seg in segments] + segments = [npy.asarray([[y.get_value() for y in x] for x in seg], npy.float_) for seg in segments] if self._uniform_offsets is not None: segments = self._add_offsets(segments) - self._paths = [path.Path(seg, closed=False) for seg in segments] + self._paths = [mpath.Path(seg, closed=False) for seg in segments] set_verts = set_segments # for compatibility with PolyCollection Modified: branches/transforms/lib/matplotlib/ticker.py =================================================================== --- branches/transforms/lib/matplotlib/ticker.py 2007-10-29 15:21:49 UTC (rev 4053) +++ branches/transforms/lib/matplotlib/ticker.py 2007-10-29 16:55:53 UTC (rev 4054) @@ -615,7 +615,7 @@ def __call__(self): 'Return the locations of the ticks' - dmin, dmax = self.dataInterval.get_bounds() + dmin, dmax = self.axis.get_data_interval() return npy.arange(dmin + self.offset, dmax+1, self._base) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 15:21:55
|
Revision: 4053 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4053&view=rev Author: mdboom Date: 2007-10-29 08:21:49 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Lots of minor bug fixes. Modified Paths: -------------- branches/transforms/PASSED_DEMOS branches/transforms/lib/matplotlib/artist.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backend_bases.py branches/transforms/lib/matplotlib/backends/backend_svg.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/colors.py branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/widgets.py Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/PASSED_DEMOS 2007-10-29 15:21:49 UTC (rev 4053) @@ -208,3 +208,5 @@ xcorr_demo.py O zoom_window.py O zorder_demo.py O + +MGDTODO: units directory \ No newline at end of file Modified: branches/transforms/lib/matplotlib/artist.py =================================================================== --- branches/transforms/lib/matplotlib/artist.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/artist.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -2,6 +2,7 @@ import re, warnings from cbook import iterable, flatten from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath +from path import Path ## Note, matplotlib artists use the doc strings for set and get # methods to enable the introspection methods of setp and getp. Every @@ -285,25 +286,48 @@ def set_clip_path(self, path, transform=None): """ - Set the artist's clip path + Set the artist's clip path, which may be: - ACCEPTS: a Path instance and a Transform instance, or a Patch instance + a) a Patch (or subclass) instance + + b) a Path instance, in which cas aoptional transform may + be provided, which will be applied to the path before using it + for clipping. + + c) None, to remove the clipping path + + For efficiency, if the path happens to be an axis-aligned + rectangle, this method will set the clipping box to the + corresponding rectangle and set the clipping path to None. + + ACCEPTS: a Path instance and a Transform instance, a Patch + instance, or None """ from patches import Patch, Rectangle + + success = False if transform is None: if isinstance(path, Rectangle): self.clipbox = TransformedBbox(Bbox.unit(), path.get_transform()) + success = True elif isinstance(path, Patch): self._clippath = TransformedPath( path.get_path(), path.get_transform()) - elif path is None: - self._clippath = None - else: - raise TypeError("Invalid arguments to set_clip_path") - else: + success = True + + if path is None: + self._clippath = None + success = True + elif isinstance(path, Path): self._clippath = TransformedPath(path, transform) - self._clipon = self.clipbox is not None or path is not None + success = True + + if not success: + print type(path), type(transform) + raise TypeError("Invalid arguments to set_clip_path") + + self._clipon = self.clipbox is not None or self._clippath is not None self.pchanged() def get_alpha(self): @@ -334,6 +358,10 @@ return self._clippath def get_transformed_clip_path_and_affine(self): + ''' + Return the clip path with the non-affine part of its transformation applied, + and the remaining affine part of its transformation. + ''' if self._clippath is not None: return self._clippath.get_transformed_path_and_affine() return None, None Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/axes.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -494,9 +494,6 @@ self.set_label(label) self.set_figure(fig) - self._invertedx = False - self._invertedy = False - # this call may differ for non-sep axes, eg polar self._init_axis() @@ -553,7 +550,8 @@ def _set_lim_and_transforms(self): """ set the dataLim and viewLim BBox attributes and the - transData and transAxes Transformation attributes + transScale, transData, transLimits and transAxes + transformations. """ self.dataLim = mtransforms.Bbox.unit() self.viewLim = mtransforms.Bbox.unit() @@ -579,27 +577,105 @@ self.axes.transAxes, self.axes.transData) def get_xaxis_transform(self): + """ + Get the transformation used for drawing x-axis labels, ticks + and gridlines. The x-direction is in data coordinates and the + y-direction is in axis coordinates. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return self._xaxis_transform def get_xaxis_text1_transform(self, pad_pixels): + """ + Get the transformation used for drawing x-axis labels, which + will add the given number of pad_pixels between the axes and + the label. The x-direction is in data coordinates and the + y-direction is in axis coordinates. Returns a 3-tuple of the + form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._xaxis_transform + mtransforms.Affine2D().translate(0, -1 * pad_pixels), "top", "center") def get_xaxis_text2_transform(self, pad_pixels): + """ + Get the transformation used for drawing the secondary x-axis + labels, which will add the given number of pad_pixels between + the axes and the label. The x-direction is in data + coordinates and the y-direction is in axis coordinates. + Returns a 3-tuple of the form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._xaxis_transform + mtransforms.Affine2D().translate(0, pad_pixels), "bottom", "center") def get_yaxis_transform(self): + """ + Get the transformation used for drawing y-axis labels, ticks + and gridlines. The x-direction is in axis coordinates and the + y-direction is in data coordinates. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return self._yaxis_transform def get_yaxis_text1_transform(self, pad_pixels): + """ + Get the transformation used for drawing y-axis labels, which + will add the given number of pad_pixels between the axes and + the label. The x-direction is in axis coordinates and the + y-direction is in data coordinates. Returns a 3-tuple of the + form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._yaxis_transform + mtransforms.Affine2D().translate(-1 * pad_pixels, 0), "center", "right") def get_yaxis_text2_transform(self, pad_pixels): + """ + Get the transformation used for drawing the secondary y-axis + labels, which will add the given number of pad_pixels between + the axes and the label. The x-direction is in axis + coordinates and the y-direction is in data coordinates. + Returns a 3-tuple of the form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._yaxis_transform + mtransforms.Affine2D().translate(pad_pixels, 0), "center", "left") @@ -610,11 +686,11 @@ self.xaxis.get_transform(), self.yaxis.get_transform())) def get_position(self, original=False): - 'Return the axes rectangle left, bottom, width, height' + 'Return the a copy of the axes rectangle as a Bbox' if original: - return self._originalPosition + return self._originalPosition.frozen() else: - return self._position + return self._position.frozen() def set_position(self, pos, which='both'): @@ -639,7 +715,6 @@ if which in ('both', 'original'): self._originalPosition.set(pos) - def _set_artist_props(self, a): 'set the boilerplate props for artists added to axes' a.set_figure(self.figure) @@ -648,6 +723,16 @@ a.axes = self def get_axes_patch(self): + """ + Returns the patch used to draw the background of the axes. It + is also used as the clipping path for any data elements on the + axes. + + In the standard axes, this is a rectangle, but in other + projections it may not be. + + Intended to be overridden by new projection types. + """ return mpatches.Rectangle((0.0, 0.0), 1.0, 1.0) def cla(self): @@ -806,6 +891,12 @@ ', '.join(mtransforms.BBox.coefs.keys())) def get_data_ratio(self): + """ + Returns the aspect ratio of the raw data. + + This method is intended to be overridden by new projection + types. + """ xmin,xmax = self.get_xbound() xsize = max(math.fabs(xmax-xmin), 1e-30) ymin,ymax = self.get_ybound() @@ -1032,6 +1123,7 @@ a.set_axes(self) self.artists.append(a) self._set_artist_props(a) + # MGDTODO: We may not want to do this -- the old trunk didn't a.set_clip_path(self.axesPatch) a._remove_method = lambda h: self.artists.remove(h) @@ -1074,19 +1166,20 @@ self._update_patch_limits(p) self.patches.append(p) p._remove_method = lambda h: self.patches.remove(h) - + def _update_patch_limits(self, p): 'update the datalimits for patch p' - xys = self._get_verts_in_data_coords( - p.get_data_transform(), - p.get_patch_transform().transform(p.get_path().vertices)) - self.update_datalim(xys) + vertices = p.get_patch_transform().transform(p.get_path().vertices) + if p.get_data_transform() != self.transData: + transform = p.get_data_transform() + self.transData.inverted() + xys = transform.transform(vertices) + self.update_datalim(vertices) - def add_table(self, tab): 'Add a table instance to the list of axes tables' self._set_artist_props(tab) self.tables.append(tab) + # MGDTODO: We may not want to do this (the old version in trunk didn't) tab.set_clip_path(self.axesPatch) tab._remove_method = lambda h: self.tables.remove(h) @@ -1105,8 +1198,6 @@ # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata - # MGDTODO: This isn't always the most efficient way to do this... in - # some cases things should use update_datalim_bounds if not ma.isMaskedArray(xys): xys = npy.asarray(xys) self.update_datalim_numerix(xys[:, 0], xys[:, 1]) @@ -1117,7 +1208,6 @@ # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata - ## self.dataLim.update_numerix(x, y, -1) self.dataLim.update_from_data(x, y, self.ignore_existing_data_limits) self.ignore_existing_data_limits = False @@ -1125,16 +1215,6 @@ 'Update the datalim to include the given Bbox' self.dataLim.set(Bbox.union([self.dataLim, bounds])) - def _get_verts_in_data_coords(self, trans, xys): - if trans == self.transData: - return xys - # data is not in axis data units. We must transform it to - # display and then back to data to get it in data units - #xys = trans.seq_xy_tups(xys) - #return [ self.transData.inverse_xy_tup(xy) for xy in xys] - xys = trans.transform(npy.asarray(xys)) - return self.transData.inverted().transform(xys) - def _process_unit_info(self, xdata=None, ydata=None, kwargs=None): 'look for unit kwargs and update the axis instances as necessary' @@ -1162,7 +1242,7 @@ self.yaxis.set_units(yunits) def in_axes(self, mouseevent): - 'return True is the point xwin, ywin (display coords) are in the Axes' + 'return True if the given mouseevent (in display coords) is in the Axes' return self.axesPatch.contains(mouseevent)[0] def get_autoscale_on(self): @@ -1268,11 +1348,11 @@ if self.axison and self._frameon: artists.append(self.axesFrame) - dsu = [ (a.zorder, a) for a in artists + dsu = [ (a.zorder, i, a) for i, a in enumerate(artists) if not a.get_animated() ] dsu.sort() - for zorder, a in dsu: + for zorder, i, a in dsu: a.draw(renderer) renderer.close_group('axes') @@ -1474,16 +1554,10 @@ self.set_xlim(upper, lower) def get_xlim(self): - """Get the x-axis range [xmin, xmax] - - NOTE: The returned values are always [xmin, xmax] such that - xmin < xmax; regardless of whether or not the axes are inverted. """ - bound1, bound2 = self.viewLim.intervalx - if ( self._invertedx ): - return bound2, bound1 - else: - return bound1, bound2 + Get the x-axis range [xmin, xmax] + """ + return self.viewLim.intervalx def set_xlim(self, xmin=None, xmax=None, emit=True, **kwargs): """ @@ -1637,16 +1711,10 @@ self.set_ylim(upper, lower) def get_ylim(self): - """Get the y-axis range [xmin, xmax] - - NOTE: The returned values are always [ymin, ymax] such that - ymin < ymax; regardless of whether or not the axes are inverted. """ - bound1, bound2 = self.viewLim.intervaly - if ( self._invertedy ): - return bound2, bound1 - else: - return bound1, bound2 + Get the y-axis range [xmin, xmax] + """ + return self.viewLim.intervaly def set_ylim(self, ymin=None, ymax=None, emit=True, **kwargs): """ @@ -1812,8 +1880,10 @@ def format_coord(self, x, y): 'return a format string formatting the x, y coord' - if x is None or y is None: - return '' + if x is None: + x = '???' + if y is None: + y = '???' xs = self.format_xdata(x) ys = self.format_ydata(y) return 'x=%s, y=%s'%(xs,ys) @@ -1855,6 +1925,17 @@ self._navigate_mode = b def start_pan(self, x, y, button): + """ + Called when a pan operation has started. + + x, y are the mouse coordinates in display coords. + button is the mouse button number: + 1: LEFT + 2: MIDDLE + 3: RIGHT + + Intended to be overridden by new projection types. + """ self._pan_start = cbook.Bunch( lim = self.viewLim.frozen(), trans = self.transData.frozen(), @@ -1864,9 +1945,29 @@ ) def end_pan(self): + """ + Called when a pan operation completes (when the mouse button + is up.) + + Intended to be overridden by new projection types. + """ del self._pan_start def drag_pan(self, button, key, x, y): + """ + Called when the mouse moves during a pan operation. + + button is the mouse button number: + 1: LEFT + 2: MIDDLE + 3: RIGHT + + key is a "shift" key + + x, y are the mouse coordinates in display coords. + + Intended to be overridden by new projection types. + """ def format_deltas(key, dx, dy): if key=='control': if(abs(dx)>abs(dy)): @@ -2223,7 +2324,7 @@ %(Annotation)s """ a = mtext.Annotation(*args, **kwargs) - a.set_transform(mtransforms.Affine2D()) + a.set_transform(mtransforms.IdentityTransform()) self._set_artist_props(a) if kwargs.has_key('clip_on'): a.set_clip_path(self.axesPatch) self.texts.append(a) @@ -4035,9 +4136,9 @@ if len(sh) == 1 and sh[0] == len(x): colors = None # use cmap, norm after collection is created else: - colors = mcolors.colorConverter.to_rgba_list(c, alpha) + colors = mcolors.colorConverter.to_rgba_array(c, alpha) else: - colors = mcolors.colorConverter.to_rgba_list(c, alpha) + colors = mcolors.colorConverter.to_rgba_array(c, alpha) if not iterable(s): scales = (s,) @@ -4137,7 +4238,7 @@ offsets = zip(x,y), transOffset = self.transData, ) - collection.set_transform(mtransforms.Affine2D()) + collection.set_transform(mtransforms.IdentityTransform()) collection.set_alpha(alpha) collection.update(kwargs) @@ -4198,6 +4299,9 @@ quiverkey.__doc__ = mquiver.QuiverKey.quiverkey_doc def quiver(self, *args, **kw): + """ + MGDTODO: Document me + """ q = mquiver.Quiver(self, *args, **kw) self.add_collection(q, False) self.update_datalim_numerix(q.X, q.Y) Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/axis.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -14,7 +14,7 @@ from font_manager import FontProperties from text import Text, TextWithDash from transforms import Affine2D, Bbox, blended_transform_factory, \ - interval_contains + IdentityTransform, interval_contains from patches import bbox_artist from scale import scale_factory @@ -113,6 +113,7 @@ self.tick1line.set_clip_path(clippath, transform) self.tick2line.set_clip_path(clippath, transform) self.gridline.set_clip_path(clippath, transform) + set_clip_path.__doc__ = Artist.set_clip_path.__doc__ def contains(self, mouseevent): """Test whether the mouse event occured in the Tick marks. @@ -1015,7 +1016,7 @@ horizontalalignment='center', ) label.set_transform( blended_transform_factory( - self.axes.transAxes, Affine2D() )) + self.axes.transAxes, IdentityTransform() )) self._set_artist_props(label) self.label_position='bottom' @@ -1030,7 +1031,7 @@ horizontalalignment='right', ) offsetText.set_transform( blended_transform_factory( - self.axes.transAxes, Affine2D() )) + self.axes.transAxes, IdentityTransform() )) self._set_artist_props(offsetText) self.offset_text_position='bottom' return offsetText @@ -1092,11 +1093,11 @@ def set_ticks_position(self, position): """ - Set the ticks position (top, bottom, both or default) - both sets the ticks to appear on both positions, but - does not change the tick labels. - default resets the tick positions to the default: - ticks on both positions, labels at bottom. + Set the ticks position (top, bottom, both, default or none) + both sets the ticks to appear on both positions, but does not + change the tick labels. default resets the tick positions to + the default: ticks on both positions, labels at bottom. none + can be used if you don't want any ticks. ACCEPTS: [ 'top' | 'bottom' | 'both' | 'default' | 'none' ] """ @@ -1225,7 +1226,7 @@ rotation='vertical', ) label.set_transform( blended_transform_factory( - Affine2D(), self.axes.transAxes) ) + IdentityTransform(), self.axes.transAxes) ) self._set_artist_props(label) self.label_position='left' @@ -1240,7 +1241,7 @@ horizontalalignment = 'left', ) offsetText.set_transform(blended_transform_factory( - self.axes.transAxes, Affine2D()) ) + self.axes.transAxes, IdentityTransform()) ) self._set_artist_props(offsetText) self.offset_text_position='left' return offsetText Modified: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -73,7 +73,7 @@ offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds): path, transform = path_id - transform = transform.frozen().translate(xo, yo) + transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo) self.draw_path(gc, path, transform, rgbFace) def _iter_collection_raw_paths(self, master_transform, paths, all_transforms): @@ -200,6 +200,27 @@ """ return False + def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!'): + raise NotImplementedError + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False): + """ + Draw the text.Text instance s at x,y (display coords) with font + properties instance prop at angle in degrees, using GraphicsContext gc + + **backend implementers note** + + When you are trying to determine if you have gotten your bounding box + right (which is what enables the text layout/alignment to work + properly), it helps to change the line in text.py + + if 0: bbox_artist(self, renderer) + + to if 1, and then the actual bounding box will be blotted along with + your text. + """ + raise NotImplementedError + def flipy(self): """return true if y small numbers are top for renderer Is used for drawing text (text.py) and images (image.py) only @@ -386,7 +407,8 @@ def set_clip_path(self, path): """ - Set the clip path and transformation + Set the clip path and transformation. Path should be a + transforms.TransformedPath instance. """ assert path is None or isinstance(path, transforms.TransformedPath) self._clippath = path Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -205,7 +205,7 @@ for i, (path, transform) in enumerate(self._iter_collection_raw_paths( master_transform, paths, all_transforms)): name = 'coll%x_%x' % (self._path_collection_id, i) - transform = transform.frozen().scale(1.0, -1.0) + transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0) d = self._convert_path(path, transform) write('<path id="%s" d="%s"/>\n' % (name, d)) path_codes.append(name) Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -83,12 +83,12 @@ if antialiaseds is None: antialiaseds = (mpl.rcParams['patch.antialiased'],) self.set_linestyles(linestyles) - self._facecolors = _colors.colorConverter.to_rgba_list(facecolors) + self._facecolors = _colors.colorConverter.to_rgba_array(facecolors) if edgecolors == 'None': self._edgecolors = self._facecolors linewidths = (0,) else: - self._edgecolors = _colors.colorConverter.to_rgba_list(edgecolors) + self._edgecolors = _colors.colorConverter.to_rgba_array(edgecolors) self._linewidths = self._get_value(linewidths) self._antialiaseds = self._get_value(antialiaseds) @@ -268,7 +268,7 @@ ACCEPTS: matplotlib color arg or sequence of rgba tuples """ - self._facecolors = _colors.colorConverter.to_rgba_list(c, self._alpha) + self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha) set_facecolors = set_facecolor @@ -284,7 +284,7 @@ self._linewidths = (0.0,) self._edgecolors = npy.array([]) else: - self._edgecolors = _colors.colorConverter.to_rgba_list(c) + self._edgecolors = _colors.colorConverter.to_rgba_array(c) set_edgecolors = set_edgecolor def set_alpha(self, alpha): @@ -581,7 +581,7 @@ if antialiaseds is None: antialiaseds = (mpl.rcParams['lines.antialiased'],) self.set_linestyles(linestyles) - colors = _colors.colorConverter.to_rgba_list(colors) + colors = _colors.colorConverter.to_rgba_array(colors) Collection.__init__( self, @@ -633,7 +633,7 @@ ACCEPTS: matplotlib color arg or sequence of rgba tuples """ - self._edgecolors = _colors.colorConverter.to_rgba_list(c) + self._edgecolors = _colors.colorConverter.to_rgba_array(c) def color(self, c): """ Modified: branches/transforms/lib/matplotlib/colors.py =================================================================== --- branches/transforms/lib/matplotlib/colors.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/colors.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -307,12 +307,13 @@ except (TypeError, ValueError), exc: raise ValueError('to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc)) - def to_rgba_list(self, c, alpha=None): + def to_rgba_array(self, c, alpha=None): """ - Returns a list of rgba tuples. + Returns an Numpy array of rgba tuples. Accepts a single mpl color spec or a sequence of specs. - If the sequence is a list, the list items are changed in place. + If the sequence is a list or array, the items are changed in place, + but an array copy is still returned. """ try: result = [self.to_rgba(c, alpha)] @@ -320,7 +321,7 @@ # If c is a list it must be maintained as the same list # with modified items so that items can be appended to # it. This is needed for examples/dynamic_collections.py. - if not isinstance(c, list): # specific; don't need duck-typing + if not isinstance(c, (list, npy.ndarray)): # specific; don't need duck-typing c = list(c) for i, cc in enumerate(c): c[i] = self.to_rgba(cc, alpha) # change in place Modified: branches/transforms/lib/matplotlib/legend.py =================================================================== --- branches/transforms/lib/matplotlib/legend.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/legend.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -363,15 +363,6 @@ bbox.update_from_data_xy(averts, True) bboxes.append(bbox) - for handle in ax.collections: - if isinstance(handle, LineCollection): - hlines = handle.get_lines() - trans = handle.get_transform() - for line in hlines: - tline = trans.seq_xy_tups(line) - aline = [inv(v) for v in tline] - lines.append(aline) - return [vertices, bboxes, lines] def draw_frame(self, b): Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/lines.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -71,6 +71,45 @@ ic1 = breakpoints return npy.concatenate((ic0[:, npy.newaxis], ic1[:, npy.newaxis]), axis=1) +def segment_hits(cx,cy,x,y,radius): + """Determine if any line segments are within radius of a point. Returns + the list of line segments that are within that radius. + """ + # Process single points specially + if len(x) < 2: + res, = npy.nonzero( (cx - x)**2 + (cy - y)**2 <= radius**2 ) + return res + + # We need to lop the last element off a lot. + xr,yr = x[:-1],y[:-1] + + # Only look at line segments whose nearest point to C on the line + # lies within the segment. + dx,dy = x[1:]-xr, y[1:]-yr + Lnorm_sq = dx**2+dy**2 # Possibly want to eliminate Lnorm==0 + u = ( (cx-xr)*dx + (cy-yr)*dy )/Lnorm_sq + candidates = (u>=0) & (u<=1) + #if any(candidates): print "candidates",xr[candidates] + + # Note that there is a little area near one side of each point + # which will be near neither segment, and another which will + # be near both, depending on the angle of the lines. The + # following radius test eliminates these ambiguities. + point_hits = (cx - x)**2 + (cy - y)**2 <= radius**2 + #if any(point_hits): print "points",xr[candidates] + candidates = candidates & ~point_hits[:-1] & ~point_hits[1:] + + # For those candidates which remain, determine how far they lie away + # from the line. + px,py = xr+u*dx,yr+u*dy + line_hits = (cx-px)**2 + (cy-py)**2 <= radius**2 + #if any(line_hits): print "lines",xr[candidates] + line_hits = line_hits & candidates + points, = point_hits.ravel().nonzero() + lines, = line_hits.ravel().nonzero() + #print points,lines + return npy.concatenate((points,lines)) + class Line2D(Artist): lineStyles = _lineStyles = { # hidden names deprecated '-' : '_draw_solid', @@ -276,7 +315,6 @@ else: pixels = self.figure.dpi/72. * self.pickradius - path, transform = self._transformed_path.get_transformed_path_and_affine() if self._linestyle == 'None': # If no line, return the nearby point(s) d = npy.sqrt((xt-mouseevent.x)**2 + (yt-mouseevent.y)**2) @@ -320,7 +358,7 @@ # correct for marker size, if any if self._marker is not None: ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5 - bbox = Bbox(bbox.get_points() + [[-ms, -ms], [ms, ms]]) + bbox = bbox.padded(ms) return bbox def set_axes(self, ax): @@ -399,7 +437,7 @@ """ set the Transformation instance used by this artist - ACCEPTS: a matplotlib.transform transformation instance + ACCEPTS: a matplotlib.transforms.Transform instance """ Artist.set_transform(self, t) self._transformed_path = TransformedPath(self._path, self.get_transform()) Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/patches.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -82,7 +82,7 @@ Returns T/F, {} """ - # This is a general version of contains should work on any + # This is a general version of contains that should work on any # patch with a path. However, patches that have a faster # algebraic solution to hit-testing should override this # method. @@ -290,8 +290,8 @@ Patch.__init__(self) self.patch = patch self.props = props - self.ox, self.oy = ox, oy - self._shadow_transform = transforms.Affine2D().translate(self.ox, self.oy) + self._ox, self._oy = ox, oy + self._update_transform() self._update() __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd @@ -308,7 +308,22 @@ self.set_facecolor((r,g,b,0.5)) self.set_edgecolor((r,g,b,0.5)) - + + def _update_transform(self): + self._shadow_transform = transforms.Affine2D().translate(self._ox, self._oy) + + def _get_ox(self): + return self._ox + def _set_ox(self, ox): + self._ox = ox + self._update_transform() + + def _get_oy(self): + return self._oy + def _set_oy(self, oy): + self._oy = oy + self._update_transform() + def get_path(self): return self.patch.get_path() Modified: branches/transforms/lib/matplotlib/widgets.py =================================================================== --- branches/transforms/lib/matplotlib/widgets.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/widgets.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -849,7 +849,7 @@ self.prev = (0, 0) if self.direction == 'horizontal': - trans = (self.ax.transData, self.ax.transAxes) + trans = blended_transform_factory(self.ax.transData, self.ax.transAxes) w,h = 0,1 else: trans = blended_transform_factory(self.ax.transAxes, self.ax.transData) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 15:21:07
|
Revision: 4052 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4052&view=rev Author: mdboom Date: 2007-10-29 08:20:13 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Revert this example to like it is in the trunk. Modified Paths: -------------- branches/transforms/examples/shared_axis_demo.py Modified: branches/transforms/examples/shared_axis_demo.py =================================================================== --- branches/transforms/examples/shared_axis_demo.py 2007-10-29 15:04:28 UTC (rev 4051) +++ branches/transforms/examples/shared_axis_demo.py 2007-10-29 15:20:13 UTC (rev 4052) @@ -36,12 +36,12 @@ s2 = exp(-t) s3 = sin(4*pi*t) ax1 = subplot(311) -plot(t,s1, "bH") +plot(t,s1) setp( ax1.get_xticklabels(), fontsize=6) ## share x only ax2 = subplot(312, sharex=ax1) -plot(t, s2, "b<") +plot(t, s2) # make these tick labels invisible setp( ax2.get_xticklabels(), visible=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-29 15:04:30
|
Revision: 4051 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4051&view=rev Author: jdh2358 Date: 2007-10-29 08:04:28 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added workbook to doc dir Added Paths: ----------- trunk/py4science/doc/workbook.pdf Added: trunk/py4science/doc/workbook.pdf =================================================================== --- trunk/py4science/doc/workbook.pdf (rev 0) +++ trunk/py4science/doc/workbook.pdf 2007-10-29 15:04:28 UTC (rev 4051) @@ -0,0 +1,20267 @@ +%PDF-1.4 +5 0 obj +<< /S /GoTo /D (chapter.1) >> +endobj +8 0 obj +(Chapter 1. Introduction) +endobj +9 0 obj +<< /S /GoTo /D (chapter.2) >> +endobj +12 0 obj +(Chapter 2. Simple non-numerical problems) +endobj +13 0 obj +<< /S /GoTo /D (section.2.1) >> +endobj +16 0 obj +(1. Sorting quickly with QuickSort ) +endobj +17 0 obj +<< /S /GoTo /D (section.2.2) >> +endobj +20 0 obj +(2. Dictionaries for counting words) +endobj +21 0 obj +<< /S /GoTo /D (chapter.3) >> +endobj +24 0 obj +(Chapter 3. Working with files, the internet, and numpy arrays) +endobj +25 0 obj +<< /S /GoTo /D (section.3.1) >> +endobj +28 0 obj +(1. Loading and saving ASCII data) +endobj +29 0 obj +<< /S /GoTo /D (section.3.2) >> +endobj +32 0 obj +(2. Working with CSV files) +endobj +33 0 obj +<< /S /GoTo /D (section.3.3) >> +endobj +36 0 obj +(3. Loading and saving binary data) +endobj +37 0 obj +<< /S /GoTo /D (chapter.4) >> +endobj +40 0 obj +(Chapter 4. Elementary Numerics) +endobj +41 0 obj +<< /S /GoTo /D (section.4.1) >> +endobj +44 0 obj +(1. Wallis' slow road to ) +endobj +45 0 obj +<< /S /GoTo /D (section.4.2) >> +endobj +48 0 obj +(2. Trapezoidal rule) +endobj +49 0 obj +<< /S /GoTo /D (section.4.3) >> +endobj +52 0 obj +(3. Newton's method) +endobj +53 0 obj +<< /S /GoTo /D (chapter.5) >> +endobj +56 0 obj +(Chapter 5. Linear algebra) +endobj +57 0 obj +<< /S /GoTo /D (section.5.1) >> +endobj +60 0 obj +(1. Glass Moir\351 Patterns) +endobj +61 0 obj +<< /S /GoTo /D (chapter.6) >> +endobj +64 0 obj +(Chapter 6. Signal processing) +endobj +65 0 obj +<< /S /GoTo /D (section.6.1) >> +endobj +68 0 obj +(1. Convolution) +endobj +69 0 obj +<< /S /GoTo /D (section.6.2) >> +endobj +72 0 obj +(2. FFT Image Denoising) +endobj +73 0 obj +<< /S /GoTo /D (chapter.7) >> +endobj +76 0 obj +(Chapter 7. Statistics) +endobj +77 0 obj +<< /S /GoTo /D (section.7.1) >> +endobj +80 0 obj +(1. Descriptive statistics) +endobj +81 0 obj +<< /S /GoTo /D (section.7.2) >> +endobj +84 0 obj +(2. Statistical distributions) +endobj +85 0 obj +<< /S /GoTo /D [86 0 R /Fit ] >> +endobj +88 0 obj << +/Length 321 +/Filter /FlateDecode +>> +stream +xڍQ;O\xC30\xDE\xF3+<\xDAC\x9F_\x8F\xBC +\xEAT\xA9\x91(CHB\x95:(jU\xC1\xAF\xC7NhU$dɖ}\xDF\xE3>22\xAF\xC1I\xA9i +\xDE\xB1z\x97I\xB6\x8E\xB5\x870F \xEF]\xBC\xFCQ\xCD-\xA0\xBD/X~)rSfW3m\xD0\xC6)V\xBE1%%(\xEB +\xE6PC\xA1#\xA3l\x9E\xF9b\xA8\xEA}WW\xEF"\xF8\xB2\xEE\xDA \xB4\xE4{\x81\xBC9\xF2\x95ԦNE\xC7o\xFB]z\xF98\x9C\x8Ba-^\xCA9#\x85hY\xAEPI\x95\xBB0I.>2Q6}\xE1\xB9R愞\xFA\xB8\x9E\xC0O\xC2+\xDE\xDB\xD7xE\xDE\xC7]\xF2~\x9BX1\x8E\xB9\x8C\x93+ "\x9Bb\x83&r\xA3ʼ\xDF$W$~\xE9,\xF8c\xF4=\xA1߷\xC3\xE4\x8E`1~\xC3/\xFB\x99 \xCF\xDB!T\xA1\xE9'\x81\x85P\xC4W\xDA\xE2\xD0~\x8D<\xAE\xB0\xB1k\xE3\xC18RSס\xDA\xE3DX\x8A\x942F\xAAD=&Rv_\x9E'u\x9A\xB55 \xFFߣ\xFEko~\x9Bendstream +endobj +86 0 obj << +/Type /Page +/Contents 88 0 R +/Resources 87 0 R +/MediaBox [0 0 612 792] +/Parent 97 0 R +>> endobj +89 0 obj << +/D [86 0 R /XYZ 93.6002 733.9477 null] +>> endobj +90 0 obj << +/D [86 0 R /XYZ 93.6002 720 null] +>> endobj +87 0 obj << +/Font << /F35 93 0 R /F34 96 0 R >> +/ProcSet [ /PDF /Text ] +>> endobj +100 0 obj << +/Length 92 +/Filter /FlateDecode +>> +stream +xڍ\x8D1\x800\xF7\xBE"h7iӼ\x80\x87t`\xE2\xFF+Ab@\x82y\xB1\xE5\x93 +\x92(\x94\x87H#W\xE50wZGڳ\xDB +nƚ\xB1G\x8Cmmp։\xCB\xE5Ğԛg\xC3\xECTG\xEF.\xF8y;"5endstream +endobj +99 0 obj << +/Type /Page +/Contents 100 0 R +/Resources 98 0 R +/MediaBox [0 0 612 792] +/Parent 97 0 R +>> endobj +101 0 obj << +/D [99 0 R /XYZ 93.6002 733.9477 null] +>> endobj +98 0 obj << +/ProcSet [ /PDF ] +>> endobj +104 0 obj << +/Length 1520 +/Filter /FlateDecode +>> +stream +xڝY\xDBn\xDC6}\xF7W\xE8-Z\xA0\xCB\xF2N\xC0E\xB4\xB5\xD1>4}\x90w7k!{q\xB5r\x8C\xF4\xEB;\xA4Hi\xB4\xBA\xA1\x82\x81ؒ\xA93Gg\x86C\x86%~Xbє\xF2\xC4A\xAC4&\xD9oh\xB2\x87gnX\xC0H.\x89\xB1V\xC3\xC5\xC0ӵb\xD6f\xC9O\xF2\xE3\xC3\xCD\xF7\xEF\x85J\x98$Bj\x9E<|N\xB8Q\x84Y\x93%ZP"\x84\xBB\xB9\xFD+}{>\xADM\xABKw\xCD_\x97\xD5\xDF?ݼ{h\xDEy*\xAB\x89Ԃ\xBBWO w\xFFP\x96\x94\xFB\xA4{\xE3w\xC41_\xE3\xF1\x9E"S\x89%Vs\xED\xF6\xDE\xE2 >\xE5ϫ5K\xAB]\xB9Z!RFVkkmzwZq\x93V%\xF0=\xAF\xD6<K\xB7/\xB7\xA9 +w\xE7t\xA7fg\xDDzj6\xA8\xAA\x8A "A\xCD.W5\xAA\x9B\xD1D\x89l\xB1l\xED\xF0 \xD5hP4D\xBBww\x9D@G\xFF\xFC\xE0>\xBBC\xC8\xF4\x92\xC1\x9D\xB5W\xF5\xE5\xB8sN\xDBb\x93\xEA9\x9E\xCB\xF3\xE3awtz\xE1\x99!L |
From: <jd...@us...> - 2007-10-29 15:02:41
|
Revision: 4050 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4050&view=rev Author: jdh2358 Date: 2007-10-29 08:02:39 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added newlink to pathces doc Modified Paths: -------------- trunk/py4science/doc/py4science.patches Modified: trunk/py4science/doc/py4science.patches =================================================================== --- trunk/py4science/doc/py4science.patches 2007-10-29 14:53:09 UTC (rev 4049) +++ trunk/py4science/doc/py4science.patches 2007-10-29 15:02:39 UTC (rev 4050) @@ -55,4 +55,4 @@ again in a few days to remind us to deal with it. 6) Congratulations, you are now open source contributors. Don't - forget to pad your resume as needed. \ No newline at end of file + forget to pad your resume as needed. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-29 14:53:12
|
Revision: 4049 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4049&view=rev Author: jdh2358 Date: 2007-10-29 07:53:09 -0700 (Mon, 29 Oct 2007) Log Message: ----------- updates to patches instructions Modified Paths: -------------- trunk/py4science/doc/py4science.patches Modified: trunk/py4science/doc/py4science.patches =================================================================== --- trunk/py4science/doc/py4science.patches 2007-10-29 14:48:20 UTC (rev 4048) +++ trunk/py4science/doc/py4science.patches 2007-10-29 14:53:09 UTC (rev 4049) @@ -3,45 +3,51 @@ 1) get an svn checkout of the py4science dir. - > svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science + > svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science - If you already have a checkout (eg on the machine we worked on in - the classroom), you just need to do + If you already have a checkout, you just need to do - > svn up + > svn up - If you are a windows user, you may want to checkout TortoiseSVN at - http://tortoisesvn.tigris.org. + If you are a windows user, you may want to checkout TortoiseSVN at + http://tortoisesvn.tigris.org. 2) Find something to fix or contribute. You can fix a typo in the workbook, some code in the examples or skeletons, add your own examples, write better explanations or comments in the workbbok, examples, or skeletons, or even fix this document you are reading now, which lives in doc/py4science.patches in the svn repository. - Make the changes in your local repository. + Make the changes in your local repository. The more you do the + better. For example, you might want to add a document to the doc + subdirectory explaining how to install and use TortiseSVN with + py4science for windows users, but if you do this don't forget to + edit the py4science.patches document to to remove this suggestion! -3) If you fix something, test it. If you mkodify an example, make +3) If you fix something, test it. If you modify an example, make sure it still runs and generates the desired output and figures. If you modify the TeX source of the workbook, make sure you can - compile it with pdflatex and view the output main.pdf. Once you - patch is accepted, it will affect py4science users worldwide, so - try and get it right! + compile it with pdflatex and view the output main.pdf. + > pdflatex main + + Once your patch is accepted, it will affect py4science users + worldwide, so try and get it right! + 4) Do an svn diff to create a patch file. Try and make the patch name meaningful, eg if you are creating a patch for the FFT denoising explanation in the workbook, do something like - > svn diff > fft_denoise.patch + > svn diff > fft_denoise.patch 5) Send the patch to the py4science mailing list by mailing py4...@co.... If you are not already subscribed, you can do so at - http://code.astraw.com/cgi-bin/mailman/listinfo/py4science + http://code.astraw.com/cgi-bin/mailman/listinfo/py4science (after you subscribe, you will get a confirmation email and you will need to click on the confirm link). When sending your patch, - send a brief explanation of the problemand solution with a helpful + send a brief explanation of the problem and solution with a helpful subject header, and *attach* your patch rather than paste it into the email browser. If you don't get any response on your patch (eg, "Thanks, I've committed this to svn revision 4096" or "I don't This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-29 14:48:25
|
Revision: 4048 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4048&view=rev Author: jdh2358 Date: 2007-10-29 07:48:20 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added instructions for py4science contribs Added Paths: ----------- trunk/py4science/doc/py4science.patches Removed Paths: ------------- trunk/py4science/workbook/main.pdf Added: trunk/py4science/doc/py4science.patches =================================================================== --- trunk/py4science/doc/py4science.patches (rev 0) +++ trunk/py4science/doc/py4science.patches 2007-10-29 14:48:20 UTC (rev 4048) @@ -0,0 +1,52 @@ +How to submit a patch for the py4science course materials + + +1) get an svn checkout of the py4science dir. + + > svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science + + If you already have a checkout (eg on the machine we worked on in + the classroom), you just need to do + + > svn up + + If you are a windows user, you may want to checkout TortoiseSVN at + http://tortoisesvn.tigris.org. + +2) Find something to fix or contribute. You can fix a typo in the + workbook, some code in the examples or skeletons, add your own + examples, write better explanations or comments in the workbbok, + examples, or skeletons, or even fix this document you are reading + now, which lives in doc/py4science.patches in the svn repository. + Make the changes in your local repository. + +3) If you fix something, test it. If you mkodify an example, make + sure it still runs and generates the desired output and figures. + If you modify the TeX source of the workbook, make sure you can + compile it with pdflatex and view the output main.pdf. Once you + patch is accepted, it will affect py4science users worldwide, so + try and get it right! + +4) Do an svn diff to create a patch file. Try and make the patch name + meaningful, eg if you are creating a patch for the FFT denoising + explanation in the workbook, do something like + + > svn diff > fft_denoise.patch + +5) Send the patch to the py4science mailing list by mailing + py4...@co.... If you are not already subscribed, you + can do so at + + http://code.astraw.com/cgi-bin/mailman/listinfo/py4science + + (after you subscribe, you will get a confirmation email and you + will need to click on the confirm link). When sending your patch, + send a brief explanation of the problemand solution with a helpful + subject header, and *attach* your patch rather than paste it into + the email browser. If you don't get any response on your patch + (eg, "Thanks, I've committed this to svn revision 4096" or "I don't + think this patch is a good idea because blah blah") then email + again in a few days to remind us to deal with it. + +6) Congratulations, you are now open source contributors. Don't + forget to pad your resume as needed. \ No newline at end of file Deleted: trunk/py4science/workbook/main.pdf =================================================================== --- trunk/py4science/workbook/main.pdf 2007-10-29 14:44:18 UTC (rev 4047) +++ trunk/py4science/workbook/main.pdf 2007-10-29 14:48:20 UTC (rev 4048) @@ -1,20230 +0,0 @@ -%PDF-1.4 -5 0 obj -<< /S /GoTo /D (chapter.1) >> -endobj -8 0 obj -(Chapter 1. Introduction) -endobj -9 0 obj -<< /S /GoTo /D (chapter.2) >> -endobj -12 0 obj -(Chapter 2. Simple non-numerical problems) -endobj -13 0 obj -<< /S /GoTo /D (section.2.1) >> -endobj -16 0 obj -(1. Sorting quickly with QuickSort ) -endobj -17 0 obj -<< /S /GoTo /D (section.2.2) >> -endobj -20 0 obj -(2. Dictionaries for counting words) -endobj -21 0 obj -<< /S /GoTo /D (chapter.3) >> -endobj -24 0 obj -(Chapter 3. Working with files, the internet, and numpy arrays) -endobj -25 0 obj -<< /S /GoTo /D (section.3.1) >> -endobj -28 0 obj -(1. Loading and saving ASCII data) -endobj -29 0 obj -<< /S /GoTo /D (section.3.2) >> -endobj -32 0 obj -(2. Working with CSV files) -endobj -33 0 obj -<< /S /GoTo /D (section.3.3) >> -endobj -36 0 obj -(3. Loading and saving binary data) -endobj -37 0 obj -<< /S /GoTo /D (chapter.4) >> -endobj -40 0 obj -(Chapter 4. Elementary Numerics) -endobj -41 0 obj -<< /S /GoTo /D (section.4.1) >> -endobj -44 0 obj -(1. Wallis' slow road to ) -endobj -45 0 obj -<< /S /GoTo /D (section.4.2) >> -endobj -48 0 obj -(2. Trapezoidal rule) -endobj -49 0 obj -<< /S /GoTo /D (section.4.3) >> -endobj -52 0 obj -(3. Newton's method) -endobj -53 0 obj -<< /S /GoTo /D (chapter.5) >> -endobj -56 0 obj -(Chapter 5. Linear algebra) -endobj -57 0 obj -<< /S /GoTo /D (section.5.1) >> -endobj -60 0 obj -(1. Glass Moir\351 Patterns) -endobj -61 0 obj -<< /S /GoTo /D (chapter.6) >> -endobj -64 0 obj -(Chapter 6. Signal processing) -endobj -65 0 obj -<< /S /GoTo /D (section.6.1) >> -endobj -68 0 obj -(1. Convolution) -endobj -69 0 obj -<< /S /GoTo /D (section.6.2) >> -endobj -72 0 obj -(2. FFT Image Denoising) -endobj -73 0 obj -<< /S /GoTo /D (chapter.7) >> -endobj -76 0 obj -(Chapter 7. Statistics) -endobj -77 0 obj -<< /S /GoTo /D (section.7.1) >> -endobj -80 0 obj -(1. Descriptive statistics) -endobj -81 0 obj -<< /S /GoTo /D (section.7.2) >> -endobj -84 0 obj -(2. Statistical distributions) -endobj -85 0 obj -<< /S /GoTo /D [86 0 R /Fit ] >> -endobj -88 0 obj << -/Length 321 -/Filter /FlateDecode ->> -stream -xڍQ;O\xC30\xDE\xF3+<\xDAC\x9F_\x8F\xBC -\xEAT\xA9\x91(CHB\x95:(jU\xC1\xAF\xC7NhU$dɖ}\xDF\xE3>22\xAF\xC1I\xA9i -\xDE\xB1z\x97I\xB6\x8E\xB5\x870F \xEF]\xBC\xFCQ\xCD-\xA0\xBD/X~)rSfW3m\xD0\xC6)V\xBE1%%(\xEB -\xE6PC\xA1#\xA3l\x9E\xF9b\xA8\xEA}WW\xEF"\xF8\xB2\xEE\xDA \xB4\xE4{\x81\xBC9\xF2\x95ԦNE\xC7o\xFB]z\xF98\x9C\x8Ba-^\xCA9#\x85hY\xAEPI\x95\xBB0I.>2Q6}\xE1\xB9R愞\xFA\xB8\x9E\xC0O\xC2+\xDE\xDB\xD7xE\xDE\xC7]\xF2~\x9BX1\x8E\xB9\x8C\x93+ "\x9Bb\x83&r\xA3ʼ\xDF$W$~\xE9,\xF8c\xF4=\xA1߷\xC3\xE4\x8E`1~\xC3/\xFB\x99 \xCF\xDB!T\xA1\xE9'\x81\x85P\xC4W\xDA\xE2\xD0~\x8D<\xAE\xB0\xB1k\xE3\xC18RSס\xDA\xE3DX\x8A\x942F\xAAD=&Rv_\x9E'u\x9A\xB55 \xFFߣ\xFEko~\x9Bendstream -endobj -86 0 obj << -/Type /Page -/Contents 88 0 R -/Resources 87 0 R -/MediaBox [0 0 612 792] -/Parent 97 0 R ->> endobj -89 0 obj << -/D [86 0 R /XYZ 93.6002 733.9477 null] ->> endobj -90 0 obj << -/D [86 0 R /XYZ 93.6002 720 null] ->> endobj -87 0 obj << -/Font << /F35 93 0 R /F34 96 0 R >> -/ProcSet [ /PDF /Text ] ->> endobj -100 0 obj << -/Length 92 -/Filter /FlateDecode ->> -stream -xڍ\x8D1\x800\xF7\xBE"h7iӼ\x80\x87t`\xE2\xFF+Ab@\x82y\xB1\xE5\x93 -\x92(\x94\x87H#W\xE50wZGڳ\xDB -nƚ\xB1G\x8Cmmp։\xCB\xE5Ğԛg\xC3\xECTG\xEF.\xF8y;"5endstream -endobj -99 0 obj << -/Type /Page -/Contents 100 0 R -/Resources 98 0 R -/MediaBox [0 0 612 792] -/Parent 97 0 R ->> endobj -101 0 obj << -/D [99 0 R /XYZ 93.6002 733.9477 null] ->> endobj -98 0 obj << -/ProcSet [ /PDF ] ->> endobj -104 0 obj << -/Length 1520 -/Filter /FlateDecode ->> -stream -xڝY\xDBn\xDC6}\xF7W\xE8-Z\xA0\xCB\xF2N\xC0E\xB4\xB5\xD1>4}\x90w7k!{q\xB5r\x8C\xF4\xEB;\xA4Hi\xB4\xBA\xA1\x82\x81ؒ\xA93Gg\x86C\x86%~Xbє\xF2\xC4A\xAC4&\xD9oh\xB2\x87gnX\xC0H.\x89\xB1V\xC3\xC5\xC0ӵb\xD6f\xC9O\xF2\xE3\xC3\xCD\xF7\xEF\x85J\x98$Bj\x9E<|N\xB8Q\x84Y\x93%ZP"\x84\xBB\xB9\xFD+}{>\xADM\xABKw\xCD_\x97\xD5\xDF?ݼ{h\xDEy*\xAB\x89Ԃ\xBBWO w\xFFP\x96\x94\xFB\xA4{\xE3w\xC41_\xE3\xF1\x9E"S\x89%Vs\xED\xF6\xDE\xE2 >\xE5ϫ5K\xAB]\xB9Z!RFVkkmzwZq\x93V%\xF0=\xAF\xD6<K\xB7/\xB7\xA9 -w\xE7t\xA7fg\xDDzj6\xA8\xAA\x8A "A\xCD.W5\xAA\x9B\xD1D\x89l\xB1l\xED\xF0 \xD5hP4D\xBBww\x9D@G\xFF\xFC\xE0>\xBBC\xC8\xF4\x92\xC1\x9D\xB5W\xF5\xE5\xB8sN\xDBb\x93\xEA9\x9E\xCB\xF3\xE3awtz\xE1\x99!L |
From: <md...@us...> - 2007-10-29 14:44:27
|
Revision: 4047 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4047&view=rev Author: mdboom Date: 2007-10-29 07:44:18 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Fixing bug in font rendering -- the patented freetype hinter appears to be unable to deal with the non-square hinting grid hack. [Forgot this file]. Modified Paths: -------------- trunk/matplotlib/src/ft2font.cpp Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2007-10-29 14:30:51 UTC (rev 4046) +++ trunk/matplotlib/src/ft2font.cpp 2007-10-29 14:44:18 UTC (rev 4047) @@ -943,7 +943,7 @@ angle = angle/360.0*2*3.14159; - long flags = FT_LOAD_DEFAULT; + long flags = FT_LOAD_FORCE_AUTOHINT; if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); @@ -1054,7 +1054,7 @@ } char FT2Font::load_char__doc__[] = -"load_char(charcode, flags=LOAD_LOAD_DEFAULT)\n" +"load_char(charcode, flags=LOAD_FORCE_AUTOHINT)\n" "\n" "Load character with charcode in current fontfile and set glyph.\n" "The flags argument can be a bitwise-or of the LOAD_XXX constants.\n" @@ -1075,7 +1075,7 @@ //load a char using the unsigned long charcode args.verify_length(1); - long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_DEFAULT); + long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT); if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 14:30:53
|
Revision: 4046 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4046&view=rev Author: mdboom Date: 2007-10-29 07:30:51 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Fixing bug in font rendering -- the patented freetype hinter appears to be unable to deal with the non-square hinting grid hack. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-10-29 13:40:42 UTC (rev 4045) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-10-29 14:30:51 UTC (rev 4046) @@ -82,7 +82,7 @@ from matplotlib.cbook import enumerate, is_string_like, exception_to_str from matplotlib.figure import Figure from matplotlib.font_manager import findfont -from matplotlib.ft2font import FT2Font, LOAD_DEFAULT +from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT from matplotlib.mathtext import MathTextParser from matplotlib.transforms import lbwh_to_bbox @@ -196,9 +196,9 @@ font = self._get_agg_font(prop) if font is None: return None if len(s) == 1 and ord(s) > 127: - font.load_char(ord(s), flags=LOAD_DEFAULT) + font.load_char(ord(s), flags=LOAD_FORCE_AUTOHINT) else: - font.set_text(s, 0, flags=LOAD_DEFAULT) + font.set_text(s, 0, flags=LOAD_FORCE_AUTOHINT) font.draw_glyphs_to_bitmap() #print x, y, int(x), int(y) @@ -231,7 +231,7 @@ self.mathtext_parser.parse(s, self.dpi.get(), prop) return width, height, descent font = self._get_agg_font(prop) - font.set_text(s, 0.0, flags=LOAD_DEFAULT) # the width and height of unrotated string + font.set_text(s, 0.0, flags=LOAD_FORCE_AUTOHINT) # the width and height of unrotated string w, h = font.get_width_height() d = font.get_descent() w /= 64.0 # convert from subpixels Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-10-29 13:40:42 UTC (rev 4045) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-10-29 14:30:51 UTC (rev 4046) @@ -143,7 +143,7 @@ from matplotlib.afm import AFM from matplotlib.cbook import enumerate, iterable, Bunch, get_realpath_and_stat, \ is_string_like -from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_DEFAULT, LOAD_NO_HINTING +from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING from matplotlib.font_manager import findfont, FontProperties from matplotlib._mathtext_data import latex_to_bakoma, \ latex_to_standard, tex2uni, type12uni, tex2type1, uni2type1, \ @@ -306,7 +306,7 @@ self.fonts_object.get_used_characters()) def get_hinting_type(self): - return LOAD_DEFAULT + return LOAD_FORCE_AUTOHINT def MathtextBackendAgg(): return MathtextBackendBbox(MathtextBackendAggRender()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-10-29 13:40:46
|
Revision: 4045 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4045&view=rev Author: jswhit Date: 2007-10-29 06:40:42 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Modified Paths: -------------- trunk/toolkits/basemap/README Modified: trunk/toolkits/basemap/README =================================================================== --- trunk/toolkits/basemap/README 2007-10-29 13:39:11 UTC (rev 4044) +++ trunk/toolkits/basemap/README 2007-10-29 13:40:42 UTC (rev 4045) @@ -84,5 +84,6 @@ Eric Firing Rob Hetland Scott Sinclair +Ivan Lima for valuable contributions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-10-29 13:39:45
|
Revision: 4044 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4044&view=rev Author: jswhit Date: 2007-10-29 06:39:11 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added "Thanks" Modified Paths: -------------- trunk/toolkits/basemap/README Modified: trunk/toolkits/basemap/README =================================================================== --- trunk/toolkits/basemap/README 2007-10-29 12:58:30 UTC (rev 4043) +++ trunk/toolkits/basemap/README 2007-10-29 13:39:11 UTC (rev 4044) @@ -73,3 +73,16 @@ **Contact** Jeff Whitaker <jef...@no...> + + +**Thanks** + +to + +John Hunter +Andrew Straw +Eric Firing +Rob Hetland +Scott Sinclair + +for valuable contributions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-10-29 12:58:33
|
Revision: 4043 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4043&view=rev Author: jswhit Date: 2007-10-29 05:58:30 -0700 (Mon, 29 Oct 2007) Log Message: ----------- support for masked vel vectors. Modified Paths: -------------- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-10-29 12:53:17 UTC (rev 4042) +++ trunk/toolkits/basemap/Changelog 2007-10-29 12:58:30 UTC (rev 4043) @@ -1,7 +1,7 @@ version 0.9.7 (not yet released) * fix rotate_vector so it works in S. Hem and for non-orthogonal - grids (EF) - * numpification (EF) + grids. Support for masked velocity vectors also added. (EF) + * numpification. (EF) version 0.9.6 (svn revision 3888) * fix addcyclic function so it handles masked arrays. * labelling of meridians and parallels now works with This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-10-29 12:53:24
|
Revision: 4042 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4042&view=rev Author: jswhit Date: 2007-10-29 05:53:17 -0700 (Mon, 29 Oct 2007) Log Message: ----------- numpification and fixes for rotate_vector (EF) Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py trunk/toolkits/basemap/setup.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-10-28 19:03:49 UTC (rev 4041) +++ trunk/toolkits/basemap/Changelog 2007-10-29 12:53:17 UTC (rev 4042) @@ -1,3 +1,7 @@ +version 0.9.7 (not yet released) + * fix rotate_vector so it works in S. Hem and for non-orthogonal + grids (EF) + * numpification (EF) version 0.9.6 (svn revision 3888) * fix addcyclic function so it handles masked arrays. * labelling of meridians and parallels now works with Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-10-28 19:03:49 UTC (rev 4041) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-10-29 12:53:17 UTC (rev 4042) @@ -12,6 +12,7 @@ from proj import Proj import matplotlib.numerix as NX from matplotlib.numerix import ma +import numpy as npy from numpy import linspace from matplotlib.numerix.mlab import squeeze from matplotlib.cbook import popd, is_scalar @@ -20,7 +21,7 @@ # basemap data files now installed in lib/matplotlib/toolkits/basemap/data basemap_datadir = os.sep.join([os.path.dirname(__file__), 'data']) -__version__ = '0.9.6' +__version__ = '0.9.7' # test to see numerix set to use numpy (if not, raise an error) if NX.which[0] != 'numpy': @@ -2175,13 +2176,33 @@ uin = interp(uin,lons,lats,lonsout,latsout,checkbounds=checkbounds,order=order,masked=masked) vin = interp(vin,lons,lats,lonsout,latsout,checkbounds=checkbounds,order=order,masked=masked) # rotate from geographic to map coordinates. - delta = 0.1 # increment in latitude used to estimate derivatives. - xn,yn = self(lonsout,NX.where(latsout+delta<90.,latsout+delta,latsout-delta)) - # northangle is the angle between true north and the y axis. - northangle = NX.where(lats+delta<90, NX.arctan2(xn-x, yn-y), - NX.arctan2(x-xn, y-yn)) - uout = uin*NX.cos(northangle) + vin*NX.sin(northangle) - vout = vin*NX.cos(northangle) - uin*NX.sin(northangle) + if ma.isMaskedArray(uin): + mask = ma.getmaskarray(uin) + uin = uin.filled(1) + vin = vin.filled(1) + masked = True # override kwarg with reality + uvc = uin + 1j*vin + uvmag = npy.abs(uvc) + delta = 0.1 # increment in longitude + dlon = delta*uin/uvmag + dlat = delta*(vin/uvmag)*npy.cos(latsout*npy.pi/180.0) + farnorth = latsout+dlat >= 90.0 + somenorth = farnorth.any() + if somenorth: + dlon[farnorth] *= -1.0 + dlat[farnorth] *= -1.0 + lon1 = lonsout + dlon + lat1 = latsout + dlat + xn, yn = self(lon1, lat1) + vecangle = npy.arctan2(yn-y, xn-x) + if somenorth: + vecangle[farnorth] += npy.pi + uvcout = uvmag * npy.exp(1j*vecangle) + uout = uvcout.real + vout = uvcout.imag + if masked: + uout = ma.array(uout, mask=mask) + vout = ma.array(vout, mask=mask) if returnxy: return uout,vout,x,y else: @@ -2210,12 +2231,35 @@ """ x, y = self(lons, lats) # rotate from geographic to map coordinates. - delta = 0.1 # increment in latitude used to estimate derivatives. - xn,yn = self(lons,NX.where(lats+delta<90.,lats+delta,lats-delta)) - northangle = NX.where(lats+delta<90, NX.arctan2(xn-x, yn-y), - NX.arctan2(x-xn, y-yn)) - uout = uin*NX.cos(northangle) + vin*NX.sin(northangle) - vout = vin*NX.cos(northangle) - uin*NX.sin(northangle) + if ma.isMaskedArray(uin): + mask = ma.getmaskarray(uin) + masked = True + uin = uin.filled(1) + vin = vin.filled(1) + else: + masked = False + uvc = uin + 1j*vin + uvmag = npy.abs(uvc) + delta = 0.1 # increment in longitude + dlon = delta*uin/uvmag + dlat = delta*(vin/uvmag)*npy.cos(lats*npy.pi/180.0) + farnorth = lats+dlat >= 90.0 + somenorth = farnorth.any() + if somenorth: + dlon[farnorth] *= -1.0 + dlat[farnorth] *= -1.0 + lon1 = lons + dlon + lat1 = lats + dlat + xn, yn = self(lon1, lat1) + vecangle = npy.arctan2(yn-y, xn-x) + if somenorth: + vecangle[farnorth] += npy.pi + uvcout = uvmag * npy.exp(1j*vecangle) + uout = uvcout.real + vout = uvcout.imag + if masked: + uout = ma.array(uout, mask=mask) + vout = ma.array(vout, mask=mask) if returnxy: return uout,vout,x,y else: Modified: trunk/toolkits/basemap/setup.py =================================================================== --- trunk/toolkits/basemap/setup.py 2007-10-28 19:03:49 UTC (rev 4041) +++ trunk/toolkits/basemap/setup.py 2007-10-29 12:53:17 UTC (rev 4042) @@ -88,7 +88,7 @@ package_data = {'matplotlib.toolkits.basemap':pyproj_datafiles+basemap_datafiles} setup( name = "basemap", - version = "0.9.6", + version = "0.9.7", description = "Plot data on map projections with matplotlib", long_description = """ An add-on toolkit for matplotlib that lets you plot data This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-28 19:04:00
|
Revision: 4041 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4041&view=rev Author: jdh2358 Date: 2007-10-28 12:03:49 -0700 (Sun, 28 Oct 2007) Log Message: ----------- syncing after pomona workshop Modified Paths: -------------- trunk/py4science/doc/linkfest Modified: trunk/py4science/doc/linkfest =================================================================== --- trunk/py4science/doc/linkfest 2007-10-28 16:35:18 UTC (rev 4040) +++ trunk/py4science/doc/linkfest 2007-10-28 19:03:49 UTC (rev 4041) @@ -64,7 +64,7 @@ matplotlib: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib - py4science workbook: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science/workbook + py4science: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science Important commands: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-28 16:35:25
|
Revision: 4040 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4040&view=rev Author: jdh2358 Date: 2007-10-28 09:35:18 -0700 (Sun, 28 Oct 2007) Log Message: ----------- fixed some bugs in convolve Modified Paths: -------------- trunk/py4science/examples/skel/convolution_demo_skel.py trunk/py4science/workbook/convolution.tex trunk/py4science/workbook/intro_sigproc.tex Modified: trunk/py4science/examples/skel/convolution_demo_skel.py =================================================================== --- trunk/py4science/examples/skel/convolution_demo_skel.py 2007-10-28 15:18:02 UTC (rev 4039) +++ trunk/py4science/examples/skel/convolution_demo_skel.py 2007-10-28 16:35:18 UTC (rev 4040) @@ -40,7 +40,7 @@ # evaluate the impulse response function, and numerically convolve it # with the input x r = XXX # evaluate the impulse function -y = XXX # convultion of x with r +y = XXX # convolution of x with r y = XXX # extract just the length Nt part # compute y by applying F^-1[F(x) * F(r)]. The fft assumes the signal Modified: trunk/py4science/workbook/convolution.tex =================================================================== --- trunk/py4science/workbook/convolution.tex 2007-10-28 15:18:02 UTC (rev 4039) +++ trunk/py4science/workbook/convolution.tex 2007-10-28 16:35:18 UTC (rev 4040) @@ -3,9 +3,9 @@ The output of a linear system is given by the convolution of its impulse response function with the input. Mathematically -\[ +\begin{equation} y(t) = \int_0^t x(\tau)r(t-\tau)d\tau -\] +\end{equation} This fundamental relationship lies at the heart of linear systems analysis. It is used to model the dynamics of calcium buffers in neuronal synapses, where incoming action potentials are represented as Modified: trunk/py4science/workbook/intro_sigproc.tex =================================================================== --- trunk/py4science/workbook/intro_sigproc.tex 2007-10-28 15:18:02 UTC (rev 4039) +++ trunk/py4science/workbook/intro_sigproc.tex 2007-10-28 16:35:18 UTC (rev 4040) @@ -12,4 +12,4 @@ analyses, such as historgrams (\texttt{hist}), auto and cross correlations (\texttt{acorr} and \texttt{xcorr}), power spectra and coherence spectra (\texttt{psd}, \texttt{csd}, \texttt{cohere} and -\texttt{specgram}. +\texttt{specgram}). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-28 15:18:08
|
Revision: 4039 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4039&view=rev Author: jdh2358 Date: 2007-10-28 08:18:02 -0700 (Sun, 28 Oct 2007) Log Message: ----------- added time series to specgram Modified Paths: -------------- trunk/matplotlib/examples/specgram_demo.py Modified: trunk/matplotlib/examples/specgram_demo.py =================================================================== --- trunk/matplotlib/examples/specgram_demo.py 2007-10-28 15:00:36 UTC (rev 4038) +++ trunk/matplotlib/examples/specgram_demo.py 2007-10-28 15:18:02 UTC (rev 4039) @@ -21,6 +21,9 @@ # the frequency vector, bins are the centers of the time bins in which # the power is computed, and im is the matplotlib.image.AxesImage # instance + +ax1 = subplot(211) +plot(t, x) +subplot(212, sharex=ax1) Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900) -colorbar() show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-28 15:00:39
|
Revision: 4038 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4038&view=rev Author: jdh2358 Date: 2007-10-28 08:00:36 -0700 (Sun, 28 Oct 2007) Log Message: ----------- added lotka example Modified Paths: -------------- trunk/py4science/examples/qsort.py Added Paths: ----------- trunk/py4science/examples/lotka_volterra.py trunk/py4science/examples/skel/lotka_volterra_skel.py Added: trunk/py4science/examples/lotka_volterra.py =================================================================== --- trunk/py4science/examples/lotka_volterra.py (rev 0) +++ trunk/py4science/examples/lotka_volterra.py 2007-10-28 15:00:36 UTC (rev 4038) @@ -0,0 +1,78 @@ +import numpy as n +import pylab as p +import scipy.integrate as integrate + +def dr(r, f): + return alpha*r - beta*r*f + +def df(r, f): + return gamma*r*f - delta*f + +def derivs(state, t): + """ + Map the state variable [rabbits, foxes] to the derivitives + [deltar, deltaf] at time t + """ + #print t, state + r, f = state # rabbits and foxes + deltar = dr(r, f) # change in rabbits + deltaf = df(r, f) # change in foxes + return deltar, deltaf + +alpha, delta = 1, .25 +beta, gamma = .2, .05 + +# the initial population of rabbits and foxes +r0 = 20 +f0 = 10 + +t = n.arange(0.0, 100, 0.1) + +y0 = [r0, f0] # the initial [rabbits, foxes] state vector +y = integrate.odeint(derivs, y0, t) +r = y[:,0] # extract the rabbits vector +f = y[:,1] # extract the foxes vector + +p.figure() +p.plot(t, r, label='rabbits') +p.plot(t, f, label='foxes') +p.xlabel('time (years)') +p.ylabel('population') +p.title('population trajectories') +p.grid() +p.legend() +p.savefig('lotka_volterra.png', dpi=150) +p.savefig('lotka_volterra.eps') + + +p.figure() +p.plot(r, f) +p.xlabel('rabbits') +p.ylabel('foxes') +p.title('phase plane') + + +# make a direction field plot with quiver +rmax = 1.1 * r.max() +fmax = 1.1 * f.max() +R, F = n.meshgrid(n.arange(-1, rmax), n.arange(-1, fmax)) +dR = dr(R, F) +dF = df(R, F) +p.quiver(R, F, dR, dF) + + +R, F = n.meshgrid(n.arange(-1, rmax, .1), n.arange(-1, fmax, .1)) +dR = dr(R, F) +dF = df(R, F) + +p.contour(R, F, dR, levels=[0], linewidths=3, colors='black') +p.contour(R, F, dF, levels=[0], linewidths=3, colors='black') +p.ylabel('foxes') +p.title('trajectory, direction field and null clines') + +p.savefig('lotka_volterra_pplane.png', dpi=150) +p.savefig('lotka_volterra_pplane.eps') + + +p.show() + Modified: trunk/py4science/examples/qsort.py =================================================================== --- trunk/py4science/examples/qsort.py 2007-10-27 12:36:39 UTC (rev 4037) +++ trunk/py4science/examples/qsort.py 2007-10-28 15:00:36 UTC (rev 4038) @@ -33,5 +33,7 @@ rseq = range(10) random.shuffle(rseq) sseq = qsort(rseq) + print tseq + print sseq self.assertEqual(tseq,sseq) main() Added: trunk/py4science/examples/skel/lotka_volterra_skel.py =================================================================== --- trunk/py4science/examples/skel/lotka_volterra_skel.py (rev 0) +++ trunk/py4science/examples/skel/lotka_volterra_skel.py 2007-10-28 15:00:36 UTC (rev 4038) @@ -0,0 +1,56 @@ +import numpy as n +import pylab as p +import scipy.integrate as integrate + +def dr(r, f): + 'return delta r' + XXX + +def df(r, f): + 'return delta f' + XXX +def derivs(state, t): + """ + Map the state variable [rabbits, foxes] to the derivitives + [deltar, deltaf] at time t + """ + XXX + +alpha, delta = 1, .25 +beta, gamma = .2, .05 + +# the initial population of rabbits and foxes +r0 = 20 +f0 = 10 + +t = XXX # pick a time vector (think about the time scales!) +y0 = [r0, f0] # the initial [rabbits, foxes] state vector +y = XXX # integrate derives over t starting at y0 +r = XXX # extract the rabbits vector +f = XXX # extract the foxes vector + + +# FIGURE 1: rabbits vs time and foxes vs time on the same plot with +# legend and xlabel, ylabel and title + +# FIGURE 2: the phase plane + +# plot r vs f and label the x and y axes +XXX + +# FIGURE 2 continued.... + +# use meshgrid to make a grid over R and F +# with a coarse 1 year sampling. evaluate dR and dF over the 2 s +# grids and make a quiver plot. See pylab.quiver and matplotlib +# examples/quiver_demo.py +XXX + +# FIGURE 2 continued... use contour to compute the null clines over +# dR (the rabbits null cline) and dF (the foxes null cline). You will +# need to do a finer meshgrid for accurate null clins and pass +# levels=[0] to contour +XXX + +p.show() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-10-27 12:36:41
|
Revision: 4037 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4037&view=rev Author: jdh2358 Date: 2007-10-27 05:36:39 -0700 (Sat, 27 Oct 2007) Log Message: ----------- final commit before workshop Modified Paths: -------------- trunk/py4science/doc/linkfest trunk/py4science/examples/skel/trapezoid_skel.py Modified: trunk/py4science/doc/linkfest =================================================================== --- trunk/py4science/doc/linkfest 2007-10-27 06:23:13 UTC (rev 4036) +++ trunk/py4science/doc/linkfest 2007-10-27 12:36:39 UTC (rev 4037) @@ -64,9 +64,8 @@ matplotlib: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib - py4science: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science + py4science workbook: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science/workbook - Important commands: svn up : update the repo Modified: trunk/py4science/examples/skel/trapezoid_skel.py =================================================================== --- trunk/py4science/examples/skel/trapezoid_skel.py 2007-10-27 06:23:13 UTC (rev 4036) +++ trunk/py4science/examples/skel/trapezoid_skel.py 2007-10-27 12:36:39 UTC (rev 4037) @@ -14,6 +14,7 @@ y[i] = f(x[i]) for some function f to be integrated. Minimally modified from matplotlib.mlab.""" + raise NotImplementedError @@ -31,6 +32,11 @@ Output: - The value of the trapezoid-rule approximation to the integral.""" + + # you will need to apply the function f to easch element of the + # vector x. What are several ways to do this? Can you profile + # them to see what differences in timings result for long vectors + # x? raise NotImplementedError if __name__ == '__main__': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |