You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(4) |
2
(9) |
3
(23) |
4
(34) |
5
(31) |
6
(25) |
7
(10) |
8
(7) |
9
(1) |
10
(18) |
11
(3) |
12
(18) |
13
(13) |
14
(6) |
15
(9) |
16
(6) |
17
(10) |
18
(12) |
19
(1) |
20
(8) |
21
(5) |
22
|
23
|
24
|
25
|
26
(4) |
27
(2) |
28
(4) |
29
|
30
|
31
|
|
|
|
|
|
From: <md...@us...> - 2007-12-13 18:13:01
|
Revision: 4723 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4723&view=rev Author: mdboom Date: 2007-12-13 10:12:51 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Use numpy for math. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-12-13 18:12:11 UTC (rev 4722) +++ branches/transforms/lib/matplotlib/path.py 2007-12-13 18:12:51 UTC (rev 4723) @@ -423,25 +423,25 @@ # http://www.spaceroots.org/documents/ellipse/index.html # degrees to radians - theta1 *= math.pi / 180.0 - theta2 *= math.pi / 180.0 + theta1 *= npy.pi / 180.0 + theta2 *= npy.pi / 180.0 - twopi = math.pi * 2.0 - halfpi = math.pi * 0.5 + twopi = npy.pi * 2.0 + halfpi = npy.pi * 0.5 - eta1 = math.atan2(math.sin(theta1), math.cos(theta1)) - eta2 = math.atan2(math.sin(theta2), math.cos(theta2)) - eta2 -= twopi * math.floor((eta2 - eta1) / twopi) - if (theta2 - theta1 > math.pi) and (eta2 - eta1 < math.pi): + eta1 = npy.arctan2(npy.sin(theta1), npy.cos(theta1)) + eta2 = npy.arctan2(npy.sin(theta2), npy.cos(theta2)) + eta2 -= twopi * npy.floor((eta2 - eta1) / twopi) + if (theta2 - theta1 > npy.pi) and (eta2 - eta1 < npy.pi): eta2 += twopi # number of curve segments to make if n is None: - n = int(2 ** math.ceil((eta2 - eta1) / halfpi)) + n = int(2 ** npy.ceil((eta2 - eta1) / halfpi)) deta = (eta2 - eta1) / n - t = math.tan(0.5 * deta) - alpha = math.sin(deta) * (math.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0 + t = npy.tan(0.5 * deta) + alpha = npy.sin(deta) * (npy.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0 steps = npy.linspace(eta1, eta2, n + 1, True) cos_eta = npy.cos(steps) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-13 16:46:18
|
Revision: 4721 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4721&view=rev Author: jswhit Date: 2007-12-13 08:46:14 -0800 (Thu, 13 Dec 2007) Log Message: ----------- make figure smaller so it fits onscreen Modified Paths: -------------- trunk/toolkits/basemap/examples/ccsm_popgrid.py Modified: trunk/toolkits/basemap/examples/ccsm_popgrid.py =================================================================== --- trunk/toolkits/basemap/examples/ccsm_popgrid.py 2007-12-13 16:06:59 UTC (rev 4720) +++ trunk/toolkits/basemap/examples/ccsm_popgrid.py 2007-12-13 16:46:14 UTC (rev 4721) @@ -45,7 +45,7 @@ temp = MA.concatenate((temp,temp),1) tlon = tlon-360. -pl.figure(figsize=(8.5,11)) +pl.figure(figsize=(6,8)) pl.subplot(2,1,1) # subplot 1 just shows POP grid cells. map = Basemap(projection='merc', lat_ts=20, llcrnrlon=-180, \ 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: <js...@us...> - 2007-12-13 16:04:19
|
Revision: 4719 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4719&view=rev Author: jswhit Date: 2007-12-13 08:04:14 -0800 (Thu, 13 Dec 2007) Log Message: ----------- fix 'your matplotlib is too old' error message Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-13 13:40:40 UTC (rev 4718) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-13 16:04:14 UTC (rev 4719) @@ -16,13 +16,17 @@ date2num: convert from a datetime object to a numeric time value. """ -from matplotlib import rcParams, is_interactive, _pylab_helpers from matplotlib import __version__ as _matplotlib_version +from matplotlib.cbook import is_scalar, dedent # check to make sure matplotlib is not too old. _mpl_required_version = '0.90' if _matplotlib_version < _mpl_required_version: - raise ImportError('your matplotlib is too old - basemap ' - 'requires version %s or higher'% _matplotlib_version) + msg = dedent(""" + your matplotlib is too old - basemap requires version %s or + higher, you have version %s""" % + (_mpl_required_version,_matplotlib_version)) + raise ImportError(msg) +from matplotlib import rcParams, is_interactive, _pylab_helpers from matplotlib.collections import LineCollection from matplotlib.patches import Ellipse, Circle, Polygon from matplotlib.lines import Line2D @@ -30,7 +34,6 @@ from proj import Proj import numpy as npy from numpy import linspace, squeeze, ma -from matplotlib.cbook import is_scalar, dedent from shapelib import ShapeFile import _geos, pupynere, netcdftime This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-13 13:40:53
|
Revision: 4718 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4718&view=rev Author: mdboom Date: 2007-12-13 05:40:40 -0800 (Thu, 13 Dec 2007) Log Message: ----------- Updated to numpy names. Modified Paths: -------------- trunk/matplotlib/examples/logo.py trunk/matplotlib/examples/mri_demo.py Modified: trunk/matplotlib/examples/logo.py =================================================================== --- trunk/matplotlib/examples/logo.py 2007-12-12 20:13:52 UTC (rev 4717) +++ trunk/matplotlib/examples/logo.py 2007-12-13 13:40:40 UTC (rev 4718) @@ -5,7 +5,7 @@ # convert data to mV x = 1000*0.1*fromstring( - file('data/membrane.dat', 'rb').read(), Float32) + file('data/membrane.dat', 'rb').read(), float32) # 0.0005 is the sample interval t = 0.0005*arange(len(x)) figure(1, figsize=(7,1), dpi=100) Modified: trunk/matplotlib/examples/mri_demo.py =================================================================== --- trunk/matplotlib/examples/mri_demo.py 2007-12-12 20:13:52 UTC (rev 4717) +++ trunk/matplotlib/examples/mri_demo.py 2007-12-13 13:40:40 UTC (rev 4718) @@ -3,7 +3,7 @@ # data are 256x256 16 bit integers dfile = 'data/s1045.ima' -im = fromstring(file(dfile, 'rb').read(), UInt16).astype(Float) +im = fromstring(file(dfile, 'rb').read(), uint16).astype(float) im.shape = 256, 256 #imshow(im, ColormapJet(256)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 20:14:34
|
Revision: 4717 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4717&view=rev Author: mdboom Date: 2007-12-12 12:13:52 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Somehow this fix didn't get merged from trunk... (Saving gzipped Svg files) Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_svg.py Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 20:06:30 UTC (rev 4716) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 20:13:52 UTC (rev 4717) @@ -517,9 +517,15 @@ return self._print_svg(filename, svgwriter, fh_to_close) def print_svgz(self, filename, *args, **kwargs): - gzipwriter = gzip.GzipFile(filename, 'w') - svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') - return self._print_svg(filename, svgwriter) + if is_string_like(filename): + gzipwriter = gzip.GzipFile(filename, 'w') + fh_to_close = svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') + elif is_writable_file_like(filename): + fh_to_close = gzipwriter = gzip.GzipFile(fileobj=filename, mode='w') + svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') + else: + raise ValueError("filename must be a path or a file-like object") + return self._print_svg(filename, svgwriter, fh_to_close) def _print_svg(self, filename, svgwriter, fh_to_close=None): self.figure.set_dpi(72.0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 20:06:44
|
Revision: 4716 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4716&view=rev Author: mdboom Date: 2007-12-12 12:06:30 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Save images to Svg files without writing the image data out as a temporary file. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_svg.py branches/transforms/src/_image.cpp Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 19:15:46 UTC (rev 4715) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 20:06:30 UTC (rev 4716) @@ -245,30 +245,33 @@ h,w = im.get_size_out() + self._svgwriter.write ( + '<image x="%s" y="%s" width="%s" height="%s" ' + '%s xlink:href="'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, transstr) + ) + if rcParams['svg.image_inline']: - filename = os.path.join (tempfile.gettempdir(), - tempfile.gettempprefix() + '.png' - ) + class Base64Writer(object): + def __init__(self, write_method): + self._write_method = write_method + self._buffer = '' + def write(self, data): + self._buffer += data + while len(self._buffer) >= 64: + self._write_method(base64.encodestring(buffer[:64])) + self._write_method('\n') + self._buffer = self._buffer[64:] + def flush(self): + self._write_method(base64.encodestring(self._buffer)) + self._write_method('\n') - verbose.report ('Writing temporary image file for inlining: %s' % filename) - # im.write_png() accepts a filename, not file object, would be - # good to avoid using files and write to mem with StringIO + self._svgwriter.write("data:image/png;base64,\n") + base64writer = Base64Writer(self._svgwriter.write) - # JDH: it *would* be good, but I don't know how to do this - # since libpng seems to want a FILE* and StringIO doesn't seem - # to provide one. I suspect there is a way, but I don't know - # it - im.flipud_out() - im.write_png(filename) + im.write_png(base64writer) im.flipud_out() - - imfile = file (filename, 'rb') - image64 = base64.encodestring (imfile.read()) - imfile.close() - os.remove(filename) - hrefstr = 'data:image/png;base64,\n' + image64 - + base64writer.flush() else: self._imaged[self.basename] = self._imaged.get(self.basename,0) + 1 filename = '%s.image%d.png'%(self.basename, self._imaged[self.basename]) @@ -276,12 +279,9 @@ im.flipud_out() im.write_png(filename) im.flipud_out() - hrefstr = filename + self._svgwriter.write(filename) - self._svgwriter.write ( - '<image x="%s" y="%s" width="%s" height="%s" ' - 'xlink:href="%s" %s/>\n'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, hrefstr, transstr) - ) + self._svgwriter.write('"/>\n') def draw_text(self, gc, x, y, s, prop, angle, ismath): if ismath: Modified: branches/transforms/src/_image.cpp =================================================================== --- branches/transforms/src/_image.cpp 2007-12-12 19:15:46 UTC (rev 4715) +++ branches/transforms/src/_image.cpp 2007-12-12 20:06:30 UTC (rev 4716) @@ -575,7 +575,25 @@ } +static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) { + PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); + PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write"); + PyObject* result = NULL; + if (write_method) + result = PyObject_CallFunction(write_method, "s#", data, length); + Py_XDECREF(write_method); + Py_XDECREF(result); +} +static void flush_png_data(png_structp png_ptr) { + PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); + PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush"); + PyObject* result = NULL; + if (flush_method) + result = PyObject_CallFunction(flush_method, ""); + Py_XDECREF(flush_method); + Py_XDECREF(result); +} // this code is heavily adapted from the paint license, which is in // the file paint.license (BSD compatible) included in this @@ -593,79 +611,90 @@ args.verify_length(1); - std::pair<agg::int8u*,bool> bufpair = _get_output_buffer(); + FILE *fp = NULL; + Py::Object py_fileobj = Py::Object(args[0]); + if (py_fileobj.isString()) { + std::string fileName = Py::String(py_fileobj); + const char *file_name = fileName.c_str(); + if ((fp = fopen(file_name, "wb")) == NULL) + throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() ); + } + else { + PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); + if (!(write_method && PyCallable_Check(write_method))) { + Py_XDECREF(write_method); + throw Py::TypeError("Object does not appear to be a path or a Python file-like object"); + } + Py_XDECREF(write_method); + } - std::string fileName = Py::String(args[0]); - const char *file_name = fileName.c_str(); - FILE *fp; png_structp png_ptr; png_infop info_ptr; - struct png_color_8_struct sig_bit; + struct png_color_8_struct sig_bit; png_uint_32 row=0; //todo: allocate on heap - png_bytep *row_pointers = new png_bytep[rowsOut]; + png_bytep *row_pointers = NULL; + std::pair<agg::int8u*,bool> bufpair; + bufpair.first = NULL; + bufpair.second = false; - for (row = 0; row < rowsOut; ++row) - row_pointers[row] = bufpair.first + row * colsOut * 4; + try { + row_pointers = new png_bytep[rowsOut]; + if (!row_pointers) + throw Py::RuntimeError("Out of memory"); - fp = fopen(file_name, "wb"); - if (fp == NULL) { - if (bufpair.second) delete [] bufpair.first; - delete [] row_pointers; - throw Py::RuntimeError(Printf("Could not open file %s", file_name).str()); - } + bufpair = _get_output_buffer(); + for (row = 0; row < rowsOut; ++row) + row_pointers[row] = bufpair.first + row * colsOut * 4; + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png_ptr == NULL) + throw Py::RuntimeError("Could not create write struct"); - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL) { - if (bufpair.second) delete [] bufpair.first; - fclose(fp); - delete [] row_pointers; - throw Py::RuntimeError("Could not create write struct"); - } + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + throw Py::RuntimeError("Could not create info struct"); - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) { - if (bufpair.second) delete [] bufpair.first; - fclose(fp); + if (setjmp(png_ptr->jmpbuf)) + throw Py::RuntimeError("Error building image"); + + if (fp) { + png_init_io(png_ptr, fp); + } else { + png_set_write_fn(png_ptr, (void*)py_fileobj.ptr(), + &write_png_data, &flush_png_data); + } + png_set_IHDR(png_ptr, info_ptr, + colsOut, rowsOut, 8, + PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + // this a a color image! + sig_bit.gray = 0; + sig_bit.red = 8; + sig_bit.green = 8; + sig_bit.blue = 8; + /* if the image has an alpha channel then */ + sig_bit.alpha = 8; + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + + png_write_info(png_ptr, info_ptr); + png_write_image(png_ptr, row_pointers); + png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); - delete [] row_pointers; - throw Py::RuntimeError("Could not create info struct"); - } - - if (setjmp(png_ptr->jmpbuf)) { + } catch (...) { if (bufpair.second) delete [] bufpair.first; - fclose(fp); + if (fp) fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); delete [] row_pointers; - throw Py::RuntimeError("Error building image"); + throw; } - png_init_io(png_ptr, fp); - png_set_IHDR(png_ptr, info_ptr, - colsOut, rowsOut, 8, - PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - // this a a color image! - sig_bit.gray = 0; - sig_bit.red = 8; - sig_bit.green = 8; - sig_bit.blue = 8; - /* if the image has an alpha channel then */ - sig_bit.alpha = 8; - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - - png_write_info(png_ptr, info_ptr); - png_write_image(png_ptr, row_pointers); - png_write_end(png_ptr, info_ptr); - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - + if (fp) fclose(fp); delete [] row_pointers; + if (bufpair.second) delete [] bufpair.first; - if (bufpair.second) delete [] bufpair.first; return Py::Object(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 19:16:46
|
Revision: 4715 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4715&view=rev Author: mdboom Date: 2007-12-12 11:15:46 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Merged revisions 4707-4714 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4707 | mdboom | 2007-12-12 09:52:01 -0500 (Wed, 12 Dec 2007) | 2 lines Support fontconfig syntax in Text constructor. ........ r4713 | mdboom | 2007-12-12 14:07:03 -0500 (Wed, 12 Dec 2007) | 2 lines Fix reference-counting leak when saving an Agg Png to a file-like object. ........ Modified Paths: -------------- branches/transforms/src/_backend_agg.cpp Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4706 + /trunk/matplotlib:1-4714 Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-12-12 19:11:44 UTC (rev 4714) +++ branches/transforms/src/_backend_agg.cpp 2007-12-12 19:15:46 UTC (rev 4715) @@ -1289,17 +1289,21 @@ static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) { PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write"); - PyObject_CallFunction(write_method, "s#", data, length); - - // MGDTODO: Check NULL on failure + PyObject* result = NULL; + if (write_method) + result = PyObject_CallFunction(write_method, "s#", data, length); + Py_XDECREF(write_method); + Py_XDECREF(result); } static void flush_png_data(png_structp png_ptr) { PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush"); - if (flush_method) { - PyObject_CallFunction(flush_method, ""); - } + PyObject* result = NULL; + if (flush_method) + result = PyObject_CallFunction(flush_method, ""); + Py_XDECREF(flush_method); + Py_XDECREF(result); } // this code is heavily adapted from the paint license, which is in @@ -1322,8 +1326,11 @@ } else { PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); - if (!(write_method && PyCallable_Check(write_method))) + if (!(write_method && PyCallable_Check(write_method))) { + Py_XDECREF(write_method); throw Py::TypeError("Object does not appear to be a path or a Python file-like object"); + } + Py_XDECREF(write_method); } png_bytep *row_pointers = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 19:12:59
|
Revision: 4714 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4714&view=rev Author: mdboom Date: 2007-12-12 11:11:44 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Code cleanup Modified Paths: -------------- branches/transforms/lib/matplotlib/patches.py Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-12-12 19:07:03 UTC (rev 4713) +++ branches/transforms/lib/matplotlib/patches.py 2007-12-12 19:11:44 UTC (rev 4714) @@ -993,15 +993,6 @@ self._path = Path.arc(self._theta1, self._theta2) return Patch.draw(self, renderer) - # Transforms the axes box_path so that it is relative to the unit - # circle in the same way that it is relative to the desired - # ellipse. - box_path = Path.unit_rectangle() - box_path_transform = transforms.BboxTransformTo(self.axes.bbox) + \ - self.get_transform().inverted() - box_path = box_path.transformed(box_path_transform) - vertices = [] - def iter_circle_intersect_on_line(x0, y0, x1, y1): dx = x1 - x0 dy = y1 - y0 @@ -1046,6 +1037,15 @@ if x >= x0e and x <= x1e and y >= y0e and y <= y1e: yield x, y + + # Transforms the axes box_path so that it is relative to the unit + # circle in the same way that it is relative to the desired + # ellipse. + box_path = Path.unit_rectangle() + box_path_transform = transforms.BboxTransformTo(self.axes.bbox) + \ + self.get_transform().inverted() + box_path = box_path.transformed(box_path_transform) + PI = npy.pi TWOPI = PI * 2.0 RAD2DEG = 180.0 / PI This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 19:09:00
|
Revision: 4713 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4713&view=rev Author: mdboom Date: 2007-12-12 11:07:03 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Fix reference-counting leak when saving an Agg Png to a file-like object. Modified Paths: -------------- trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2007-12-12 18:24:56 UTC (rev 4712) +++ trunk/matplotlib/src/_backend_agg.cpp 2007-12-12 19:07:03 UTC (rev 4713) @@ -2261,17 +2261,21 @@ static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) { PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write"); - PyObject_CallFunction(write_method, "s#", data, length); - - // MGDTODO: Check NULL on failure + PyObject* result = NULL; + if (write_method) + result = PyObject_CallFunction(write_method, "s#", data, length); + Py_XDECREF(write_method); + Py_XDECREF(result); } static void flush_png_data(png_structp png_ptr) { PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush"); - if (flush_method) { - PyObject_CallFunction(flush_method, ""); - } + PyObject* result = NULL; + if (flush_method) + result = PyObject_CallFunction(flush_method, ""); + Py_XDECREF(flush_method); + Py_XDECREF(result); } // this code is heavily adapted from the paint license, which is in @@ -2294,8 +2298,11 @@ } else { PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); - if (!(write_method && PyCallable_Check(write_method))) + if (!(write_method && PyCallable_Check(write_method))) { + Py_XDECREF(write_method); throw Py::TypeError("Object does not appear to be a path or a Python file-like object"); + } + Py_XDECREF(write_method); } png_bytep *row_pointers = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-12 18:25:34
|
Revision: 4712 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4712&view=rev Author: jswhit Date: 2007-12-12 10:24:56 -0800 (Wed, 12 Dec 2007) Log Message: ----------- fix up a bit. Modified Paths: -------------- trunk/toolkits/basemap/examples/plotsst.py Modified: trunk/toolkits/basemap/examples/plotsst.py =================================================================== --- trunk/toolkits/basemap/examples/plotsst.py 2007-12-12 16:57:09 UTC (rev 4711) +++ trunk/toolkits/basemap/examples/plotsst.py 2007-12-12 18:24:56 UTC (rev 4712) @@ -4,23 +4,38 @@ # can be a local file, a URL for a remote opendap dataset, # or (if PyNIO is installed) a GRIB or HDF file. ncfile = NetCDFFile('http://nomads.ncdc.noaa.gov:8085/thredds/dodsC/oisst/2007/AVHRR/sst4-navy-eot.20071201.nc') +# read sst. Will automatically create a masked array using +# missing_value variable attribute. sst = ncfile.variables['sst'][:] +# read lats and lons (representing centers of grid boxes). lats = ncfile.variables['lat'][:] lons = ncfile.variables['lon'][:] +# shift lats, lons so values represent edges of grid boxes +# (as pcolor expects). +delon = lons[1]-lons[0] +delat = lats[1]-lats[0] +lons = (lons - 0.5*delon).tolist() +lons.append(lons[-1]+delon) +lons = numpy.array(lons,numpy.float64) +lats = (lats - 0.5*delat).tolist() +lats.append(lats[-1]+delat) +lats = numpy.array(lats,numpy.float64) # create Basemap instance for mollweide projection. # coastlines not used, so resolution set to None to skip # continent processing (this speeds things up a bit) m = Basemap(projection='moll',lon_0=lons.mean(),lat_0=0,resolution=None) # compute map projection coordinates of grid. x, y = m(*numpy.meshgrid(lons, lats)) -m.drawmapboundary(fill_color='k') +# draw line around map projection limb. +# color background of map projection region. +# missing values over land will show up this color. +m.drawmapboundary(fill_color='0.3') # plot with pcolor -im = m.pcolormesh(x,y,sst,shading='flat',cmap=pylab.cm.gist_ncar) +im = m.pcolor(x,y,sst,shading='flat',cmap=pylab.cm.gist_ncar) # draw parallels and meridians, but don't bother labelling them. m.drawparallels(numpy.arange(-90.,120.,30.)) m.drawmeridians(numpy.arange(0.,420.,60.)) -# draw line around map projection limb. -# color map region background black (missing values will be this color) # draw horizontal colorbar. pylab.colorbar(orientation='horizontal') +# display the plot. pylab.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-12 16:57:32
|
Revision: 4711 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4711&view=rev Author: jswhit Date: 2007-12-12 08:57:09 -0800 (Wed, 12 Dec 2007) Log Message: ----------- add plotsst.py example. Modified Paths: -------------- trunk/toolkits/basemap/MANIFEST.in trunk/toolkits/basemap/examples/README trunk/toolkits/basemap/examples/run_all.py Modified: trunk/toolkits/basemap/MANIFEST.in =================================================================== --- trunk/toolkits/basemap/MANIFEST.in 2007-12-12 16:43:29 UTC (rev 4710) +++ trunk/toolkits/basemap/MANIFEST.in 2007-12-12 16:57:09 UTC (rev 4711) @@ -43,6 +43,7 @@ include examples/geos_demo_2.py include examples/200706041200-msg-ch01-SAfrica.jpg include examples/fcstmaps.py +include examples/plotsst.py include examples/wiki_example.py include examples/fillstates.py include examples/run_all.py Modified: trunk/toolkits/basemap/examples/README =================================================================== --- trunk/toolkits/basemap/examples/README 2007-12-12 16:43:29 UTC (rev 4710) +++ trunk/toolkits/basemap/examples/README 2007-12-12 16:57:09 UTC (rev 4711) @@ -13,6 +13,9 @@ customticks.py shows how to create custom tick labels for a cylindrical projection. +plotcities.py shows how to read and plot data from a shapefile containing +Point data. + plotmap.py is the example on the matplotlib 'screenshots' page (included in test.py) which shows the ETOPO topography as an image on a Lambert Conformal projection (using imshow). @@ -52,6 +55,9 @@ fcstmaps.py is a sample multi-panel plot that accesses data over http using the dap module. An internet connection is required. +plotsst.py also uses dap client to access the data, and also illustrates +how the NetCDFFile function deals with missing values. + wiki_example.py is the example from the MatplotlibCookbook scipy wiki page (http://www.scipy.org/wikis/topical_software/MatplotlibCookbook/wikipage_view). Modified: trunk/toolkits/basemap/examples/run_all.py =================================================================== --- trunk/toolkits/basemap/examples/run_all.py 2007-12-12 16:43:29 UTC (rev 4710) +++ trunk/toolkits/basemap/examples/run_all.py 2007-12-12 16:57:09 UTC (rev 4711) @@ -2,6 +2,7 @@ test_files = glob.glob('*.py') test_files.remove('run_all.py') test_files.remove('fcstmaps.py') +test_files.remove('plotsst.py') test_files.remove('testgdal.py') test_files.remove('pnganim.py') test_files.remove('warpimage.py') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-12 16:47:54
|
Revision: 4709 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4709&view=rev Author: jswhit Date: 2007-12-12 08:25:57 -0800 (Wed, 12 Dec 2007) Log Message: ----------- break some long lines Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-12-12 15:01:20 UTC (rev 4708) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-12-12 16:25:57 UTC (rev 4709) @@ -96,9 +96,11 @@ def _maskandscale(var,datout): if hasattr(var, 'missing_value') and (datout == var.missing_value).any(): - datout = ma.masked_array(datout, mask = datout == var.missing_value, fill_value=var.missing_value) + datout = ma.masked_array(datout,mask=datout==var.missing_value, + fill_value=var.missing_value) elif hasattr(var, '_FillValue') and (datout == var._FillValue).any(): - datout = ma.masked_array(datout, mask = datout == var._FillValue, fill_value=var._FillValue) + datout = ma.masked_array(datout,mask=datout==var._FillValue, + fill_value=var._FillValue) try: datout = var.scale_factor*datout + var.add_offset except: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-12 16:43:39
|
Revision: 4710 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4710&view=rev Author: jswhit Date: 2007-12-12 08:43:29 -0800 (Wed, 12 Dec 2007) Log Message: ----------- install dap client anyway if installed version is older. Modified Paths: -------------- trunk/toolkits/basemap/setup.py Modified: trunk/toolkits/basemap/setup.py =================================================================== --- trunk/toolkits/basemap/setup.py 2007-12-12 16:25:57 UTC (rev 4709) +++ trunk/toolkits/basemap/setup.py 2007-12-12 16:43:29 UTC (rev 4710) @@ -112,11 +112,20 @@ # install dap and httplib2, if not already available. # only a subset of dap is installed (the client, not the server) +__dapversion__ = None try: - from dap import client + from dap.lib import __version__ as __dapversion__ except ImportError: packages = packages + ['dap','dap.util','dap.parsers'] package_dirs['dap'] = os.path.join('lib','dap') +# install dap client anyway if installed version is older than +# version provided here. +if __dapversion__ is not None: + __dapversion__ = [repr(v)+'.' for v in __dapversion__] + __dapversion__ = ''.join(__dapversion__)[:-1] + if __dapversion__ < '2.2.6.2': + packages = packages + ['dap','dap.util','dap.parsers'] + package_dirs['dap'] = os.path.join('lib','dap') try: import httplib2 except ImportError: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 15:01:37
|
Revision: 4708 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4708&view=rev Author: mdboom Date: 2007-12-12 07:01:20 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Merged revisions 4689-4706 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4697 | pkienzle | 2007-12-11 12:14:44 -0500 (Tue, 11 Dec 2007) | 1 line remove wx specific gui_repaint comment ........ r4698 | jdh2358 | 2007-12-11 16:17:59 -0500 (Tue, 11 Dec 2007) | 2 lines fixed text with dash bug ........ r4706 | mdboom | 2007-12-12 09:08:15 -0500 (Wed, 12 Dec 2007) | 2 lines Support alpha-blended text in the Agg and Svg backends. ........ Modified Paths: -------------- branches/transforms/examples/dashpointlabel.py branches/transforms/examples/lasso_demo.py branches/transforms/lib/matplotlib/backend_bases.py branches/transforms/lib/matplotlib/backends/backend_svg.py branches/transforms/lib/matplotlib/cbook.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/text.py branches/transforms/src/_backend_agg.cpp Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4688 + /trunk/matplotlib:1-4706 Modified: branches/transforms/examples/dashpointlabel.py =================================================================== --- branches/transforms/examples/dashpointlabel.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/examples/dashpointlabel.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -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: branches/transforms/examples/lasso_demo.py =================================================================== --- branches/transforms/examples/lasso_demo.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/examples/lasso_demo.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -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: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -843,7 +843,6 @@ a.set_facecolor('lightblue') else: self._active[a] = None self.draw_idle() - #self.gui_repaint() def pick(self, mouseevent): if not self.widgetlock.locked(): Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -296,7 +296,7 @@ color = rgb2hex(gc.get_rgb()[:3]) 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: @@ -335,7 +335,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: branches/transforms/lib/matplotlib/cbook.py =================================================================== --- branches/transforms/lib/matplotlib/cbook.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/lib/matplotlib/cbook.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -11,7 +11,7 @@ set = set except NameError: from sets import Set as set - + major, minor1, minor2, s, tmp = sys.version_info @@ -974,9 +974,9 @@ .get(). The objects being joined must be hashable. - + For example: - + >>> g = grouper.Grouper() >>> g.join('a', 'b') >>> g.join('b', 'c') @@ -989,7 +989,7 @@ True >>> g.joined('a', 'd') False - """ + """ def __init__(self, init=[]): mapping = self._mapping = {} for x in init: @@ -997,7 +997,7 @@ def __contains__(self, item): return item in self._mapping - + def join(self, a, *args): """ Join given arguments into the same set. @@ -1045,7 +1045,7 @@ """ return self._mapping.get(a, [a]) - + def simple_linear_interpolation(a, steps): steps = npy.floor(steps) new_length = ((len(a) - 1) * steps) + 1 @@ -1061,7 +1061,7 @@ for i in range(1, int(steps)): result[i::steps] = delta * i + a0 result[steps::steps] = a1 - + return result if __name__=='__main__': Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/lib/matplotlib/patches.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -1006,7 +1006,6 @@ dx = x1 - x0 dy = y1 - y0 dr2 = dx*dx + dy*dy - dr = npy.sqrt(dr2) D = x0*y1 - x1*y0 D2 = D*D discrim = dr2 - D2 @@ -1017,7 +1016,9 @@ y = (-D*dx) / dr2 yield x, y elif discrim > 0.0: - if dy < 0: + # The definition of "sign" here is different from + # npy.sign: we never want to get 0.0 + if dy < 0.0: sign_dy = -1.0 else: sign_dy = 1.0 @@ -1057,10 +1058,10 @@ x0, y0 = p0 x1, y1 = p1 for x, y in iter_circle_intersect_on_line_seg(x0, y0, x1, y1): - # Convert radians to angles theta = npy.arccos(x) if y < 0: theta = TWOPI - theta + # Convert radians to angles theta *= RAD2DEG if theta > theta1 and theta < theta2: thetas[theta] = None @@ -1072,7 +1073,6 @@ last_theta = theta1 theta1_rad = theta1 * DEG2RAD inside = box_path.contains_point((npy.cos(theta1_rad), npy.sin(theta1_rad))) - for theta in thetas: if inside: self._path = Path.arc(last_theta, theta, 8) Modified: branches/transforms/lib/matplotlib/text.py =================================================================== --- branches/transforms/lib/matplotlib/text.py 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/lib/matplotlib/text.py 2007-12-12 15:01:20 UTC (rev 4708) @@ -368,6 +368,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().transform_point((self._x, self._y)) + def get_position(self): "Return x, y as tuple" x = float(self.convert_xunits(self._x)) @@ -631,6 +636,8 @@ ACCEPTS: a matplotlib.font_manager.FontProperties instance """ + if is_string_like(fp): + fp = FontProperties(fp) self._fontproperties = fp artist.kwdocd['Text'] = artist.kwdoc(Text) @@ -731,6 +738,24 @@ #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.update_coords(renderer) Text.draw(self, renderer) @@ -808,7 +833,8 @@ cwd *= 1+dashpad/npy.sqrt(npy.dot(cwd,cwd)) cw = c2+(dashdirection*2-1)*cwd - self._x, self._y = inverse.transform_point(tuple(cw)) + newx, newy = inverse.transform_point(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. @@ -892,9 +918,6 @@ """ self._dashpush = dp - def get_position(self): - "Return x, y as tuple" - return self._dashx, self._dashy def set_position(self, xy): """ Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-12-12 14:52:01 UTC (rev 4707) +++ branches/transforms/src/_backend_agg.cpp 2007-12-12 15:01:20 UTC (rev 4708) @@ -625,7 +625,7 @@ do { *output_span = _color; - output_span->a = input_span->v; + output_span->a = ((unsigned int)_color.a * (unsigned int)input_span->v) >> 8; ++output_span; ++input_span; } while (--len); 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:52:52
|
Revision: 4707 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4707&view=rev Author: mdboom Date: 2007-12-12 06:52:01 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Support fontconfig syntax in Text constructor. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2007-12-12 14:08:15 UTC (rev 4706) +++ trunk/matplotlib/lib/matplotlib/text.py 2007-12-12 14:52:01 UTC (rev 4707) @@ -675,6 +675,8 @@ ACCEPTS: a matplotlib.font_manager.FontProperties instance """ + if is_string_like(fp): + fp = FontProperties(fp) self._fontproperties = fp artist.kwdocd['Text'] = artist.kwdoc(Text) 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: <js...@us...> - 2007-12-12 14:05:07
|
Revision: 4705 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4705&view=rev Author: jswhit Date: 2007-12-12 06:04:57 -0800 (Wed, 12 Dec 2007) Log Message: ----------- new example Added Paths: ----------- trunk/toolkits/basemap/examples/plotsst.py Added: trunk/toolkits/basemap/examples/plotsst.py =================================================================== --- trunk/toolkits/basemap/examples/plotsst.py (rev 0) +++ trunk/toolkits/basemap/examples/plotsst.py 2007-12-12 14:04:57 UTC (rev 4705) @@ -0,0 +1,26 @@ +from matplotlib.toolkits.basemap import Basemap, NetCDFFile +import pylab, numpy +# read in sea-surface temperature data +# can be a local file, a URL for a remote opendap dataset, +# or (if PyNIO is installed) a GRIB or HDF file. +ncfile = NetCDFFile('http://nomads.ncdc.noaa.gov:8085/thredds/dodsC/oisst/2007/AVHRR/sst4-navy-eot.20071201.nc') +sst = ncfile.variables['sst'][:] +lats = ncfile.variables['lat'][:] +lons = ncfile.variables['lon'][:] +# create Basemap instance for mollweide projection. +# coastlines not used, so resolution set to None to skip +# continent processing (this speeds things up a bit) +m = Basemap(projection='moll',lon_0=lons.mean(),lat_0=0,resolution=None) +# compute map projection coordinates of grid. +x, y = m(*numpy.meshgrid(lons, lats)) +m.drawmapboundary(fill_color='k') +# plot with pcolor +im = m.pcolormesh(x,y,sst,shading='flat',cmap=pylab.cm.gist_ncar) +# draw parallels and meridians, but don't bother labelling them. +m.drawparallels(numpy.arange(-90.,120.,30.)) +m.drawmeridians(numpy.arange(0.,420.,60.)) +# draw line around map projection limb. +# color map region background black (missing values will be this color) +# draw horizontal colorbar. +pylab.colorbar(orientation='horizontal') +pylab.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-12 14:00:22
|
Revision: 4704 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4704&view=rev Author: jswhit Date: 2007-12-12 06:00:04 -0800 (Wed, 12 Dec 2007) Log Message: ----------- make sure masked arrays have correct fill_value Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-12-12 13:55:12 UTC (rev 4703) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-12-12 14:00:04 UTC (rev 4704) @@ -96,9 +96,9 @@ def _maskandscale(var,datout): if hasattr(var, 'missing_value') and (datout == var.missing_value).any(): - datout = ma.masked_values(datout, var.missing_value) + datout = ma.masked_array(datout, mask = datout == var.missing_value, fill_value=var.missing_value) elif hasattr(var, '_FillValue') and (datout == var._FillValue).any(): - datout = ma.masked_values(datout, var._FillValue) + datout = ma.masked_array(datout, mask = datout == var._FillValue, fill_value=var._FillValue) try: datout = var.scale_factor*datout + var.add_offset except: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 13:55:27
|
Revision: 4703 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4703&view=rev Author: mdboom Date: 2007-12-12 05:55:12 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Layout fix. Modified Paths: -------------- branches/transforms/src/_path.cpp Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-12-12 13:54:56 UTC (rev 4702) +++ branches/transforms/src/_path.cpp 2007-12-12 13:55:12 UTC (rev 4703) @@ -141,7 +141,7 @@ // The following cases denote the beginning on a new subpath if (code == agg::path_cmd_stop || - (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) + (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) { x = sx; y = sy; @@ -184,7 +184,7 @@ vty1 = y; } while (code != agg::path_cmd_stop && - (code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly); + (code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly); yflag1 = (vty1 >= ty); if (yflag0 != yflag1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 13:55:11
|
Revision: 4702 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4702&view=rev Author: mdboom Date: 2007-12-12 05:54:56 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Fix a bad merge. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_cairo.py branches/transforms/lib/matplotlib/backends/backend_svg.py Modified: branches/transforms/lib/matplotlib/backends/backend_cairo.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-12 13:48:09 UTC (rev 4701) +++ branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-12 13:54:56 UTC (rev 4702) @@ -34,7 +34,6 @@ 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 Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 13:48:09 UTC (rev 4701) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12 13:54:56 UTC (rev 4702) @@ -2,7 +2,6 @@ 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 13:48:32
|
Revision: 4701 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4701&view=rev Author: mdboom Date: 2007-12-12 05:48:09 -0800 (Wed, 12 Dec 2007) Log Message: ----------- Make the arc edge detection algorithm be dynamic based on the size of the ellipse, rather than always on (that was just for debugging). Modified Paths: -------------- branches/transforms/lib/matplotlib/patches.py Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-12-12 00:15:23 UTC (rev 4700) +++ branches/transforms/lib/matplotlib/patches.py 2007-12-12 13:48:09 UTC (rev 4701) @@ -989,7 +989,7 @@ (self._width, self._height)) inv_error = (1.0 / 1.89818e-6) - if width < inv_error and height < inv_error and False: + if width < inv_error and height < inv_error: self._path = Path.arc(self._theta1, self._theta2) return Patch.draw(self, renderer) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-12 00:15:30
|
Revision: 4700 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4700&view=rev Author: mdboom Date: 2007-12-11 16:15:23 -0800 (Tue, 11 Dec 2007) Log Message: ----------- Added (experimental) support for large arcs Modified Paths: -------------- branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/path.py branches/transforms/src/_path.cpp branches/transforms/unit/ellipse_compare.py branches/transforms/unit/ellipse_large.py Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-12-11 22:03:58 UTC (rev 4699) +++ branches/transforms/lib/matplotlib/patches.py 2007-12-12 00:15:23 UTC (rev 4700) @@ -839,6 +839,7 @@ self._width, self._height = width, height self._angle = angle self._recompute_transform() + self._path = Path.unit_circle() def _recompute_transform(self): self._patch_transform = transforms.Affine2D() \ @@ -850,7 +851,7 @@ """ Return the vertices of the rectangle """ - return Path.unit_circle() + return self._path def get_patch_transform(self): return self._patch_transform @@ -881,7 +882,6 @@ self._recompute_transform() angle = property(_get_angle, _set_angle) - class Circle(Ellipse): """ A circle patch @@ -908,7 +908,180 @@ Ellipse.__init__(self, xy, radius*2, radius*2, **kwargs) __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd +class Arc(Ellipse): + """ + An elliptical arc. Because it performs various optimizations, it may not be + filled. + """ + def __str__(self): + return "Arc(%d,%d;%dx%d)"%(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 + width - length of horizontal axis + height - length of vertical axis + angle - rotation in degrees (anti-clockwise) + theta1 - starting angle of the arc in degrees + theta2 - ending angle of the arc in degrees + + If theta1 and theta2 are not provided, the arc will form a + complete ellipse. + + Valid kwargs are: + %(Patch)s + """ + fill = kwargs.pop('fill') + if fill: + raise ValueError("Arc objects can not be filled") + kwargs['fill'] = False + + Ellipse.__init__(self, xy, width, height, angle, **kwargs) + + self._theta1 = theta1 + self._theta2 = theta2 + + def draw(self, renderer): + """ + Ellipses are normally drawn using an approximation that uses + eight cubic bezier splines. The error of this approximation + is 1.89818e-6, according to this unverified source: + + Lancaster, Don. Approximating a Circle or an Ellipse Using + Four Bezier Cubic Splines. + + http://www.tinaja.com/glib/ellipse4.pdf + + There is a use case where very large ellipses must be drawn + with very high accuracy, and it is too expensive to render the + entire ellipse with enough segments (either splines or line + segments). Therefore, in the case where either radius of the + ellipse is large enough that the error of the spline + approximation will be visible (greater than one pixel offset + from the ideal), a different technique is used. + + In that case, only the visible parts of the ellipse are drawn, + with each visible arc using a fixed number of spline segments + (8). The algorithm proceeds as follows: + + 1. The points where the ellipse intersects the axes bounding + box are located. (This is done be performing an inverse + transformation on the axes bbox such that it is relative to + the unit circle -- this makes the intersection calculation + much easier than doing rotated ellipse intersection + directly). + + This uses the "line intersecting a circle" algorithm from: + + Vince, John. Geometry for Computer Graphics: Formulae, + Examples & Proofs. London: Springer-Verlag, 2005. + + 2. The angles of each of the intersection points are + calculated. + + 3. Proceeding counterclockwise starting in the positive + x-direction, each of the visible arc-segments between the + pairs of vertices are drawn using the bezier arc + approximation technique implemented in Path.arc(). + """ + # Get the width and height in pixels + width, height = self.get_transform().transform_point( + (self._width, self._height)) + inv_error = (1.0 / 1.89818e-6) + + if width < inv_error and height < inv_error and False: + self._path = Path.arc(self._theta1, self._theta2) + return Patch.draw(self, renderer) + + # Transforms the axes box_path so that it is relative to the unit + # circle in the same way that it is relative to the desired + # ellipse. + box_path = Path.unit_rectangle() + box_path_transform = transforms.BboxTransformTo(self.axes.bbox) + \ + self.get_transform().inverted() + box_path = box_path.transformed(box_path_transform) + vertices = [] + + def iter_circle_intersect_on_line(x0, y0, x1, y1): + dx = x1 - x0 + dy = y1 - y0 + dr2 = dx*dx + dy*dy + dr = npy.sqrt(dr2) + D = x0*y1 - x1*y0 + D2 = D*D + discrim = dr2 - D2 + + # Single (tangential) intersection + if discrim == 0.0: + x = (D*dy) / dr2 + y = (-D*dx) / dr2 + yield x, y + elif discrim > 0.0: + if dy < 0: + sign_dy = -1.0 + else: + sign_dy = 1.0 + sqrt_discrim = npy.sqrt(discrim) + for sign in (1., -1.): + x = (D*dy + sign * sign_dy * dx * sqrt_discrim) / dr2 + y = (-D*dx + sign * npy.abs(dy) * sqrt_discrim) / dr2 + yield x, y + + def iter_circle_intersect_on_line_seg(x0, y0, x1, y1): + epsilon = 1e-9 + if x1 < x0: + x0e, x1e = x1, x0 + else: + x0e, x1e = x0, x1 + if y1 < y0: + y0e, y1e = y1, y0 + else: + y0e, y1e = y0, y1 + x0e -= epsilon + y0e -= epsilon + x1e += epsilon + y1e += epsilon + for x, y in iter_circle_intersect_on_line(x0, y0, x1, y1): + if x >= x0e and x <= x1e and y >= y0e and y <= y1e: + yield x, y + + PI = npy.pi + TWOPI = PI * 2.0 + RAD2DEG = 180.0 / PI + DEG2RAD = PI / 180.0 + theta1 = self._theta1 + theta2 = self._theta2 + thetas = {} + # For each of the point pairs, there is a line segment + for p0, p1 in zip(box_path.vertices[:-1], box_path.vertices[1:]): + x0, y0 = p0 + x1, y1 = p1 + for x, y in iter_circle_intersect_on_line_seg(x0, y0, x1, y1): + # Convert radians to angles + theta = npy.arccos(x) + if y < 0: + theta = TWOPI - theta + theta *= RAD2DEG + if theta > theta1 and theta < theta2: + thetas[theta] = None + + thetas = thetas.keys() + thetas.sort() + thetas.append(theta2) + + last_theta = theta1 + theta1_rad = theta1 * DEG2RAD + inside = box_path.contains_point((npy.cos(theta1_rad), npy.sin(theta1_rad))) + + for theta in thetas: + if inside: + self._path = Path.arc(last_theta, theta, 8) + Patch.draw(self, renderer) + inside = False + else: + inside = True + last_theta = theta + def bbox_artist(artist, renderer, props=None, fill=True): """ This is a debug function to draw a rectangle around the bounding Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-12-11 22:03:58 UTC (rev 4699) +++ branches/transforms/lib/matplotlib/path.py 2007-12-12 00:15:23 UTC (rev 4700) @@ -408,7 +408,7 @@ unit_circle = classmethod(unit_circle) #@classmethod - def arc(cls, theta1, theta2, is_wedge=False, n=None): + def arc(cls, theta1, theta2, n=None, is_wedge=False): """ Returns an arc on the unit circle from angle theta1 to angle theta2 (in degrees). @@ -486,12 +486,12 @@ arc = classmethod(arc) #@classmethod - def wedge(cls, theta1, theta2): + def wedge(cls, theta1, theta2, n=None): """ Returns a wedge of the unit circle from angle theta1 to angle theta2 (in degrees). """ - return cls.arc(theta1, theta2, True) + return cls.arc(theta1, theta2, True, n) wedge = classmethod(wedge) _get_path_collection_extents = get_path_collection_extents Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-12-11 22:03:58 UTC (rev 4699) +++ branches/transforms/src/_path.cpp 2007-12-12 00:15:23 UTC (rev 4700) @@ -109,7 +109,7 @@ // Input 2D polygon _pgon_ with _numverts_ number of vertices and test point // _point_, returns 1 if inside, 0 if outside. template<class T> -bool point_in_path_impl(double tx, double ty, T& path) +bool point_in_path_impl(const double tx, const double ty, T& path) { int yflag0, yflag1, inside_flag; double vtx0, vty0, vtx1, vty1, sx, sy; @@ -132,7 +132,7 @@ yflag0 = (vty0 >= ty); vtx1 = x; - vty1 = x; + vty1 = y; inside_flag = 0; do @@ -141,7 +141,7 @@ // The following cases denote the beginning on a new subpath if (code == agg::path_cmd_stop || - (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) + (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) { x = sx; y = sy; @@ -169,7 +169,7 @@ // by Joseph Samosky's and Mark Haigh-Hutchinson's different // polygon inclusion tests. if ( ((vty1-ty) * (vtx0-vtx1) >= - (vtx1-tx) * (vty0-vty1)) == yflag1 ) + (vtx1-tx) * (vty0-vty1)) == yflag1 ) { inside_flag ^= 1; } @@ -184,7 +184,7 @@ vty1 = y; } while (code != agg::path_cmd_stop && - (code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly); + (code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly); yflag1 = (vty1 >= ty); if (yflag0 != yflag1) Modified: branches/transforms/unit/ellipse_compare.py =================================================================== --- branches/transforms/unit/ellipse_compare.py 2007-12-11 22:03:58 UTC (rev 4699) +++ branches/transforms/unit/ellipse_compare.py 2007-12-12 00:15:23 UTC (rev 4700) @@ -1,5 +1,5 @@ """ -Compare the ellipse generated with arcs versus a polygonal approximation +Compare the ellipse generated with arcs versus a polygonal approximation """ import numpy as npy from matplotlib import patches @@ -29,7 +29,7 @@ ax = fig.add_subplot(211, aspect='auto') ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1) -e1 = patches.Ellipse((xcenter, ycenter), width, height, +e1 = patches.Arc((xcenter, ycenter), width, height, angle=angle, linewidth=2, fill=False, zorder=2) ax.add_patch(e1) Modified: branches/transforms/unit/ellipse_large.py =================================================================== --- branches/transforms/unit/ellipse_large.py 2007-12-11 22:03:58 UTC (rev 4699) +++ branches/transforms/unit/ellipse_large.py 2007-12-12 00:15:23 UTC (rev 4700) @@ -6,7 +6,7 @@ import math from pylab import * -from matplotlib.patches import Ellipse +from matplotlib.patches import Arc # given a point x, y x = 2692.440 @@ -54,22 +54,22 @@ # 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" ) +lower_ellipse = Arc( (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" ) +target_ellipse = Arc( (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" ) +upper_ellipse = Arc( (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" ) +target = Arc( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" ) ax.add_patch( target ) # give it a big marker @@ -104,4 +104,4 @@ ax.set_ylim(6705, 6735) show() -savefig("ellipse") +# savefig("ellipse") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-11 22:03:59
|
Revision: 4699 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4699&view=rev Author: jswhit Date: 2007-12-11 14:03:58 -0800 (Tue, 11 Dec 2007) Log Message: ----------- fixed exception handling bug in polygon intersection code. Modified Paths: -------------- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-12-11 21:17:59 UTC (rev 4698) +++ trunk/toolkits/basemap/Changelog 2007-12-11 22:03:58 UTC (rev 4699) @@ -1,4 +1,7 @@ version 0.9.9 (not yet released) + * fixed exception handling bug in code that looks for + intersection between boundary feature and map projection + region. * setup.py now looks for GEOS library in a few standard places (/usr/local, /opt, $HOME, /sw) if the GEOS_DIR environment variable not set. This is a workaround for a 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. |