From: <jd...@us...> - 2007-12-05 15:16:52
|
Revision: 4614 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4614&view=rev Author: jdh2358 Date: 2007-12-05 07:16:48 -0800 (Wed, 05 Dec 2007) Log Message: ----------- exposed default color cycle Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/image.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-12-05 14:45:56 UTC (rev 4613) +++ trunk/matplotlib/API_CHANGES 2007-12-05 15:16:48 UTC (rev 4614) @@ -1,3 +1,5 @@ + Removed, dead/experimental ExampleInfo, Namespace and Importer + code from matplotlib/__init__.py 0.91.1 Released 0.91.0 Released Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-05 14:45:56 UTC (rev 4613) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-05 15:16:48 UTC (rev 4614) @@ -55,7 +55,7 @@ """ from __future__ import generators -__version__ = '0.91.1' +__version__ = '0.91.2svn' __revision__ = '$Revision$' __date__ = '$Date$' @@ -784,60 +784,3 @@ verbose.report('platform is %s'%sys.platform) verbose.report('loaded modules: %s'%sys.modules.keys(), 'debug') -class ExampleInfo: - pass - -class ExampleManager: - baseurl = 'http://matplotlib.sf.net' - urls = ['%s/%s'%(baseurl, subdir) for subdir in - ( 'examples', 'examples/widgets')] - - def get_examples(self): - import urllib, re - rgx = re.compile('.*<A HREF="([^.]+\.py)">.*') - examples = [] - for url in urls: - lines = urllib.urlopen(url).readlines() - for line in lines: - m = rgx.match(line) - if m is not None: - examples.append('%s/%s'%(url, m.group(1))) - return examples - - def get_info(self, s): - """ - return an ExampleInfo instance from s, the string content of - an example - """ - pass - -class Namespace: - """ - A class which takes a list of modules and creates an object with - the module naems at attrs - """ - def __init__(self, namespace): - for k,v in namespace.items(): - modname = getattr(v, '__name__', None) - if modname is None: continue - if modname.startswith('matplotlib.'): - self.__dict__[modname.replace('matplotlib.', '')] = v - - -class Importer: - def __init__(self, modstr): - """ - import a bunch of matplotlib modules listed in modstr into a - single namespace. Eg, - - mpl = Importer('artist, cbook, lines, patches') - print mpl.cbook.iterable(1) - """ - for name in modstr.split(','): - name = name.strip() - wholename = '.'.join(['matplotlib', name]) - basemod = __import__(wholename) - mod = getattr(basemod, name) - setattr(self, name, mod) - - Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007-12-05 14:45:56 UTC (rev 4613) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007-12-05 15:16:48 UTC (rev 4614) @@ -152,13 +152,14 @@ an arbitrary number of x, y, fmt are allowed """ + defaultColors = ['b','g','r','c','m','y','k'] def __init__(self, axes, command='plot'): self.axes = axes self.command = command self._clear_color_cycle() def _clear_color_cycle(self): - self.colors = ['b','g','r','c','m','y','k'] + self.colors = _process_plot_var_args.defaultColors[:] # if the default line color is a color format string, move it up # in the que try: ind = self.colors.index(rcParams['lines.color']) Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2007-12-05 14:45:56 UTC (rev 4613) +++ trunk/matplotlib/lib/matplotlib/image.py 2007-12-05 15:16:48 UTC (rev 4614) @@ -243,6 +243,8 @@ self.set_data(A) + + def set_extent(self, extent): """extent is data axes (left, right, bottom, top) for making image plots """ Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2007-12-05 14:45:56 UTC (rev 4613) +++ trunk/matplotlib/matplotlibrc.template 2007-12-05 15:16:48 UTC (rev 4614) @@ -25,7 +25,7 @@ #### CONFIGURATION BEGINS HERE # the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg -# Agg Cairo GD GDK Paint PS PDF SVG Template +# WX WXAgg Agg Cairo GD GDK Paint PS PDF SVG Template backend : %(backend)s numerix : %(numerix)s # numpy, Numeric or numarray #maskedarray : False # True to use external maskedarray module This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-05 16:21:07
|
Revision: 4618 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4618&view=rev Author: mdboom Date: 2007-12-05 08:20:54 -0800 (Wed, 05 Dec 2007) Log Message: ----------- Support arbitrary rotation of usetex text. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/texmanager.py trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-12-05 15:40:46 UTC (rev 4617) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-12-05 16:20:54 UTC (rev 4618) @@ -27,8 +27,8 @@ REQUIREMENTs python2.3+ - numpy 1.0 + - + numpy 1.0 + + agg2 (see below) freetype 2 libpng @@ -126,7 +126,7 @@ self.restore_region = self._renderer.restore_region self.mathtext_parser = MathTextParser('Agg') self._fontd = {} - + self.bbox = lbwh_to_bbox(0,0, self.width, self.height) if __debug__: verbose.report('RendererAgg.__init__ done', 'debug-annoying') @@ -175,7 +175,7 @@ 'debug-annoying') ox, oy, width, height, descent, font_image, used_characters = \ self.mathtext_parser.parse(s, self.dpi.get(), prop) - + x = int(x) + ox y = int(y) - oy self._renderer.draw_text_image(font_image, x, y + 1, angle, gc) @@ -209,7 +209,7 @@ self._renderer.draw_text_image(font.get_image(), int(x), int(y) + 1, angle, gc) - def get_text_width_height_descent(self, s, prop, ismath, rgb=(0,0,0)): + def get_text_width_height_descent(self, s, prop, ismath): """ get the width and height in display coords of the string s with FontPropertry prop @@ -222,8 +222,8 @@ # todo: handle props size = prop.get_size_in_points() texmanager = self.get_texmanager() - Z = texmanager.get_rgba(s, size, self.dpi.get(), rgb) - m,n,tmp = Z.shape + Z = texmanager.get_grey(s, size, self.dpi.get()) + m,n = Z.shape # TODO: descent of TeX text (I am imitating backend_ps here -JKS) return n, m, 0 @@ -242,45 +242,19 @@ def draw_tex(self, gc, x, y, s, prop, angle): # todo, handle props, angle, origins - rgb = gc.get_rgb() size = prop.get_size_in_points() dpi = self.dpi.get() - flip = angle==90 - w,h,d = self.get_text_width_height_descent(s, prop, 'TeX', rgb) - if flip: - w,h = h,w - x -= w - texmanager = self.get_texmanager() - key = s, size, dpi, rgb, angle, texmanager.get_font_config() + key = s, size, dpi, angle, texmanager.get_font_config() im = self.texd.get(key) if im is None: - Z = texmanager.get_rgba(s, size, dpi, rgb) - if flip: - r = Z[:,:,0] - g = Z[:,:,1] - b = Z[:,:,2] - a = Z[:,:,3] - m,n,tmp = Z.shape + Z = texmanager.get_grey(s, size, dpi) + Z = npy.array(Z * 255.0, npy.uint8) - def func(x): - return npy.transpose(npy.fliplr(x)) + self._renderer.draw_text_image(Z, x, y, angle, gc) - Z = npy.zeros((n,m,4), float) - Z[:,:,0] = func(r) - Z[:,:,1] = func(g) - Z[:,:,2] = func(b) - Z[:,:,3] = func(a) - im = fromarray(Z, 1) - im.flipud_out() - self.texd[key] = im - cliprect = gc.get_clip_rectangle() - if cliprect is None: bbox = None - else: bbox = lbwh_to_bbox(*cliprect) - self.draw_image(x, self.height-y, im, bbox) - def get_canvas_width_height(self): 'return the canvas width and height in display coords' return self.width, self.height @@ -413,8 +387,8 @@ self.draw() self.get_renderer()._renderer.write_rgba(str(filename)) print_rgba = print_raw - + def print_png(self, filename, *args, **kwargs): self.draw() self.get_renderer()._renderer.write_png(filename, self.figure.dpi.get()) - + Modified: trunk/matplotlib/lib/matplotlib/texmanager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/texmanager.py 2007-12-05 15:40:46 UTC (rev 4617) +++ trunk/matplotlib/lib/matplotlib/texmanager.py 2007-12-05 16:20:54 UTC (rev 4618) @@ -79,7 +79,8 @@ dvipngVersion = get_dvipng_version() # mappable cache of - arrayd = {} + rgba_arrayd = {} + grey_arrayd = {} postscriptd = {} pscnt = 0 @@ -131,7 +132,7 @@ found_font = self.font_info[font.lower()] setattr(self, font_family_attr, self.font_info[font.lower()]) - if DEBUG: + if DEBUG: print 'family: %s, font: %s, info: %s'%(font_family, font, self.font_info[font.lower()]) break @@ -323,6 +324,24 @@ return [int(val) for val in line.split()[1:]] raise RuntimeError('Could not parse %s'%psfile) + def get_grey(self, tex, fontsize=None, dpi=None): + key = tex, self.get_font_config(), fontsize, dpi + alpha = self.grey_arrayd.get(key) + + if alpha is None: + pngfile = self.make_png(tex, fontsize, dpi) + X = readpng(os.path.join(self.texcache, pngfile)) + + if (self.dvipngVersion < '1.6') or rcParams['text.dvipnghack']: + # hack the alpha channel as described in comment above + alpha = npy.sqrt(1-X[:,:,0]) + else: + alpha = X[:,:,-1] + + self.grey_arrayd[key] = alpha + return alpha + + def get_rgba(self, tex, fontsize=None, dpi=None, rgb=(0,0,0)): """ Return tex string as an rgba array @@ -351,23 +370,16 @@ if not dpi: dpi = rcParams['savefig.dpi'] r,g,b = rgb key = tex, self.get_font_config(), fontsize, dpi, tuple(rgb) - Z = self.arrayd.get(key) + Z = self.rgba_arrayd.get(key) if Z is None: - pngfile = self.make_png(tex, fontsize, dpi) - X = readpng(os.path.join(self.texcache, pngfile)) + alpha = self.get_grey(tex, fontsize, dpi) - if (self.dvipngVersion < '1.6') or rcParams['text.dvipnghack']: - # hack the alpha channel as described in comment above - alpha = npy.sqrt(1-X[:,:,0]) - else: - alpha = X[:,:,-1] - - Z = npy.zeros(X.shape, npy.float) + Z = npy.zeros((X.shape[0], X.shape[1], 4), npy.float) Z[:,:,0] = r Z[:,:,1] = g Z[:,:,2] = b Z[:,:,3] = alpha - self.arrayd[key] = Z + self.rgba_arrayd[key] = Z return Z Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2007-12-05 15:40:46 UTC (rev 4617) +++ trunk/matplotlib/src/_backend_agg.cpp 2007-12-05 16:20:54 UTC (rev 4618) @@ -1003,7 +1003,7 @@ for(k = firstRow; k <= lastRow; k++) { numCol = inPolygon(k, xs, ys, col); - + if (numCol >= 2) rendererBase->copy_hline(col[0], k, col[1] - 1, color); if (numCol == 4) rendererBase->copy_hline(col[2], k, col[3] - 1, color); } @@ -2137,9 +2137,25 @@ args.verify_length(5); - FT2Image *image = static_cast<FT2Image*>(args[0].ptr()); - if (!image->get_buffer()) - return Py::Object(); + const unsigned char* buffer = NULL; + int width, height; + Py::Object image_obj = args[0]; + if (PyArray_Check(image_obj.ptr())) { + PyArrayObject* image_array = NULL; + image_array = (PyArrayObject*)PyArray_FromObject(image_obj.ptr(), PyArray_UBYTE, 2, 2); + if (!image_array) + throw Py::ValueError("First argument to draw_text_image must be a FT2Font.Image object or a Nx2 uint8 numpy array."); + buffer = (unsigned char *)PyArray_DATA(image_array); + width = PyArray_DIM(image_array, 1); + height = PyArray_DIM(image_array, 0); + } else { + FT2Image *image = static_cast<FT2Image*>(args[0].ptr()); + if (!image->get_buffer()) + throw Py::ValueError("First argument to draw_text_image must be a FT2Font.Image object or a Nx2 uint8 numpy array."); + buffer = image->get_buffer(); + width = image->get_width(); + height = image->get_height(); + } int x(0),y(0); try { @@ -2157,22 +2173,19 @@ set_clipbox_rasterizer(gc.cliprect); - const unsigned char* const buffer = image->get_buffer(); - agg::rendering_buffer srcbuf - ((agg::int8u*)buffer, image->get_width(), - image->get_height(), image->get_width()); + agg::rendering_buffer srcbuf((agg::int8u*)buffer, width, height, width); agg::pixfmt_gray8 pixf_img(srcbuf); agg::trans_affine mtx; - mtx *= agg::trans_affine_translation(0, -(int)image->get_height()); + mtx *= agg::trans_affine_translation(0, -(int)height); mtx *= agg::trans_affine_rotation(-angle * agg::pi / 180.0); mtx *= agg::trans_affine_translation(x, y); agg::path_storage rect; rect.move_to(0, 0); - rect.line_to(image->get_width(), 0); - rect.line_to(image->get_width(), image->get_height()); - rect.line_to(0, image->get_height()); + rect.line_to(width, 0); + rect.line_to(width, height); + rect.line_to(0, height); rect.line_to(0, 0); agg::conv_transform<agg::path_storage> rect2(rect, mtx); Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2007-12-05 15:40:46 UTC (rev 4617) +++ trunk/matplotlib/src/_image.cpp 2007-12-05 16:20:54 UTC (rev 4618) @@ -850,7 +850,7 @@ char _image_module_readpng__doc__[] = "readpng(fname)\n" "\n" -"Load an image from png file into a numerix array of MxNx4 uint8"; +"Load an image from png file into a numerix array of MxNx4 float"; Py::Object _image_module::readpng(const Py::Tuple& args) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-05 19:27:18
|
Revision: 4629 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4629&view=rev Author: jdh2358 Date: 2007-12-05 11:27:14 -0800 (Wed, 05 Dec 2007) Log Message: ----------- minor rec2excel enhancements Modified Paths: -------------- trunk/matplotlib/examples/loadrec.py trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/examples/loadrec.py =================================================================== --- trunk/matplotlib/examples/loadrec.py 2007-12-05 18:57:54 UTC (rev 4628) +++ trunk/matplotlib/examples/loadrec.py 2007-12-05 19:27:14 UTC (rev 4629) @@ -9,4 +9,6 @@ ax = fig.add_subplot(111) ax.plot(a.date, a.adj_close, '-') fig.autofmt_xdate() + +mlab.rec2excel(a, 'test.xls', colnum=4) show() Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-05 18:57:54 UTC (rev 4628) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-05 19:27:14 UTC (rev 4629) @@ -2367,7 +2367,7 @@ xlstyle.num_format_str = '#,##;[RED]-#,##' elif isinstance(format, FormatPercent): zeros = ''.join(['0']*format.precision) - xlstyle.num_format_str = '0.%s%;[RED]-0.%s%'%(zeros, zeros) + xlstyle.num_format_str = '0.%s%%;[RED]-0.%s%%'%(zeros, zeros) format.scale = 1. else: xlstyle = None @@ -2376,12 +2376,14 @@ return format - def rec2excel(r, ws, formatd=None, rownum=0): + def rec2excel(r, ws, formatd=None, rownum=0, colnum=0): """ save record array r to excel pyExcelerator worksheet ws starting at rownum. if ws is string like, assume it is a filename and save to it + start writing at rownum, colnum + formatd is a dictionary mapping dtype name -> FormatXL instances The next rownum after writing is returned @@ -2399,6 +2401,12 @@ formatd = dict() formats = [] + font = excel.Font() + font.bold = True + + stylehdr = excel.XFStyle() + stylehdr.font = font + for i, name in enumerate(r.dtype.names): dt = r.dtype[name] format = formatd.get(name) @@ -2406,7 +2414,7 @@ format = defaultformatd.get(dt.type, FormatObj()) format = xlformat_factory(format) - ws.write(rownum, i, name) + ws.write(rownum, colnum+i, name, stylehdr) formats.append(format) rownum+=1 @@ -2419,12 +2427,12 @@ format = formats[i] val = format.toval(val) if format.xlstyle is None: - ws.write(rownum, i, val) + ws.write(rownum, colnum+i, val) else: if safe_isnan(val): - ws.write(rownum, i, 'NaN') + ws.write(rownum, colnum+i, 'NaN') else: - ws.write(rownum, i, val, format.xlstyle) + ws.write(rownum, colnum+i, val, format.xlstyle) rownum += 1 if autosave: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-06 02:36:09
|
Revision: 4638 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4638&view=rev Author: jdh2358 Date: 2007-12-05 18:36:05 -0800 (Wed, 05 Dec 2007) Log Message: ----------- changed offset naming for annotations Modified Paths: -------------- trunk/matplotlib/examples/annotation_demo.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/examples/annotation_demo.py =================================================================== --- trunk/matplotlib/examples/annotation_demo.py 2007-12-06 00:09:49 UTC (rev 4637) +++ trunk/matplotlib/examples/annotation_demo.py 2007-12-06 02:36:05 UTC (rev 4638) @@ -10,6 +10,7 @@ 'axes points' : points from lower left corner of axes 'axes pixels' : pixels from lower left corner of axes 'axes fraction' : 0,1 is lower left of axes and 1,1 is upper right + 'offset points' : Specify an offset (in points) from the xy value 'data' : use the axes data coordinate system Optionally, you can specify arrow properties which draws and arrow Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2007-12-06 00:09:49 UTC (rev 4637) +++ trunk/matplotlib/lib/matplotlib/text.py 2007-12-06 02:36:05 UTC (rev 4638) @@ -187,7 +187,7 @@ xmin, ymin = thisx, thisy lines = self._text.split('\n') - + whs = [] # Find full vertical extent of font, # including ascenders and descenders: @@ -1025,7 +1025,7 @@ 'axes pixels' : pixels from lower left corner of axes 'axes fraction' : 0,1 is lower left of axes and 1,1 is upper right 'data' : use the coordinate system of the object being annotated (default) - 'data offset' : Specify an offset (in points) from the xy value + 'offset points' : Specify an offset (in points) from the xy value 'polar' : you can specify theta, r for the annotation, even in cartesian plots. Note that if you are using a polar axes, you do not need @@ -1081,12 +1081,12 @@ x = float(self.convert_xunits(x)) y = float(self.convert_yunits(y)) return trans.xy_tup((x,y)) - elif s=='data offset': + elif s=='offset points': # convert the data point dx, dy = self.xy # prevent recursion - if self.xycoords == 'data offset': + if self.xycoords == 'offset points': return self._get_xy(dx, dy, 'data') dx, dy = self._get_xy(dx, dy, self.xycoords) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-12-06 16:24:06
|
Revision: 4645 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4645&view=rev Author: dsdale Date: 2007-12-06 08:23:58 -0800 (Thu, 06 Dec 2007) Log Message: ----------- modified svn:ignore properties to ignore generated files not under revision control Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/examples/ trunk/matplotlib/lib/ trunk/matplotlib/lib/matplotlib/mpl-data/ trunk/matplotlib/unit/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svn:ignore - build dist docs *.pyc .project matplotlibrc win32_static + build dist docs *.pyc .project matplotlibrc win32_static setup.cfg Property changes on: trunk/matplotlib/examples ___________________________________________________________________ Name: svn:ignore - *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg + matplotlibrc matplotlib.conf *.eps *.jpeg *.jpg *.pdf *.png *.ps *.pyc *.svg Property changes on: trunk/matplotlib/lib ___________________________________________________________________ Name: svn:ignore + matplotlib.egg-info Property changes on: trunk/matplotlib/lib/matplotlib/mpl-data ___________________________________________________________________ Name: svn:ignore + matplotlibrc matplotlib.conf Property changes on: trunk/matplotlib/unit ___________________________________________________________________ Name: svn:ignore + *.png This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-12-06 17:47:47
|
Revision: 4647 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4647&view=rev Author: dsdale Date: 2007-12-06 09:47:46 -0800 (Thu, 06 Dec 2007) Log Message: ----------- fixed a bug in rcsetup, see bug 1845057 Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/rcsetup.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-06 17:09:53 UTC (rev 4646) +++ trunk/matplotlib/CHANGELOG 2007-12-06 17:47:46 UTC (rev 4647) @@ -1,3 +1,5 @@ +2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD + =============================================================== 2007-11-27 Released 0.91.1 at revision 4517 Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-06 17:09:53 UTC (rev 4646) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-06 17:47:46 UTC (rev 4647) @@ -615,6 +615,15 @@ if ret['datapath'] is None: ret['datapath'] = get_data_path() + if not ret['text.latex.preamble'] == ['']: + verbose.report(""" +***************************************************************** +You have the following UNSUPPORTED LaTeX preamble customizations: +%s +Please do not ask for support with these customizations active. +***************************************************************** +"""% '\n'.join(ret['text.latex.preamble']), 'helpful') + verbose.report('loaded rc file %s'%fname) return ret Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-12-06 17:09:53 UTC (rev 4646) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2007-12-06 17:47:46 UTC (rev 4647) @@ -143,7 +143,7 @@ if len(s)==6 and s.isalnum(): # looks like hex return '#' + s - + if len(s)==7 and s.startswith('#') and s[1:].isalnum(): return s @@ -165,21 +165,6 @@ 'landscape', 'portrait', ]) -def validate_latex_preamble(s): - 'return a list' - preamble_list = validate_stringlist(s) - if not preamble_list == ['']: - verbose.report(""" -***************************************************************** -You have the following UNSUPPORTED LaTeX preamble customizations: -%s -Please do not ask for support with these customizations active. -***************************************************************** -"""% '\n'.join(preamble_list), 'helpful') - return preamble_list - - - def validate_aspect(s): if s in ('auto', 'equal'): return s @@ -198,7 +183,7 @@ return float(s) except ValueError: raise ValueError('not a valid font size') - + def validate_font_properties(s): parse_fontconfig_pattern(s) return s @@ -353,7 +338,7 @@ 'text.color' : ['k', validate_color], # black 'text.usetex' : [False, validate_bool], 'text.latex.unicode' : [False, validate_bool], - 'text.latex.preamble' : [[''], validate_latex_preamble], + 'text.latex.preamble' : [[''], validate_stringlist], 'text.dvipnghack' : [False, validate_bool], 'text.fontstyle' : ['normal', str], 'text.fontangle' : ['normal', str], @@ -369,7 +354,7 @@ 'mathtext.sf' : ['sans\-serif', validate_font_properties], 'mathtext.fontset' : ['cm', validate_fontset], 'mathtext.fallback_to_cm' : [True, validate_bool], - + 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number 'image.interpolation' : ['bilinear', str], 'image.cmap' : ['jet', str], # one of gray, jet, etc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-12-06 18:32:50
|
Revision: 4649 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4649&view=rev Author: dsdale Date: 2007-12-06 10:32:44 -0800 (Thu, 06 Dec 2007) Log Message: ----------- fixed a bug in savefig, saving to a nonexistent directory would result in a crash in some circumstances. Closes bug 1699614 Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-06 18:08:21 UTC (rev 4648) +++ trunk/matplotlib/CHANGELOG 2007-12-06 18:32:44 UTC (rev 4649) @@ -1,3 +1,7 @@ +2007-12-06 fixed a bug in savefig, saving to a nonexistent directory + would result in a crash in some circumstances. Closes bug + 1699614 - DSD + 2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD =============================================================== Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2007-12-06 18:08:21 UTC (rev 4648) +++ trunk/matplotlib/lib/matplotlib/figure.py 2007-12-06 18:32:44 UTC (rev 4649) @@ -1,6 +1,7 @@ """ Figure class -- add docstring here! """ +import os import sys import numpy as npy @@ -772,6 +773,9 @@ format - one of the file extensions supported by the active backend. """ + path = os.path.abspath(os.path.split(args[0])[0]) + if not os.access(path, os.W_OK): + raise IOError('%s is not a writeable directory'%path) for key in ('dpi', 'facecolor', 'edgecolor'): if not kwargs.has_key(key): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-12-06 18:38:57
|
Revision: 4650 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4650&view=rev Author: dsdale Date: 2007-12-06 10:38:55 -0800 (Thu, 06 Dec 2007) Log Message: ----------- undo that last change, mdboom had a different solution that I overlooked Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-06 18:32:44 UTC (rev 4649) +++ trunk/matplotlib/CHANGELOG 2007-12-06 18:38:55 UTC (rev 4650) @@ -1,7 +1,3 @@ -2007-12-06 fixed a bug in savefig, saving to a nonexistent directory - would result in a crash in some circumstances. Closes bug - 1699614 - DSD - 2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD =============================================================== Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2007-12-06 18:32:44 UTC (rev 4649) +++ trunk/matplotlib/lib/matplotlib/figure.py 2007-12-06 18:38:55 UTC (rev 4650) @@ -773,9 +773,6 @@ format - one of the file extensions supported by the active backend. """ - path = os.path.abspath(os.path.split(args[0])[0]) - if not os.access(path, os.W_OK): - raise IOError('%s is not a writeable directory'%path) for key in ('dpi', 'facecolor', 'edgecolor'): if not kwargs.has_key(key): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-06 18:47:52
|
Revision: 4651 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4651&view=rev Author: mdboom Date: 2007-12-06 10:47:50 -0800 (Thu, 06 Dec 2007) Log Message: ----------- Fix saving to a file-like object. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-12-06 18:38:55 UTC (rev 4650) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-12-06 18:47:50 UTC (rev 4651) @@ -214,7 +214,7 @@ return 1 def is_writable_file_like(obj): - return hasattr(filename, 'write') and callable(filename.write) + return hasattr(obj, 'write') and callable(obj.write) def is_scalar(obj): return is_string_like(obj) or not iterable(obj) @@ -891,7 +891,7 @@ return x, self._mem[i0:self._n:isub] def plot(self, i0=0, isub=1, fig=None): - if fig is None: + if fig is None: from pylab import figure, show fig = figure() Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2007-12-06 18:38:55 UTC (rev 4650) +++ trunk/matplotlib/src/_backend_agg.cpp 2007-12-06 18:47:50 UTC (rev 4651) @@ -2293,11 +2293,9 @@ throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() ); } else { - if ((fp = PyFile_AsFile(py_fileobj.ptr())) == NULL) { - PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); - if (!(write_method && PyCallable_Check(write_method))) - throw Py::TypeError("Object does not appear to be a path or a Python file-like object"); - } + PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); + if (!(write_method && PyCallable_Check(write_method))) + throw Py::TypeError("Object does not appear to be a path or a Python file-like object"); } png_bytep *row_pointers = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-12-06 19:18:50
|
Revision: 4654 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4654&view=rev Author: dsdale Date: 2007-12-06 11:18:49 -0800 (Thu, 06 Dec 2007) Log Message: ----------- updated references to mpl data directories for py2exe Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/config/cutils.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-06 19:10:12 UTC (rev 4653) +++ trunk/matplotlib/CHANGELOG 2007-12-06 19:18:49 UTC (rev 4654) @@ -1,3 +1,5 @@ +2007-12-06 updated references to mpl data directories for py2exe - DSD + 2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD =============================================================== Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-06 19:10:12 UTC (rev 4653) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-06 19:18:49 UTC (rev 4654) @@ -428,11 +428,16 @@ # py2exe zips pure python, so still need special check if getattr(sys,'frozen',None): - path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata') + path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data') if os.path.isdir(path): return path else: + # Try again assuming we need to step up one more directory + path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0], + 'mpl-data') + if os.path.isdir(path): return path + else: # Try again assuming sys.path[0] is a dir not a exe - path = os.path.join(sys.path[0], 'matplotlibdata') + path = os.path.join(sys.path[0], 'mpl-data') if os.path.isdir(path): return path raise RuntimeError('Could not find the matplotlib data files') @@ -442,7 +447,8 @@ defaultParams['datapath'][0] = _get_data_path() return defaultParams['datapath'][0] -get_data_path = verbose.wrap('matplotlib data path %s', _get_data_path_cached, always=False) +get_data_path = verbose.wrap('matplotlib data path %s', _get_data_path_cached, + always=False) def get_py2exe_datafiles(): datapath = get_data_path() @@ -454,8 +460,8 @@ if 'Matplotlib.nib' in files: files.remove('Matplotlib.nib') files = [os.path.join(root, filename) for filename in files] - root = root.replace(tail, 'matplotlibdata') - root = root[root.index('matplotlibdata'):] + root = root.replace(tail, 'mpl-data') + root = root[root.index('mpl-data'):] d[root] = files return d.items() Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/cutils.py 2007-12-06 19:10:12 UTC (rev 4653) +++ trunk/matplotlib/lib/matplotlib/config/cutils.py 2007-12-06 19:18:49 UTC (rev 4654) @@ -77,7 +77,7 @@ if os.path.exists(p): if not is_writable_dir(p): raise RuntimeError("""\ -'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. +'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored """%h) else: @@ -110,11 +110,16 @@ # py2exe zips pure python, so still need special check if getattr(sys,'frozen',None): - path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata') + path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data') if os.path.isdir(path): return path else: + # Try again assuming we need to step up one more directory + path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0], + 'mpl-data') + if os.path.isdir(path): return path + else: # Try again assuming sys.path[0] is a dir not a exe - path = os.path.join(sys.path[0], 'matplotlibdata') + path = os.path.join(sys.path[0], 'mpl-data') if os.path.isdir(path): return path raise RuntimeError('Could not find the matplotlib data files') @@ -136,8 +141,8 @@ if 'Matplotlib.nib' in files: files.remove('Matplotlib.nib') files = [os.path.join(root, filename) for filename in files] - root = root.replace(tail, 'matplotlibdata') - root = root[root.index('matplotlibdata'):] + root = root.replace(tail, 'mpl-data') + root = root[root.index('mpl-data'):] d[root] = files return d.items() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2007-12-06 22:28:31
|
Revision: 4658 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4658&view=rev Author: dsdale Date: 2007-12-06 14:28:27 -0800 (Thu, 06 Dec 2007) Log Message: ----------- let widgets.Cursor initialize to the lower x and y bounds rather than 0,0, which can cause havoc for dates and other transforms Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/widgets.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-06 21:51:12 UTC (rev 4657) +++ trunk/matplotlib/CHANGELOG 2007-12-06 22:28:27 UTC (rev 4658) @@ -1,3 +1,7 @@ +2007-12-06 let widgets.Cursor initialize to the lower x and y bounds + rather than 0,0, which can cause havoc for dates and other + transforms - DSD + 2007-12-06 updated references to mpl data directories for py2exe - DSD 2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD Modified: trunk/matplotlib/lib/matplotlib/widgets.py =================================================================== --- trunk/matplotlib/lib/matplotlib/widgets.py 2007-12-06 21:51:12 UTC (rev 4657) +++ trunk/matplotlib/lib/matplotlib/widgets.py 2007-12-06 22:28:27 UTC (rev 4658) @@ -662,8 +662,8 @@ self.vertOn = True self.useblit = useblit - self.lineh = ax.axhline(0, visible=False, **lineprops) - self.linev = ax.axvline(0, visible=False, **lineprops) + self.lineh = ax.axhline(ax.get_ybound()[0], visible=False, **lineprops) + self.linev = ax.axvline(ax.get_xbound()[0], visible=False, **lineprops) self.background = None self.needclear = False @@ -1070,11 +1070,11 @@ # If RectangleSelector is not active : if not self.active: return True - + # If canvas was locked if not self.canvas.widgetlock.available(self): return True - + # If no button was pressed yet ignore the event if it was out # of the axes if self.eventpress == None: @@ -1174,7 +1174,7 @@ def get_active(self): """ to get status of active mode (boolean variable)""" - return self.active + return self.active class Lasso(Widget): def __init__(self, ax, xy, callback=None, useblit=True): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 14:50:59
|
Revision: 4679 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4679&view=rev Author: mdboom Date: 2007-12-10 06:50:40 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Use an 8-spline approximation of an ellipse instead of a 4-spline one. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/patches.py Added Paths: ----------- trunk/matplotlib/unit/ellipse_large.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-12-09 00:48:27 UTC (rev 4678) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-12-10 14:50:40 UTC (rev 4679) @@ -1644,11 +1644,15 @@ } bind def""", """/unitcircle { newpath --1. 0. moveto --1.0 0.552284749831 -0.552284749831 1.0 0.0 1.0 curveto -0.552284749831 1.0 1.0 0.552284749831 1.0 0.0 curveto -1.0 -0.552284749831 0.552284749831 -1.0 0.0 -1.0 curveto --0.552284749831 -1.0 -1.0 -0.552284749831 -1.0 0.0 curveto +0. -1. moveto +0.2652031 -1.0 0.519579870785 -0.894633691588 0.707106781187 -0.707106781187 curveto +0.894633691588 -0.519579870785 1.0 -0.2652031 1.0 0.0 curveto +1.0 0.2652031 0.894633691588 0.519579870785 0.707106781187 0.707106781187 curveto +0.519579870785 0.894633691588 0.2652031 1.0 0.0 1.0 curveto +-0.2652031 1.0 -0.519579870785 0.894633691588 -0.707106781187 0.707106781187 curveto +-0.894633691588 0.519579870785 -1.0 0.2652031 -1.0 0.0 curveto +-1.0 -0.2652031 -0.894633691588 -0.519579870785 -0.707106781187 -0.707106781187 curveto +-0.519579870785 -0.894633691588 -0.2652031 -1.0 0.0 -1.0 curveto closepath } bind def""", Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2007-12-09 00:48:27 UTC (rev 4678) +++ trunk/matplotlib/lib/matplotlib/patches.py 2007-12-10 14:50:40 UTC (rev 4679) @@ -201,7 +201,7 @@ if cbook.is_string_like(self._edgecolor) and self._edgecolor.lower()=='none': gc.set_linewidth(0) - else: + else: gc.set_foreground(self._edgecolor) gc.set_linewidth(self._linewidth) @@ -764,32 +764,46 @@ """ A scale-free ellipse """ - offset = 4.0 * (npy.sqrt(2) - 1) / 3.0 + MAGIC = 0.2652031 + SQRT2 = npy.sqrt(0.5) + MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) - circle = npy.array([ - [-1.0, 0.0], + circle = npy.array( + [[0.0, -1.0], - [-1.0, offset], - [-offset, 1.0], - [0.0, 1.0], + [MAGIC, -1.0], + [SQRT2-MAGIC45, -SQRT2-MAGIC45], + [SQRT2, -SQRT2], - [offset, 1.0], - [1.0, offset], - [1.0, 0.0], + [SQRT2+MAGIC45, -SQRT2+MAGIC45], + [1.0, -MAGIC], + [1.0, 0.0], - [1.0, -offset], - [offset, -1.0], - [0.0, -1.0], + [1.0, MAGIC], + [SQRT2+MAGIC45, SQRT2-MAGIC45], + [SQRT2, SQRT2], - [-offset, -1.0], - [-1.0, -offset], - [-1.0, 0.0], + [SQRT2-MAGIC45, SQRT2+MAGIC45], + [MAGIC, 1.0], + [0.0, 1.0], - [-1.0, 0.0] - ], - npy.float_) + [-MAGIC, 1.0], + [-SQRT2+MAGIC45, SQRT2+MAGIC45], + [-SQRT2, SQRT2], - + [-SQRT2-MAGIC45, SQRT2-MAGIC45], + [-1.0, MAGIC], + [-1.0, 0.0], + + [-1.0, -MAGIC], + [-SQRT2-MAGIC45, -SQRT2+MAGIC45], + [-SQRT2, -SQRT2], + + [-SQRT2+MAGIC45, -SQRT2-MAGIC45], + [-MAGIC, -1.0], + [0.0, -1.0]], + npy.float_) + def __str__(self): return "Ellipse(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height) @@ -823,9 +837,9 @@ width, height = self.width, self.height xcenter = self.convert_xunits(xcenter) - width = self.convert_xunits(width) + width = self.convert_xunits(width) ycenter = self.convert_yunits(ycenter) - height = self.convert_xunits(height) + height = self.convert_xunits(height) @@ -871,8 +885,8 @@ mpl.verbose.report('patches.Ellipse renderer does not support path drawing; falling back on vertex approximation for nonlinear transformation') renderer.draw_polygon(gc, rgbFace, self.get_verts()) return - + x, y = self.center x = self.convert_xunits(x) y = self.convert_yunits(y) @@ -887,14 +901,14 @@ - + S = npy.array([ [w, 0, 0], [0, h, 0], [0, 0, 1]]) - + # rotate by theta R = npy.array([ [npy.cos(theta), -npy.sin(theta), 0], @@ -903,8 +917,8 @@ # transform unit circle into ellipse E = npy.dot(T, npy.dot(R, S)) - + # Apply the display affine sx, b, c, sy, tx, ty = self.get_transform().as_vec6_val() @@ -918,25 +932,19 @@ C = npy.ones((3, len(self.circle))) C[0:2,:] = self.circle.T - + ellipse = npy.dot(M, C).T[:,:2] path = agg.path_storage() path.move_to(*ellipse[0]) - verts = ellipse[1:4].flat - path.curve4(*verts) - verts = ellipse[4:7].flat - path.curve4(*verts) - verts = ellipse[7:10].flat - path.curve4(*verts) - verts = ellipse[10:13].flat - path.curve4(*verts) + for i in range(1, 25, 3): + path.curve4(*ellipse[i:i+3].flat) path.close_polygon() renderer.draw_path(gc, rgbFace, path) - + class Circle(Ellipse): """ A circle patch Added: trunk/matplotlib/unit/ellipse_large.py =================================================================== --- trunk/matplotlib/unit/ellipse_large.py (rev 0) +++ trunk/matplotlib/unit/ellipse_large.py 2007-12-10 14:50:40 UTC (rev 4679) @@ -0,0 +1,107 @@ + +# This example can be boiled down to a more simplistic example +# to show the problem, but bu including the upper and lower +# bound ellipses, it demonstrates how significant this error +# is to our plots. + +import math +from pylab import * +from matplotlib.patches import Ellipse + +# given a point x, y +x = 2692.440 +y = 6720.850 + +# get is the radius of a circle through this point +r = math.sqrt( x*x+y*y ) + +# show some comparative circles +delta = 6 + + +################################################## +def custom_ellipse( ax, x, y, major, minor, theta, numpoints = 750, **kwargs ): + xs = [] + ys = [] + incr = 2.0*math.pi / numpoints + incrTheta = 0.0 + while incrTheta <= (2.0*math.pi): + a = major * math.cos( incrTheta ) + b = minor * math.sin( incrTheta ) + l = math.sqrt( ( a**2 ) + ( b**2 ) ) + phi = math.atan2( b, a ) + incrTheta += incr + + xs.append( x + ( l * math.cos( theta + phi ) ) ) + ys.append( y + ( l * math.sin( theta + phi ) ) ) + # end while + + incrTheta = 2.0*math.pi + a = major * math.cos( incrTheta ) + b = minor * math.sin( incrTheta ) + l = sqrt( ( a**2 ) + ( b**2 ) ) + phi = math.atan2( b, a ) + xs.append( x + ( l * math.cos( theta + phi ) ) ) + ys.append( y + ( l * math.sin( theta + phi ) ) ) + + ellipseLine = ax.plot( xs, ys, **kwargs ) + + +################################################## +# make the axes +ax = subplot( 211, aspect='equal' ) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound ellipse +diam = (r - delta) * 2.0 +lower_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkgreen" ) +ax.add_patch( lower_ellipse ) + +# make the target ellipse +diam = r * 2.0 +target_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkred" ) +ax.add_patch( target_ellipse ) + +# make the upper-bound ellipse +diam = (r + delta) * 2.0 +upper_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkblue" ) +ax.add_patch( upper_ellipse ) + +# make the target +diam = delta * 2.0 +target = Ellipse( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" ) +ax.add_patch( target ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# now lets do the same thing again using a custom ellipse function + +# make the axes +ax = subplot( 212, aspect='equal', sharex=ax, sharey=ax ) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound ellipse +custom_ellipse( ax, 0.0, 0.0, r-delta, r-delta, 0.0, color="darkgreen" ) + +# make the target ellipse +custom_ellipse( ax, 0.0, 0.0, r, r, 0.0, color="darkred" ) + +# make the upper-bound ellipse +custom_ellipse( ax, 0.0, 0.0, r+delta, r+delta, 0.0, color="darkblue" ) + +# make the target +custom_ellipse( ax, x, y, delta, delta, 0.0, color="#BB1208" ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# lets zoom in to see the area of interest + +ax.set_xlim(2650, 2735) +ax.set_ylim(6705, 6735) +show() + +savefig("ellipse") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 16:15:33
|
Revision: 4686 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4686&view=rev Author: mdboom Date: 2007-12-10 08:15:30 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Support draw_path (importantly for ellipses) in Pdf, Svg and Cairo backends. Fix SVG text rendering bug. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/CHANGELOG 2007-12-10 16:15:30 UTC (rev 4686) @@ -1,3 +1,9 @@ +2007-12-10 Fix SVG text rendering bug. + +2007-12-10 Increase accuracy of circle and ellipse drawing by using an 8-piece + bezier approximation, rather than a 4-piece one. Fix PDF, SVG and + Cairo backends so they can draw paths (meaning ellipses as well). + 2007-12-07 Issue a warning when drawing an image on a non-linear axis. - MGD 2007-12-06 let widgets.Cursor initialize to the lower x and y bounds Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:15:30 UTC (rev 4686) @@ -34,6 +34,7 @@ backend_version = cairo.version del _version_required +from matplotlib import agg from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import enumerate, izip, is_string_like @@ -124,7 +125,35 @@ #_.ctx.restore() # revert to the default attributes + def draw_path(self, gc, rgbFace, path): + ctx = gc.ctx + ctx.new_path() + while 1: + code, xp, yp = path.vertex() + yp = self.height - yp + + if code == agg.path_cmd_stop: + ctx.close_path() + break + elif code == agg.path_cmd_move_to: + ctx.move_to(xp, yp) + elif code == agg.path_cmd_line_to: + ctx.line_to(xp, yp) + elif code == agg.path_cmd_curve3: + _, xp1, yp1 = path.vertex() + yp1 = self.height - yp1 + ctx.curve_to(xp, yp, xp, yp, xp1, yp1) + elif code == agg.path_cmd_curve4: + _, xp1, yp1 = path.vertex() + yp1 = self.height - yp1 + _, xp2, yp2 = path.vertex() + yp2 = self.height - yp2 + ctx.curve_to(xp, yp, xp1, yp1, xp2, yp2) + elif code == agg.path_cmd_end_poly: + ctx.close_path() + self._fill_and_stroke(ctx, rgbFace) + def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) @@ -307,11 +336,11 @@ ctx.translate(x, y) if angle: ctx.rotate (-angle * npy.pi / 180) - + for font, fontsize, s, ox, oy in glyphs: ctx.new_path() ctx.move_to(ox, oy) - + fontProp = ttfFontProperty(font) ctx.save() ctx.select_font_face (fontProp.name, @@ -332,7 +361,7 @@ ctx.restore() - + def flipy(self): if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) return True @@ -494,7 +523,7 @@ self.figure.draw (renderer) surface.write_to_png (fobj) - + def print_pdf(self, fobj, *args, **kwargs): return self._save(fobj, 'pdf', *args, **kwargs) @@ -506,10 +535,10 @@ def print_svgz(self, fobj, *args, **kwargs): return self._save(fobj, 'svgz', *args, **kwargs) - + def get_default_filetype(self): return rcParams['cairo.format'] - + def _save (self, fo, format, **kwargs): # save PDF/PS/SVG orientation = kwargs.get('orientation', 'portrait') Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:15:30 UTC (rev 4686) @@ -1249,6 +1249,36 @@ self.file.output(self.gc.close_and_paint()) + def draw_path(self, gc, rgbFace, path): + self.check_gc(gc, rgbFace) + + cmds = [] + + while 1: + code, xp, yp = path.vertex() + + if code == agg.path_cmd_stop: + cmds.append(Op.closepath) + break + elif code == agg.path_cmd_move_to: + cmds.extend([xp, yp, Op.moveto]) + elif code == agg.path_cmd_line_to: + cmds.extend([xp, yp, Op.lineto]) + elif code == agg.path_cmd_curve3: + cmds.extend([xp, yp]) + cmds.extend([xp, yp]) + cmds.extend(path.vertex()[1:]) + cmds.append(Op.curveto) + elif code == agg.path_cmd_curve4: + cmds.extend([xp, yp]) + cmds.extend(path.vertex()[1:]) + cmds.extend(path.vertex()[1:]) + cmds.append(Op.curveto) + elif code == agg.path_cmd_end_poly: + cmds.append(Op.closepath) + self.file.output(*cmds) + self.file.output(self.gc.paint()) + def get_image_magnification(self): return self.image_magnification Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:15:30 UTC (rev 4686) @@ -2,6 +2,7 @@ import os, codecs, base64, tempfile, urllib, gzip +from matplotlib import agg from matplotlib import verbose, __version__, rcParams from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase @@ -137,6 +138,38 @@ def close_group(self, s): self._svgwriter.write('</g>\n') + def draw_path(self, gc, rgbFace, path): + cmd = [] + + while 1: + code, xp, yp = path.vertex() + yp = self.height - yp + + if code == agg.path_cmd_stop: + cmd.append('z') # Hack, path_cmd_end_poly not found + break + elif code == agg.path_cmd_move_to: + cmd.append('M%g %g' % (xp, yp)) + elif code == agg.path_cmd_line_to: + cmd.append('L%g %g' % (xp, yp)) + elif code == agg.path_cmd_curve3: + verts = [xp, yp] + verts.extent(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + cmd.append('Q%g %g %g %g' % tuple(verts)) + elif code == agg.path_cmd_curve4: + verts = [xp, yp] + verts.extend(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + verts.extend(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + cmd.append('C%g %g %g %g %g %g'%tuple(verts)) + elif code == agg.path_cmd_end_poly: + cmd.append('z') + + path_data = "".join(cmd) + self._draw_svg_element("path", 'd="%s"' % path_data, gc, rgbFace) + def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): """ Ignores angles for now @@ -284,7 +317,7 @@ svg.append(' transform="translate(%s)"' % (currx * (self.FONT_SCALE / fontsize))) svg.append('/>\n') - currx += (glyph.linearHoriAdvance / 65536.0) + currx += (glyph.linearHoriAdvance / 65536.0) / (self.FONT_SCALE / fontsize) svg.append('</g>\n') svg = ''.join(svg) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-11 21:18:19
|
Revision: 4698 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4698&view=rev Author: jdh2358 Date: 2007-12-11 13:17:59 -0800 (Tue, 11 Dec 2007) Log Message: ----------- fixed text with dash bug Modified Paths: -------------- trunk/matplotlib/examples/dashpointlabel.py trunk/matplotlib/examples/lasso_demo.py trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/examples/dashpointlabel.py =================================================================== --- trunk/matplotlib/examples/dashpointlabel.py 2007-12-11 17:14:44 UTC (rev 4697) +++ trunk/matplotlib/examples/dashpointlabel.py 2007-12-11 21:17:59 UTC (rev 4698) @@ -1,4 +1,4 @@ -from matplotlib import pylab +import pylab DATA = ((1, 3), (2, 4), @@ -15,26 +15,27 @@ (1, 20, 30, 60, 10), ) -def test_dashpointlabel(save=False): - pylab.clf() - (x,y) = zip(*DATA) - pylab.plot(x, y, marker='o') - for i in xrange(len(DATA)): - (x,y) = DATA[i] - (dd, dl, r, dr, dp) = dash_style[i] - pylab.text(x, y, str((x,y)), withdash=True, - dashdirection=dd, - dashlength=dl, - rotation=r, - dashrotation=dr, - dashpush=dp, - ) - axis = pylab.gca() - axis.set_xlim((0.0, 5.0)) - axis.set_ylim((0.0, 5.0)) - if save: - pylab.savefig('dashpointlabel') - pylab.show() +fig = pylab.figure() +ax = fig.add_subplot(111) -if __name__ == '__main__': - test_dashpointlabel() + +(x,y) = zip(*DATA) +ax.plot(x, y, marker='o') +for i in xrange(len(DATA)): + (x,y) = DATA[i] + (dd, dl, r, dr, dp) = dash_style[i] + #print 'dashlen call', dl + t = ax.text(x, y, str((x,y)), withdash=True, + dashdirection=dd, + dashlength=dl, + rotation=r, + dashrotation=dr, + dashpush=dp, + ) + +ax.set_xlim((0.0, 5.0)) +ax.set_ylim((0.0, 5.0)) +#if save: +# pylab.savefig('dashpointlabel') +pylab.show() + Modified: trunk/matplotlib/examples/lasso_demo.py =================================================================== --- trunk/matplotlib/examples/lasso_demo.py 2007-12-11 17:14:44 UTC (rev 4697) +++ trunk/matplotlib/examples/lasso_demo.py 2007-12-11 21:17:59 UTC (rev 4698) @@ -59,6 +59,7 @@ self.canvas.draw_idle() self.canvas.widgetlock.release(self.lasso) del self.lasso + def onpress(self, event): if self.canvas.widgetlock.locked(): return if event.inaxes is None: return Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-12-11 17:14:44 UTC (rev 4697) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-12-11 21:17:59 UTC (rev 4698) @@ -962,6 +962,10 @@ outstream.write("Examining: %r\n" % (obj,)) recurse(obj, obj, { }, []) + + + + if __name__=='__main__': assert( allequal([1,1,1]) ) assert(not allequal([1,1,0]) ) Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2007-12-11 17:14:44 UTC (rev 4697) +++ trunk/matplotlib/lib/matplotlib/text.py 2007-12-11 21:17:59 UTC (rev 4698) @@ -387,6 +387,11 @@ "Return the horizontal alignment as string" return self._horizontalalignment + + def _get_xy_display(self): + 'get the (possibly unit converted) transformed x,y in display coords' + return self.get_transform().xy_tup((self._x, self._y)) + def get_position(self): "Return x, y as tuple" x = float(self.convert_xunits(self._x)) @@ -770,7 +775,26 @@ #self.set_bbox(dict(pad=0)) + def get_position(self): + "Return x, y as tuple" + x = float(self.convert_xunits(self._dashx)) + y = float(self.convert_yunits(self._dashy)) + return x, y + + def get_prop_tup(self): + """ + Return a hashable tuple of properties + + Not intended to be human readable, but useful for backends who + want to cache derived information about text (eg layouts) and + need to know if the text has changed + """ + props = [p for p in Text.get_prop_tup(self)] + props.extend([self._x, self._y, self._dashlength, self._dashdirection, self._dashrotation, self._dashpad, self._dashpush]) + return tuple(props) + def draw(self, renderer): + self.cached = dict() self.update_coords(renderer) Text.draw(self, renderer) if self.get_dashlength() > 0.0: @@ -846,8 +870,12 @@ cwd *= 1+dashpad/npy.sqrt(npy.dot(cwd,cwd)) cw = c2+(dashdirection*2-1)*cwd - self._x, self._y = transform.inverse_xy_tup(tuple(cw)) + + newx, newy = transform.inverse_xy_tup(tuple(cw)) + + self._x, self._y = newx, newy + # Now set the window extent # I'm not at all sure this is the right way to do this. we = Text.get_window_extent(self, renderer=renderer) @@ -930,9 +958,6 @@ """ self._dashpush = dp - def get_position(self): - "Return x, y as tuple" - return self._dashx, self._dashy def set_position(self, xy): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 14:08:40
|
Revision: 4706 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4706&view=rev Author: mdboom Date: 2007-12-12 06:08:15 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Support alpha-blended text in the Agg and Svg backends. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-12-12 14:04:57 UTC (rev 4705) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-12-12 14:08:15 UTC (rev 4706) @@ -286,7 +286,7 @@ color = rgb2hex(gc.get_rgb()) if rcParams['svg.embed_char_paths']: - svg = ['<g style="fill: %s" transform="' % color] + svg = ['<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())] if angle != 0: svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle)) elif x != 0 or y != 0: @@ -325,7 +325,8 @@ fontfamily = font.family_name fontstyle = prop.get_style() - style = 'font-size: %f; font-family: %s; font-style: %s; fill: %s;'%(fontsize, fontfamily,fontstyle, color) + style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %s' % + (fontsize, fontfamily,fontstyle, color, gc.get_alpha())) if angle!=0: transform = 'transform="translate(%s,%s) rotate(%1.1f) translate(%s,%s)"' % (x,y,-angle,-x,-y) # Inkscape doesn't support rotate(angle x y) Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2007-12-12 14:04:57 UTC (rev 4705) +++ trunk/matplotlib/src/_backend_agg.cpp 2007-12-12 14:08:15 UTC (rev 4706) @@ -2107,7 +2107,7 @@ do { *dst = _color; - dst->a = src->v; + dst->a = ((unsigned int)_color.a * (unsigned int)src->v) >> 8; ++src; ++dst; } while (--len); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-13 16:20:02
|
Revision: 4720 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4720&view=rev Author: jdh2358 Date: 2007-12-13 08:06:59 -0800 (Thu, 13 Dec 2007) Log Message: ----------- moved optional rec2* packages out of mlab and into toolkits Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CODING_GUIDE trunk/matplotlib/examples/figimage_demo.py trunk/matplotlib/lib/matplotlib/image.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/API_CHANGES 2007-12-13 16:06:59 UTC (rev 4720) @@ -1,3 +1,8 @@ + Moved rec2gtk to matplotlib.toolkits.gtktools + + Moved rec2excel to matplotlib.toolkits.exceltools + + Removed, dead/experimental ExampleInfo, Namespace and Importer code from matplotlib/__init__.py 0.91.1 Released Modified: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/CODING_GUIDE 2007-12-13 16:06:59 UTC (rev 4720) @@ -113,6 +113,16 @@ .emacs will cause emacs to strip trailing white space on save for python, C and C++ + +When importing modules from the matplotlib namespace + + import matplotlib.cbook as cbook # DO + from matplotlib import cbook #DONT + +because the latter is ambiguous whether cbook is a module or a +function to the new developer. The former makes it explcit that you +are importing a module or package. + ; and similarly for c++-mode-hook and c-mode-hook (add-hook 'python-mode-hook (lambda () Modified: trunk/matplotlib/examples/figimage_demo.py =================================================================== --- trunk/matplotlib/examples/figimage_demo.py 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/examples/figimage_demo.py 2007-12-13 16:06:59 UTC (rev 4720) @@ -13,7 +13,7 @@ im1 = figimage(Z, xo=50, yo=0) im2 = figimage(Z, xo=100, yo=100, alpha=.8) #gray() # overrides current and sets default -#savefig('figimage_demo') +savefig('figimage_demo') show() Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/lib/matplotlib/image.py 2007-12-13 16:06:59 UTC (rev 4720) @@ -23,6 +23,7 @@ from matplotlib._image import * class AxesImage(martist.Artist, cm.ScalarMappable): + zorder = 1 def __init__(self, ax, cmap = None, @@ -517,18 +518,21 @@ self.update_dict['array'] = True class FigureImage(martist.Artist, cm.ScalarMappable): + zorder = 1 def __init__(self, fig, cmap = None, norm = None, offsetx = 0, offsety = 0, origin=None, + **kwargs ): """ cmap is a colors.Colormap instance norm is a colors.Normalize instance to map luminance to 0-1 + kwargs are an optional list of Artist keyword args """ martist.Artist.__init__(self) cm.ScalarMappable.__init__(self, norm, cmap) @@ -537,6 +541,7 @@ self.figure = fig self.ox = offsetx self.oy = offsety + self.update(kwargs) def contains(self, mouseevent): """Test whether the mouse event occured within the image. Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-13 16:06:59 UTC (rev 4720) @@ -48,13 +48,13 @@ * rec2csv : store record array in CSV file * rec2excel : store record array in excel worksheet - required pyExcelerator - * rec2gtk : put record array in GTK treeview - requires gtk + * csv2rec : import record array from CSV file with type inspection * rec_append_field : add a field/array to record array * rec_drop_fields : drop fields from record array * rec_join : join two record arrays on sequence of fields -For the rec viewer clases (rec2csv, rec2excel and rec2gtk), there are +For the rec viewer clases (rec2csv, rec2excel), there are a bunch of Format objects you can pass into the functions that will do things like color negative values red, set percent formatting and scaling, etc. @@ -1978,7 +1978,7 @@ join record arrays r1 and r2 on key; key is a tuple of field names. if r1 and r2 have equal values on all the keys in the key tuple, then their fields will be merged into a new record array - containing the union of the fields of r1 and r2 + containing the intersection of the fields of r1 and r2 """ for name in key: @@ -2343,373 +2343,5 @@ writer.writerow([func(val) for func, val in zip(funcs, row)]) fh.close() -# if pyExcelerator is installed, provide an excel view -try: - import pyExcelerator as excel -except ImportError: - pass -else: - def xlformat_factory(format): - """ - copy the format, perform any overrides, and attach an xlstyle instance - copied format is returned - """ - format = copy.deepcopy(format) - - - xlstyle = excel.XFStyle() - if isinstance(format, FormatFloat): - zeros = ''.join(['0']*format.precision) - xlstyle.num_format_str = '#,##0.%s;[RED]-#,##0.%s'%(zeros, zeros) - elif isinstance(format, FormatInt): - xlstyle.num_format_str = '#,##;[RED]-#,##' - elif isinstance(format, FormatPercent): - zeros = ''.join(['0']*format.precision) - xlstyle.num_format_str = '0.%s%%;[RED]-0.%s%%'%(zeros, zeros) - format.scale = 1. - else: - xlstyle = None - - format.xlstyle = xlstyle - - return format - - def rec2excel(r, ws, formatd=None, rownum=0, colnum=0): - """ - save record array r to excel pyExcelerator worksheet ws - starting at rownum. if ws is string like, assume it is a - filename and save to it - - start writing at rownum, colnum - - formatd is a dictionary mapping dtype name -> FormatXL instances - - The next rownum after writing is returned - """ - - autosave = False - if cbook.is_string_like(ws): - filename = ws - wb = excel.Workbook() - ws = wb.add_sheet('worksheet') - autosave = True - - - if formatd is None: - formatd = dict() - - formats = [] - font = excel.Font() - font.bold = True - - stylehdr = excel.XFStyle() - stylehdr.font = font - - for i, name in enumerate(r.dtype.names): - dt = r.dtype[name] - format = formatd.get(name) - if format is None: - format = defaultformatd.get(dt.type, FormatObj()) - - format = xlformat_factory(format) - ws.write(rownum, colnum+i, name, stylehdr) - 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.toval(val) - if format.xlstyle is None: - ws.write(rownum, colnum+i, val) - else: - if safe_isnan(val): - ws.write(rownum, colnum+i, 'NaN') - else: - ws.write(rownum, colnum+i, val, format.xlstyle) - rownum += 1 - - if autosave: - wb.save(filename) - return rownum - - - - -# if gtk is installed, provide a gtk view -try: - import gtk, gobject -except ImportError: - pass -except RuntimeError: - pass -else: - - - def gtkformat_factory(format, colnum): - """ - copy the format, perform any overrides, and attach an gtk style attrs - - - xalign = 0. - cell = None - - """ - - format = copy.copy(format) - format.xalign = 0. - format.cell = None - - def negative_red_cell(column, cell, model, thisiter): - val = model.get_value(thisiter, colnum) - try: val = float(val) - except: cell.set_property('foreground', 'black') - else: - if val<0: - cell.set_property('foreground', 'red') - else: - cell.set_property('foreground', 'black') - - - if isinstance(format, FormatFloat) or isinstance(format, FormatInt): - format.cell = negative_red_cell - format.xalign = 1. - elif isinstance(format, FormatDate): - format.xalign = 1. - return format - - - - class SortedStringsScrolledWindow(gtk.ScrolledWindow): - """ - A simple treeview/liststore assuming all columns are strings. - Supports ascending/descending sort by clicking on column header - """ - - def __init__(self, colheaders, formatterd=None): - """ - xalignd if not None, is a dict mapping col header to xalignent (default 1) - - formatterd if not None, is a dict mapping col header to a ColumnFormatter - """ - - - gtk.ScrolledWindow.__init__(self) - self.colheaders = colheaders - self.seq = None # not initialized with accts - self.set_shadow_type(gtk.SHADOW_ETCHED_IN) - self.set_policy(gtk.POLICY_AUTOMATIC, - gtk.POLICY_AUTOMATIC) - - types = [gobject.TYPE_STRING] * len(colheaders) - model = self.model = gtk.ListStore(*types) - - - treeview = gtk.TreeView(self.model) - treeview.show() - treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) - treeview.set_rules_hint(True) - - - class Clicked: - def __init__(self, parent, i): - self.parent = parent - self.i = i - self.num = 0 - - def __call__(self, column): - ind = [] - dsu = [] - for rownum, thisiter in enumerate(self.parent.iters): - val = model.get_value(thisiter, self.i) - try: val = float(val.strip().rstrip('%')) - except ValueError: pass - if npy.isnan(val): val = npy.inf # force nan to sort uniquely - dsu.append((val, rownum)) - dsu.sort() - if not self.num%2: dsu.reverse() - - vals, otherind = zip(*dsu) - ind.extend(otherind) - - self.parent.model.reorder(ind) - newiters = [] - for i in ind: - newiters.append(self.parent.iters[i]) - self.parent.iters = newiters[:] - for i, thisiter in enumerate(self.parent.iters): - key = tuple([self.parent.model.get_value(thisiter, j) for j in range(len(colheaders))]) - self.parent.rownumd[i] = key - - self.num+=1 - - - if formatterd is None: - formatterd = dict() - - formatterd = formatterd.copy() - - for i, header in enumerate(colheaders): - renderer = gtk.CellRendererText() - if header not in formatterd: - formatterd[header] = ColumnFormatter() - formatter = formatterd[header] - - column = gtk.TreeViewColumn(header, renderer, text=i) - renderer.set_property('xalign', formatter.xalign) - column.connect('clicked', Clicked(self, i)) - column.set_property('clickable', True) - - if formatter.cell is not None: - column.set_cell_data_func(renderer, formatter.cell) - - treeview.append_column(column) - - - - self.formatterd = formatterd - self.lastcol = column - self.add(treeview) - self.treeview = treeview - self.clear() - - def clear(self): - self.iterd = dict() - self.iters = [] # an ordered list of iters - self.rownumd = dict() # a map from rownum -> symbol - self.model.clear() - self.datad = dict() - - - def flat(self, row): - seq = [] - for i,val in enumerate(row): - formatter = self.formatterd.get(self.colheaders[i]) - seq.extend([i,formatter.tostr(val)]) - return seq - - def __delete_selected(self, *unused): # untested - - - keyd = dict([(thisiter, key) for key, thisiter in self.iterd.values()]) - for row in self.get_selected(): - key = tuple(row) - thisiter = self.iterd[key] - self.model.remove(thisiter) - del self.datad[key] - del self.iterd[key] - self.iters.remove(thisiter) - - for i, thisiter in enumerate(self.iters): - self.rownumd[i] = keyd[thisiter] - - - - def delete_row(self, row): - key = tuple(row) - thisiter = self.iterd[key] - self.model.remove(thisiter) - - - del self.datad[key] - del self.iterd[key] - self.rownumd[len(self.iters)] = key - self.iters.remove(thisiter) - - for rownum, thiskey in self.rownumd.items(): - if thiskey==key: del self.rownumd[rownum] - - def add_row(self, row): - thisiter = self.model.append() - self.model.set(thisiter, *self.flat(row)) - key = tuple(row) - self.datad[key] = row - self.iterd[key] = thisiter - self.rownumd[len(self.iters)] = key - self.iters.append(thisiter) - - def update_row(self, rownum, newrow): - key = self.rownumd[rownum] - thisiter = self.iterd[key] - newkey = tuple(newrow) - - self.rownumd[rownum] = newkey - del self.datad[key] - del self.iterd[key] - self.datad[newkey] = newrow - self.iterd[newkey] = thisiter - - - self.model.set(thisiter, *self.flat(newrow)) - - def get_row(self, rownum): - key = self.rownumd[rownum] - return self.datad[key] - - def get_selected(self): - selected = [] - def foreach(model, path, iter, selected): - selected.append(model.get_value(iter, 0)) - - self.treeview.get_selection().selected_foreach(foreach, selected) - return selected - - - - def rec2gtk(r, formatd=None, rownum=0, autowin=True): - """ - save record array r to excel pyExcelerator worksheet ws - starting at rownum. if ws is string like, assume it is a - filename and save to it - - formatd is a dictionary mapping dtype name -> FormatXL instances - - This function creates a SortedStringsScrolledWindow (derived - from gtk.ScrolledWindow) and returns it. if autowin is True, - a gtk.Window is created, attached to the - SortedStringsScrolledWindow instance, shown and returned. If - autowin=False, the caller is responsible for adding the - SortedStringsScrolledWindow instance to a gtk widget and - showing it. - """ - - - - 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 = defaultformatd.get(dt.type, FormatObj()) - #print 'gtk fmt factory', i, name, format, type(format) - format = gtkformat_factory(format, i) - formatd[name] = format - - - colheaders = r.dtype.names - scroll = SortedStringsScrolledWindow(colheaders, formatd) - - ind = npy.arange(len(r.dtype.names)) - for row in r: - scroll.add_row(row) - - - if autowin: - win = gtk.Window() - win.set_default_size(800,600) - win.add(scroll) - win.show_all() - scroll.win = win - - return scroll - - Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/src/_backend_agg.cpp 2007-12-13 16:06:59 UTC (rev 4720) @@ -251,7 +251,7 @@ alphaMaskRenderingBuffer = new agg::rendering_buffer; alphaMaskRenderingBuffer->attach(alphaBuffer, width, height, stride); alphaMask = new alpha_mask_type(*alphaMaskRenderingBuffer); - //jdh + pixfmtAlphaMask = new agg::pixfmt_gray8(*alphaMaskRenderingBuffer); rendererBaseAlphaMask = new renderer_base_alpha_mask_type(*pixfmtAlphaMask); rendererAlphaMask = new renderer_alpha_mask_type(*rendererBaseAlphaMask); @@ -441,7 +441,6 @@ GCAgg gc = GCAgg(args[0], dpi); facepair_t face = _get_rgba_face(args[1], gc.alpha); - double l = Py::Float( args[2] ); double b = Py::Float( args[3] ); double w = Py::Float( args[4] ); @@ -2022,7 +2021,6 @@ delete [] fillCache; delete [] strokeCache; - //jdh _VERBOSE("RendererAgg::_draw_markers_cache done"); return Py::Object(); @@ -2200,6 +2198,7 @@ agg::span_allocator<agg::gray8> gray_span_allocator; image_span_gen_type image_span_generator(gray_span_allocator, srcbuf, 0, interpolator, filter); + span_gen_type output_span_generator(&image_span_generator, gc.color); renderer_type ri(*rendererBase, output_span_generator); //agg::rasterizer_scanline_aa<> rasterizer; Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2007-12-13 16:04:14 UTC (rev 4719) +++ trunk/matplotlib/src/_image.cpp 2007-12-13 16:06:59 UTC (rev 4720) @@ -297,7 +297,7 @@ Py::Object Image::get_matrix(const Py::Tuple& args) { - _VERBOSE("Image::get_size"); + _VERBOSE("Image::get_matrix"); args.verify_length(0); @@ -565,7 +565,7 @@ Py::Object Image::get_size_out(const Py::Tuple& args) { - _VERBOSE("Image::get_size"); + _VERBOSE("Image::get_size_out"); args.verify_length(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-13 18:30:50
|
Revision: 4728 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4728&view=rev Author: mdboom Date: 2007-12-13 10:30:45 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Update API_CHANGES and CHANGELOG for stuff since 0.91.1 Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-12-13 18:21:25 UTC (rev 4727) +++ trunk/matplotlib/API_CHANGES 2007-12-13 18:30:45 UTC (rev 4728) @@ -1,3 +1,6 @@ + A warning is issued when an image is drawn on log-scaled + axes, since it will not log-scale the image data. + Moved rec2gtk to matplotlib.toolkits.gtktools Moved rec2excel to matplotlib.toolkits.exceltools @@ -2,3 +5,2 @@ - Removed, dead/experimental ExampleInfo, Namespace and Importer @@ -11,7 +13,7 @@ Changed cbook.is_file_like to cbook.is_writable_file_like and corrected behavior. - + 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: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-13 18:21:25 UTC (rev 4727) +++ trunk/matplotlib/CHANGELOG 2007-12-13 18:30:45 UTC (rev 4728) @@ -1,9 +1,13 @@ -2007-12-10 Fix SVG text rendering bug. +2007-12-12 Support alpha-blended text in the Agg and Svg backends - + MGD -2007-12-10 Increase accuracy of circle and ellipse drawing by using an 8-piece - bezier approximation, rather than a 4-piece one. Fix PDF, SVG and - Cairo backends so they can draw paths (meaning ellipses as well). +2007-12-10 Fix SVG text rendering bug. - MGD +2007-12-10 Increase accuracy of circle and ellipse drawing by using an + 8-piece bezier approximation, rather than a 4-piece one. + Fix PDF, SVG and Cairo backends so they can draw paths + (meaning ellipses as well). - MGD + 2007-12-07 Issue a warning when drawing an image on a non-linear axis. - MGD 2007-12-06 let widgets.Cursor initialize to the lower x and y bounds @@ -18,6 +22,10 @@ (This was a regression since 0.90 caused by the refactoring of font_manager.py) - MGD +2007-12-05 Support arbitrary rotation of usetex text in Agg backend. - MGD + +2007-12-04 Support '|' as a character in mathtext - MGD + =============================================================== 2007-11-27 Released 0.91.1 at revision 4517 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2007-12-16 20:53:40
|
Revision: 4748 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4748&view=rev Author: astraw Date: 2007-12-16 12:53:35 -0800 (Sun, 16 Dec 2007) Log Message: ----------- rec2csv does not close filehandles passed in open Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-16 19:28:46 UTC (rev 4747) +++ trunk/matplotlib/CHANGELOG 2007-12-16 20:53:35 UTC (rev 4748) @@ -1,3 +1,6 @@ +2007-12-16 rec2csv saves doubles without losing precision. Also, it + does not close filehandles passed in open. - JDH,ADS + 2007-12-13 Moved rec2gtk to matplotlib.toolkits.gtktools and rec2excel to matplotlib.toolkits.exceltools - JDH Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2007-12-16 19:28:46 UTC (rev 4747) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2007-12-16 20:53:35 UTC (rev 4748) @@ -224,7 +224,7 @@ except TypeError: return False else: return True -def to_filehandle(fname, flag='r'): +def to_filehandle(fname, flag='r', return_opened=False): """ fname can be a filename or a file handle. Support for gzipped files is automatic, if the filename ends in .gz. flag is a @@ -236,10 +236,14 @@ fh = gzip.open(fname, flag) else: fh = file(fname, flag) + opened = True elif hasattr(fname, 'seek'): fh = fname + opened = False else: raise ValueError('fname must be a string or file handle') + if return_opened: + return fh, opened return fh def flatten(seq, scalarp=is_scalar): Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-16 19:28:46 UTC (rev 4747) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-16 20:53:35 UTC (rev 4748) @@ -2335,13 +2335,14 @@ for i, name in enumerate(r.dtype.names): funcs.append(csvformat_factory(formatd[name]).tostr) - fh = cbook.to_filehandle(fname, 'w') + fh, opened = cbook.to_filehandle(fname, 'w', return_opened=True) writer = csv.writer(fh, delimiter=delimiter) header = r.dtype.names writer.writerow(header) for row in r: writer.writerow([func(val) for func, val in zip(funcs, row)]) - fh.close() + if opened: + fh.close() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2007-12-16 23:20:01
|
Revision: 4749 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4749&view=rev Author: astraw Date: 2007-12-16 15:19:59 -0800 (Sun, 16 Dec 2007) Log Message: ----------- fix csv2rec roundtrip for funky strings, too Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/unit/mlab_unit.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-16 20:53:35 UTC (rev 4748) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-16 23:19:59 UTC (rev 4749) @@ -2236,11 +2236,15 @@ return repr(x) +class FormatString2(FormatObj): + def tostr(self, x): + val = repr(x) + return val[1:-1] + class FormatString(FormatObj): def tostr(self, x): return '"%r"'%self.toval(x) - class FormatFormatStr(FormatObj): def __init__(self, fmt): self.fmt = fmt @@ -2297,7 +2301,7 @@ npy.float32 : FormatFloat(), npy.float64 : FormatFloat(), npy.object_ : FormatObj(), - npy.string_ : FormatObj(), + npy.string_ : FormatString2(), } def get_formatd(r, formatd=None): Modified: trunk/matplotlib/unit/mlab_unit.py =================================================================== --- trunk/matplotlib/unit/mlab_unit.py 2007-12-16 20:53:35 UTC (rev 4748) +++ trunk/matplotlib/unit/mlab_unit.py 2007-12-16 23:19:59 UTC (rev 4749) @@ -13,25 +13,34 @@ self.failIf( fh.closed ) def test_csv2rec_roundtrip(self): - # Make sure double-precision floats pass through. + # Make sure double-precision floats and strings pass through a + # roundtrip unaltered. + # A bug in numpy (fixed in r4602) meant that numpy scalars # lost precision when passing through repr(). csv2rec was # affected by this. This test will only pass on numpy >= # 1.0.5. - ra=numpy.rec.array([(123, 1197346475.0137341), (456, 123.456)], - dtype=[('a', '<i8'), ('b', '<f8')]) - rec2csv_closes_files = True - if rec2csv_closes_files: - fh = 'mlab_unit_tmp.csv' - else: - fh = StringIO.StringIO() + ra=numpy.rec.array([(123, 1197346475.0137341, 'a,bc'), + (456, 123.456, 'd\'ef'), + (789, 0.000000001, 'ghi'), + ], + dtype=[('a', '<i8'), ('b', '<f8'), ('c', '|S3')]) + fh = StringIO.StringIO() mlab.rec2csv( ra, fh ) - if not rec2csv_closes_files: + fh.seek(0) + if 0: + print 'CSV contents:','-'*40 + print fh.read() + print '-'*40 fh.seek(0) ra2 = mlab.csv2rec(fh) + fh.close() for name in ra.dtype.names: - #print name, repr(ra[name]), repr(ra2[name]) + if 0: + print name, repr(ra[name]), repr(ra2[name]) + dt = ra.dtype[name] + print 'repr(dt.type)',repr(dt.type) self.failUnless( numpy.all(ra[name] == ra2[name]) ) # should not fail with numpy 1.0.5 if __name__=='__main__': This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-17 04:37:43
|
Revision: 4755 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4755&view=rev Author: jdh2358 Date: 2007-12-16 20:37:38 -0800 (Sun, 16 Dec 2007) Log Message: ----------- mods to support dates in csv2rec and friends Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/unit/mlab_unit.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-17 02:57:17 UTC (rev 4754) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-17 04:37:38 UTC (rev 4755) @@ -2129,6 +2129,7 @@ process_skiprows(reader) + dateparser = dateutil.parser.parse def myfloat(x): if x==missing: @@ -2136,9 +2137,18 @@ else: return float(x) + def mydate(x): + # try and return a date object + d = dateparser(x) + + if d.hour>0 or d.minute>0 or d.second>0: + raise ValueError('not a date') + return d.date() + + def get_func(item, func): # promote functions in this order - funcmap = {int:myfloat, myfloat:dateutil.parser.parse, dateutil.parser.parse:str} + funcmap = {int:myfloat, myfloat:mydate, mydate:dateparser, dateparser:str} try: func(item) except: if func==str: @@ -2233,17 +2243,17 @@ return self.toval(x) def toval(self, x): - return repr(x) + return str(x) -class FormatString2(FormatObj): +class FormatString(FormatObj): def tostr(self, x): val = repr(x) return val[1:-1] -class FormatString(FormatObj): - def tostr(self, x): - return '"%r"'%self.toval(x) +#class FormatString(FormatObj): +# def tostr(self, x): +# return '"%r"'%self.toval(x) class FormatFormatStr(FormatObj): def __init__(self, fmt): @@ -2301,7 +2311,7 @@ npy.float32 : FormatFloat(), npy.float64 : FormatFloat(), npy.object_ : FormatObj(), - npy.string_ : FormatString2(), + npy.string_ : FormatString(), } def get_formatd(r, formatd=None): Modified: trunk/matplotlib/unit/mlab_unit.py =================================================================== --- trunk/matplotlib/unit/mlab_unit.py 2007-12-17 02:57:17 UTC (rev 4754) +++ trunk/matplotlib/unit/mlab_unit.py 2007-12-17 04:37:38 UTC (rev 4755) @@ -1,7 +1,6 @@ -import unittest +import datetime, StringIO, unittest import matplotlib.mlab as mlab import numpy -import StringIO class TestMlab(unittest.TestCase): def test_csv2rec_closefile(self): @@ -21,11 +20,22 @@ # lost precision when passing through repr(). csv2rec was # affected by this. This test will only pass on numpy >= # 1.0.5. - ra=numpy.rec.array([(123, 1197346475.0137341, 'a,bc'), - (456, 123.456, 'd\'ef'), - (789, 0.000000001, 'ghi'), + delta = datetime.timedelta(days=1) + date0 = datetime.date(2007,12,16) + date1 = date0 + delta + date2 = date1 + delta + + delta = datetime.timedelta(days=1) + datetime0 = datetime.datetime(2007,12,16,22,29,34,924122) + datetime1 = datetime0 + delta + datetime2 = datetime1 + delta + ra=numpy.rec.fromrecords([ + (123, date0, datetime0, 1197346475.0137341, 'a,bc'), + (456, date1, datetime1, 123.456, 'd\'ef'), + (789, date2, datetime2, 0.000000001, 'ghi'), ], - dtype=[('a', '<i8'), ('b', '<f8'), ('c', '|S3')]) + names='intdata,datedata,datetimedata,floatdata,stringdata') + fh = StringIO.StringIO() mlab.rec2csv( ra, fh ) fh.seek(0) @@ -36,6 +46,8 @@ fh.seek(0) ra2 = mlab.csv2rec(fh) fh.close() + #print 'ra', ra + #print 'ra2', ra2 for name in ra.dtype.names: if 0: print name, repr(ra[name]), repr(ra2[name]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-21 18:56:52
|
Revision: 4785 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4785&view=rev Author: jdh2358 Date: 2007-12-21 08:22:42 -0800 (Fri, 21 Dec 2007) Log Message: ----------- added unit support to arc Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CODING_GUIDE trunk/matplotlib/examples/units/ellipse_with_units.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/unit/ellipse_large.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-12-21 15:13:14 UTC (rev 4784) +++ trunk/matplotlib/API_CHANGES 2007-12-21 16:22:42 UTC (rev 4785) @@ -1,3 +1,6 @@ + For csv2rec, checkrows=0 is the new default indicating all rows + will be checked for type inference + A warning is issued when an image is drawn on log-scaled axes, since it will not log-scale the image data. Modified: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2007-12-21 15:13:14 UTC (rev 4784) +++ trunk/matplotlib/CODING_GUIDE 2007-12-21 16:22:42 UTC (rev 4785) @@ -12,6 +12,9 @@ # checking out the main src svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib --username=youruser --password=yourpass +# branch checkouts, eg the transforms branch +svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/transforms transbranch + == Committing changes == When committing changes to matplotlib, there are a few things to bear @@ -27,12 +30,6 @@ support 2.3, so avoid 2.4 only features like decorators until we remove 2.3 support - * Are your changes Numeric, numarray and numpy compatible? Try - running simple_plot.py or image_demo.py with --Numeric, --numarray - and --numpy (Note, someone should add examples to - backend_driver.py which explicitly require numpy, numarray and - Numeric so we can automatically catch these) - * Can you pass examples/backend_driver.py? This is our poor man's unit test. @@ -49,9 +46,8 @@ For numpy, use: import numpy as npy - ... a = npy.array([1,2,3]) - ... + For masked arrays, use: import matplotlib.numerix.npyma as ma @@ -64,16 +60,20 @@ For matplotlib main module, use: import matplotlib as mpl - ... mpl.rcParams['xtick.major.pad'] = 6 -For matplotlib modules, use: +For matplotlib modules (or any other modules), use: - import matplotlib.cbook as cbook as mpl_cbook - ... - if mpl_cbook.iterable(z): - ... + import matplotlib.cbook as cbook + + if cbook.iterable(z): + pass + We prefer this over the equivalent 'from matplotlib import cbook' + because the latter is ambiguous whether cbook is a module or a + function to the new developer. The former makes it explcit that + you are importing a module or package. + == Naming, spacing, and formatting conventions == In general, we want to hew as closely as possible to the standard @@ -114,15 +114,6 @@ python, C and C++ -When importing modules from the matplotlib namespace - - import matplotlib.cbook as cbook # DO - from matplotlib import cbook #DONT - -because the latter is ambiguous whether cbook is a module or a -function to the new developer. The former makes it explcit that you -are importing a module or package. - ; and similarly for c++-mode-hook and c-mode-hook (add-hook 'python-mode-hook (lambda () Modified: trunk/matplotlib/examples/units/ellipse_with_units.py =================================================================== --- trunk/matplotlib/examples/units/ellipse_with_units.py 2007-12-21 15:13:14 UTC (rev 4784) +++ trunk/matplotlib/examples/units/ellipse_with_units.py 2007-12-21 16:22:42 UTC (rev 4785) @@ -1,5 +1,5 @@ """ -Compare the ellipse generated with arcs versus a polygonal approximation +Compare the ellipse generated with arcs versus a polygonal approximation """ from basic_units import cm import numpy as npy @@ -46,4 +46,24 @@ #fig.savefig('ellipse_compare.png') fig.savefig('ellipse_compare') +fig = figure() +ax = fig.add_subplot(211, aspect='auto') +ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1) + +e1 = patches.Arc((xcenter, ycenter), width, height, + angle=angle, linewidth=2, fill=False, zorder=2) + +ax.add_patch(e1) + +ax = fig.add_subplot(212, aspect='equal') +ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1) +e2 = patches.Arc((xcenter, ycenter), width, height, + angle=angle, linewidth=2, fill=False, zorder=2) + + +ax.add_patch(e2) + +#fig.savefig('arc_compare.png') +fig.savefig('arc_compare') + show() Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-21 15:13:14 UTC (rev 4784) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-12-21 16:22:42 UTC (rev 4785) @@ -2045,7 +2045,7 @@ return newrec.view(npy.recarray) -def csv2rec(fname, comments='#', skiprows=0, checkrows=5, delimiter=',', +def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',', converterd=None, names=None, missing=None): """ Load data from comma/space/tab delimited file in fname into a @@ -2075,7 +2075,7 @@ names, if not None, is a list of header names. In this case, no header will be read from the file - if no rows are found, None is returned See examples/loadrec.py + if no rows are found, None is returned -- see examples/loadrec.py """ if converterd is None: Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2007-12-21 15:13:14 UTC (rev 4784) +++ trunk/matplotlib/lib/matplotlib/patches.py 2007-12-21 16:22:42 UTC (rev 4785) @@ -977,10 +977,16 @@ """ An elliptical arc. Because it performs various optimizations, it can not be filled. + + The arc must be used in an Axes instance it cannot be added + directly to a Figure) because it is optimized to only render the + segments that are inside the axes bounding box with high + resolution. """ def __str__(self): - return "Arc(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height) + return "Arc(%s,%s;%sx%s)"%(self.center[0],self.center[1],self.width,self.height) + def __init__(self, xy, width, height, angle=0.0, theta1=0.0, theta2=360.0, **kwargs): """ xy - center of ellipse @@ -1053,6 +1059,10 @@ """ # Do the usual GC handling stuff if not self.get_visible(): return + + if not hasattr(self, 'axes'): + raise RuntimeError('Arcs can only be used in Axes instances') + gc = renderer.new_gc() gc.set_foreground(self._edgecolor) gc.set_linewidth(self._linewidth) @@ -1212,10 +1222,17 @@ # Set up the master transform from unit circle, all the way to # display space. + + centerx, centery = self.center + centerx = self.convert_xunits(centerx) + centery = self.convert_yunits(centery) + width = self.convert_xunits(self.width) + height = self.convert_yunits(self.height) + trans = self.get_transform() scale = npy.array( - [[self.width * 0.5, 0.0, 0.0], - [0.0, self.height * 0.5, 0.0], + [[width * 0.5, 0.0, 0.0], + [0.0, height * 0.5, 0.0], [0.0, 0.0, 1.0]], npy.float_) theta = (self.angle / 180.0) * npy.pi rotate = npy.array( @@ -1223,8 +1240,8 @@ [npy.sin(theta), npy.cos(theta), 0.0], [0.0, 0.0, 1.0]], npy.float_) translate = npy.array( - [[1.0, 0.0, self.center[0]], - [0.0, 1.0, self.center[1]], + [[1.0, 0.0, centerx], + [0.0, 1.0, centery], [0.0, 0.0, 1.0]], npy.float_) sx, b, c, sy, tx, ty = trans.as_vec6_val() dataTrans = npy.array( @@ -1240,7 +1257,7 @@ # that as a threshold to use the fast (whole ellipse) # technique or accurate (partial arcs) technique. size = affine_transform( - npy.array([[self.width, self.height]], npy.float_), + npy.array([[width, height]], npy.float_), mainTrans) width = size[0,0] height = size[0,1] Modified: trunk/matplotlib/unit/ellipse_large.py =================================================================== --- trunk/matplotlib/unit/ellipse_large.py 2007-12-21 15:13:14 UTC (rev 4784) +++ trunk/matplotlib/unit/ellipse_large.py 2007-12-21 16:22:42 UTC (rev 4785) @@ -6,7 +6,7 @@ import math from pylab import * -from matplotlib.patches import Ellipse +from matplotlib.patches import Ellipse, Arc # given a point x, y x = 2692.440 @@ -47,39 +47,75 @@ ellipseLine = ax.plot( xs, ys, **kwargs ) + + ################################################## # make the axes -ax = subplot( 211, aspect='equal' ) -ax.set_aspect( 'equal', 'datalim' ) +ax1 = subplot( 311, aspect='equal' ) +ax1.set_aspect( 'equal', 'datalim' ) # make the lower-bound ellipse diam = (r - delta) * 2.0 lower_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkgreen" ) -ax.add_patch( lower_ellipse ) +ax1.add_patch( lower_ellipse ) # make the target ellipse diam = r * 2.0 target_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkred" ) -ax.add_patch( target_ellipse ) +ax1.add_patch( target_ellipse ) # make the upper-bound ellipse diam = (r + delta) * 2.0 upper_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkblue" ) -ax.add_patch( upper_ellipse ) +ax1.add_patch( upper_ellipse ) # make the target diam = delta * 2.0 target = Ellipse( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" ) +ax1.add_patch( target ) + +# give it a big marker +ax1.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# make the axes +ax = subplot( 312, aspect='equal' , sharex=ax1, sharey=ax1) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound arc +diam = (r - delta) * 2.0 +lower_arc = Arc( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkgreen" ) +ax.add_patch( lower_arc ) + +# make the target arc +diam = r * 2.0 +target_arc = Arc( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkred" ) +ax.add_patch( target_arc ) + +# make the upper-bound arc +diam = (r + delta) * 2.0 +upper_arc = Arc( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkblue" ) +ax.add_patch( upper_arc ) + +# make the target +diam = delta * 2.0 +target = Arc( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" ) ax.add_patch( target ) # give it a big marker ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + + + + ################################################## # now lets do the same thing again using a custom ellipse function + + # make the axes -ax = subplot( 212, aspect='equal', sharex=ax, sharey=ax ) +ax = subplot( 313, aspect='equal', sharex=ax1, sharey=ax1 ) ax.set_aspect( 'equal', 'datalim' ) # make the lower-bound ellipse @@ -97,11 +133,17 @@ # give it a big marker ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + ################################################## # lets zoom in to see the area of interest -ax.set_xlim(2650, 2735) -ax.set_ylim(6705, 6735) +ax1.set_xlim(2650, 2735) +ax1.set_ylim(6705, 6735) + +savefig("ellipse") show() -savefig("ellipse") + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-12-26 07:23:32
|
Revision: 4788 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4788&view=rev Author: efiring Date: 2007-12-25 23:23:27 -0800 (Tue, 25 Dec 2007) Log Message: ----------- Make numerix.ma and numerix.npyma work with numpy 1.05 The numpy maskedarray branch is scheduled to become the trunk for 1.05. It includes a change from ma.py being in numpy/core to ma being a module under numpy, so the import syntax is different in numerix.ma and numerix.npyma. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/numerix/ma/__init__.py trunk/matplotlib/lib/matplotlib/numerix/npyma/__init__.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-21 19:40:59 UTC (rev 4787) +++ trunk/matplotlib/CHANGELOG 2007-12-26 07:23:27 UTC (rev 4788) @@ -1,3 +1,7 @@ +2007-12-25 Changed masked array importing to work with the upcoming + numpy 1.05 (now the maskedarray branch) as well as with + earlier versions. - EF + 2007-12-16 rec2csv saves doubles without losing precision. Also, it does not close filehandles passed in open. - JDH,ADS Modified: trunk/matplotlib/lib/matplotlib/numerix/ma/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/numerix/ma/__init__.py 2007-12-21 19:40:59 UTC (rev 4787) +++ trunk/matplotlib/lib/matplotlib/numerix/ma/__init__.py 2007-12-26 07:23:27 UTC (rev 4788) @@ -13,7 +13,10 @@ from maskedarray import * print "using maskedarray" else: - from numpy.core.ma import * + try: + from numpy.ma import * # numpy 1.05 and later + except ImportError: + from numpy.core.ma import * # earlier #print "using ma" def getmaskorNone(obj): _msk = getmask(obj) Modified: trunk/matplotlib/lib/matplotlib/numerix/npyma/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/numerix/npyma/__init__.py 2007-12-21 19:40:59 UTC (rev 4787) +++ trunk/matplotlib/lib/matplotlib/numerix/npyma/__init__.py 2007-12-26 07:23:27 UTC (rev 4788) @@ -4,5 +4,8 @@ from maskedarray import * print "using maskedarray" else: - from numpy.core.ma import * + try: + from numpy.ma import * # numpy 1.05 and later + except ImportError: + from numpy.core.ma import * # earlier #print "using ma" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-12-26 07:51:22
|
Revision: 4789 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4789&view=rev Author: efiring Date: 2007-12-25 23:51:19 -0800 (Tue, 25 Dec 2007) Log Message: ----------- Fix bug in errorbar, reported by Noriko Minakawa Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-26 07:23:27 UTC (rev 4788) +++ trunk/matplotlib/CHANGELOG 2007-12-26 07:51:19 UTC (rev 4789) @@ -1,3 +1,5 @@ +2007-12-25 Fix bug in errorbar, identified by Noriko Minakawa - EF + 2007-12-25 Changed masked array importing to work with the upcoming numpy 1.05 (now the maskedarray branch) as well as with earlier versions. - EF Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007-12-26 07:23:27 UTC (rev 4788) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007-12-26 07:51:19 UTC (rev 4789) @@ -3684,6 +3684,8 @@ lines_kw['linewidth']=kwargs['linewidth'] if 'lw' in kwargs: lines_kw['lw']=kwargs['lw'] + if 'transform' in kwargs: + lines_kw['transform'] = kwargs['transform'] # arrays fine here, they are booleans and hence not units if not iterable(lolims): @@ -3719,6 +3721,8 @@ plot_kw['markeredgewidth']=kwargs['markeredgewidth'] if 'mew' in kwargs: plot_kw['mew']=kwargs['mew'] + if 'transform' in kwargs: + plot_kw['transform'] = kwargs['transform'] if xerr is not None: if iterable(xerr) and len(xerr)==2 and iterable(xerr[0]) and iterable(xerr[1]): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-12-26 17:10:48
|
Revision: 4790 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4790&view=rev Author: efiring Date: 2007-12-26 09:10:34 -0800 (Wed, 26 Dec 2007) Log Message: ----------- Warning instead of exception if matplotlib.use() is called too late. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/__init__.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-26 07:51:19 UTC (rev 4789) +++ trunk/matplotlib/CHANGELOG 2007-12-26 17:10:34 UTC (rev 4790) @@ -1,3 +1,6 @@ +2007-12-26 Reduce too-late use of matplotlib.use() to a warning + instead of an exception, for backwards compatibility - EF + 2007-12-25 Fix bug in errorbar, identified by Noriko Minakawa - EF 2007-12-25 Changed masked array importing to work with the upcoming Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-26 07:51:19 UTC (rev 4789) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-12-26 17:10:34 UTC (rev 4790) @@ -727,8 +727,11 @@ except: from config import rcParams, rcdefaults -_use_error_msg = """ matplotlib.use() must be called *before* pylab -or matplotlib.backends is imported for the first time.""" +_use_error_msg = """ This call to matplotlib.use() has no effect +because the the backend has already been chosen; +matplotlib.use() must be called *before* pylab, matplotlib.pyplot, +or matplotlib.backends is imported for the first time. +""" def use(arg): """ @@ -747,7 +750,7 @@ be called before importing matplotlib.backends. """ if 'matplotlib.backends' in sys.modules: - raise RuntimeError(_use_error_msg) + warnings.warn(_use_error_msg) be_parts = arg.split('.') name = validate_backend(be_parts[0]) rcParams['backend'] = name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2008-01-06 18:28:34
|
Revision: 4802 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4802&view=rev Author: cmoad Date: 2008-01-06 10:28:17 -0800 (Sun, 06 Jan 2008) Log Message: ----------- minor rev bump Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/setupext.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-01-04 14:59:50 UTC (rev 4801) +++ trunk/matplotlib/API_CHANGES 2008-01-06 18:28:17 UTC (rev 4802) @@ -1,3 +1,5 @@ +0.91.2 Released + For csv2rec, checkrows=0 is the new default indicating all rows will be checked for type inference @@ -10,6 +12,7 @@ Removed, dead/experimental ExampleInfo, Namespace and Importer code from matplotlib/__init__.py + 0.91.1 Released 0.91.0 Released Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-01-04 14:59:50 UTC (rev 4801) +++ trunk/matplotlib/CHANGELOG 2008-01-06 18:28:17 UTC (rev 4802) @@ -1,3 +1,6 @@ +=============================================================== +2008-01-06 Released 0.91.2 at revision 4802 + 2007-12-26 Reduce too-late use of matplotlib.use() to a warning instead of an exception, for backwards compatibility - EF Modified: trunk/matplotlib/setupext.py =================================================================== --- trunk/matplotlib/setupext.py 2008-01-04 14:59:50 UTC (rev 4801) +++ trunk/matplotlib/setupext.py 2008-01-06 18:28:17 UTC (rev 4802) @@ -902,9 +902,9 @@ # First test for a MacOSX/darwin framework install from os.path import join, exists framework_dirs = [ + join(os.getenv('HOME'), '/Library/Frameworks'), + '/Library/Frameworks', '/System/Library/Frameworks/', - '/Library/Frameworks', - join(os.getenv('HOME'), '/Library/Frameworks') ] # Find the directory that contains the Tcl.framework and Tk.framework This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |