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
(12) |
2
(3) |
3
(2) |
4
(15) |
5
(4) |
6
(8) |
7
(14) |
8
(10) |
9
(6) |
10
(1) |
11
(5) |
12
(7) |
13
(7) |
14
(1) |
15
|
16
(1) |
17
(2) |
18
(4) |
19
(2) |
20
|
21
(1) |
22
(2) |
23
|
24
|
25
(2) |
26
(1) |
27
|
28
(4) |
29
|
30
(1) |
31
|
|
|
|
|
|
|
From: <mme...@us...> - 2008-08-30 10:11:40
|
Revision: 6056 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6056&view=rev Author: mmetz_bn Date: 2008-08-30 10:11:37 +0000 (Sat, 30 Aug 2008) Log Message: ----------- fix problem with hist Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py Modified: trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2008-08-28 13:50:39 UTC (rev 6055) +++ trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2008-08-30 10:11:37 UTC (rev 6056) @@ -24,7 +24,7 @@ if 1: # plot the histogram of MRI intensity subplot(222) im = ravel(im) - im = take(im, nonzero(im)) # ignore the background + im = ravel(take(im, nonzero(im))) # ignore the background im = im/(2.0**15) # normalize hist(im, 100) xticks([-1, -.5, 0, .5, 1]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-08-28 13:50:42
|
Revision: 6055 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6055&view=rev Author: mmetz_bn Date: 2008-08-28 13:50:39 +0000 (Thu, 28 Aug 2008) Log Message: ----------- support for multi-hist with different length Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-28 13:12:46 UTC (rev 6054) +++ trunk/matplotlib/CHANGELOG 2008-08-28 13:50:39 UTC (rev 6055) @@ -1,3 +1,6 @@ +2008-08-28 Added support for multiple histograms with data of + different length - MM + 2008-08-28 Fix step plots with log scale - MGD 2008-08-28 Fix masked arrays with markers in non-Agg backends - MGD Modified: trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2008-08-28 13:12:46 UTC (rev 6054) +++ trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2008-08-28 13:50:39 UTC (rev 6055) @@ -78,5 +78,16 @@ n, bins, patches = P.hist(x, 10, normed=1, histtype='barstacked') +# +# finally: make a multiple-histogram of data-sets with different length +# +x0 = mu + sigma*P.randn(10000) +x1 = mu + sigma*P.randn(7000) +x2 = mu + sigma*P.randn(3000) +P.figure() + +n, bins, patches = P.hist( [x0,x1,x2], 10, histtype='bar') + + P.show() \ No newline at end of file Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-08-28 13:12:46 UTC (rev 6054) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-08-28 13:50:39 UTC (rev 6055) @@ -6157,7 +6157,7 @@ - 'step' generates a lineplot that is by default unfilled - - 'stepfilled' generates a lineplot that this by default + - 'stepfilled' generates a lineplot that is by default filled. *align*: ['left' | 'mid' | 'right' ] @@ -6209,26 +6209,27 @@ raise DeprecationWarning( 'hist now uses the rwidth to give relative width and not absolute width') - # todo: make hist() work with list of arrays with different lengths - x = np.asarray(x).copy() - if len(x.shape)==2 and min(x.shape)==1: - x.shape = max(x.shape), + try: + x = np.transpose(np.asarray(x).copy()) + if len(x.shape)==1: + x.shape = (1,x.shape[0]) + elif len(x.shape)==2 and x.shape[1]<x.shape[0]: + warnings.warn('2D hist should be nsamples x nvariables; this looks transposed') + except ValueError: + # multiple hist with data of different length + if iterable(x[0]) and not is_string_like(x[0]): + tx = [] + for i in xrange(len(x)): + tx.append( np.asarray(x[i]).copy() ) + x = tx - if len(x.shape)==2 and x.shape[0]<x.shape[1]: - warnings.warn('2D hist should be nsamples x nvariables; this looks transposed') - - if len(x.shape)==2: - n = [] - for i in xrange(x.shape[1]): - # this will automatically overwrite bins, - # so that each histogram uses the same bins - m, bins = np.histogram(x[:,i], bins, range=range, - normed=bool(normed), new=True) - n.append(m) - else: - n, bins = np.histogram(x, bins, range=range, + n = [] + for i in xrange(len(x)): + # this will automatically overwrite bins, + # so that each histogram uses the same bins + m, bins = np.histogram(x[i], bins, range=range, normed=bool(normed), new=True) - n = [n,] + n.append(m) if cumulative: slc = slice(None) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-28 13:12:50
|
Revision: 6054 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6054&view=rev Author: mdboom Date: 2008-08-28 13:12:46 +0000 (Thu, 28 Aug 2008) Log Message: ----------- Fix step plots with log scale Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-28 12:45:37 UTC (rev 6053) +++ trunk/matplotlib/CHANGELOG 2008-08-28 13:12:46 UTC (rev 6054) @@ -1,3 +1,5 @@ +2008-08-28 Fix step plots with log scale - MGD + 2008-08-28 Fix masked arrays with markers in non-Agg backends - MGD 2008-08-28 Fix clip_on kwarg so it actually works correctly - MGD Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008-08-28 12:45:37 UTC (rev 6053) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008-08-28 13:12:46 UTC (rev 6054) @@ -14,7 +14,7 @@ from cbook import iterable, is_string_like, is_numlike, ls_mapper, dedent from colors import colorConverter from path import Path -from transforms import Affine2D, Bbox, TransformedPath +from transforms import Affine2D, Bbox, TransformedPath, IdentityTransform from matplotlib import rcParams # special-purpose marker identifiers: @@ -675,7 +675,8 @@ steps[0::2, 1], steps[1:-1:2, 1] = vertices[:, 1], vertices[1:, 1] path = Path(steps) - self._draw_solid(renderer, gc, path, trans) + path = path.transformed(self.get_transform()) + self._draw_solid(renderer, gc, path, IdentityTransform()) def _draw_steps_post(self, renderer, gc, path, trans): @@ -686,7 +687,8 @@ steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:-1, 1] path = Path(steps) - self._draw_solid(renderer, gc, path, trans) + path = path.transformed(self.get_transform()) + self._draw_solid(renderer, gc, path, IdentityTransform()) def _draw_steps_mid(self, renderer, gc, path, trans): @@ -700,7 +702,8 @@ steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:, 1] path = Path(steps) - self._draw_solid(renderer, gc, path, trans) + path = path.transformed(self.get_transform()) + self._draw_solid(renderer, gc, path, IdentityTransform()) def _draw_dashed(self, renderer, gc, path, trans): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-28 12:45:40
|
Revision: 6053 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6053&view=rev Author: mdboom Date: 2008-08-28 12:45:37 +0000 (Thu, 28 Aug 2008) Log Message: ----------- Fix clip_on kwarg to work correctly. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-28 12:42:52 UTC (rev 6052) +++ trunk/matplotlib/CHANGELOG 2008-08-28 12:45:37 UTC (rev 6053) @@ -1,3 +1,5 @@ +2008-08-28 Fix masked arrays with markers in non-Agg backends - MGD + 2008-08-28 Fix clip_on kwarg so it actually works correctly - MGD 2008-08-25 Fix locale problems in SVG backend - MGD Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-08-28 12:42:52 UTC (rev 6052) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-08-28 12:45:37 UTC (rev 6053) @@ -97,10 +97,12 @@ once and reuse it multiple times. """ tpath = trans.transform_path(path) - for x, y in tpath.vertices: - self.draw_path(gc, marker_path, - marker_trans + transforms.Affine2D().translate(x, y), - rgbFace) + for vertices, codes in tpath.iter_segments(): + if len(vertices): + x,y = vertices[-2:] + self.draw_path(gc, marker_path, + marker_trans + transforms.Affine2D().translate(x, y), + rgbFace) def draw_path_collection(self, master_transform, cliprect, clippath, clippath_trans, paths, all_transforms, offsets, Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-08-28 12:42:52 UTC (rev 6052) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-08-28 12:45:37 UTC (rev 6053) @@ -1247,11 +1247,13 @@ output(Op.gsave) lastx, lasty = 0, 0 - for x, y in tpath.vertices: - dx, dy = x - lastx, y - lasty - output(1, 0, 0, 1, dx, dy, Op.concat_matrix, - marker, Op.use_xobject) - lastx, lasty = x, y + for vertices, code in tpath.iter_segments(): + if len(vertices): + x, y = vertices[-2:] + dx, dy = x - lastx, y - lasty + output(1, 0, 0, 1, dx, dy, Op.concat_matrix, + marker, Op.use_xobject) + lastx, lasty = x, y output(Op.grestore) def _setup_textpos(self, x, y, angle, oldx=0, oldy=0, oldangle=0): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-08-28 12:42:52 UTC (rev 6052) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-08-28 12:45:37 UTC (rev 6053) @@ -510,8 +510,10 @@ ps_cmd.extend(['stroke', 'grestore', '} bind def']) tpath = trans.transform_path(path) - for x, y in tpath.vertices: - ps_cmd.append("%g %g o" % (x, y)) + for vertices, code in tpath.iter_segments(): + if len(vertices): + x, y = vertices[-2:] + ps_cmd.append("%g %g o" % (x, y)) ps = '\n'.join(ps_cmd) self._draw_ps(ps, gc, rgbFace, fill=False, stroke=False) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-28 12:42:52 UTC (rev 6052) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-28 12:45:37 UTC (rev 6053) @@ -209,10 +209,12 @@ write('<g %s>' % clippath) trans_and_flip = self._make_flip_transform(trans) tpath = trans_and_flip.transform_path(path) - for x, y in tpath.vertices: - details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y) - style = self._get_style(gc, rgbFace) - self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details)) + for vertices, code in tpath.iter_segments(): + if len(vertices): + x, y = vertices[-2:] + details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y) + style = self._get_style(gc, rgbFace) + self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details)) write('</g>') def draw_path_collection(self, master_transform, cliprect, clippath, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-28 12:42:55
|
Revision: 6052 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6052&view=rev Author: mdboom Date: 2008-08-28 12:42:52 +0000 (Thu, 28 Aug 2008) Log Message: ----------- Fix clip_on kwarg to work correctly. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/artist.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-26 13:24:00 UTC (rev 6051) +++ trunk/matplotlib/CHANGELOG 2008-08-28 12:42:52 UTC (rev 6052) @@ -1,3 +1,5 @@ +2008-08-28 Fix clip_on kwarg so it actually works correctly - MGD + 2008-08-25 Fix locale problems in SVG backend - MGD 2008-08-22 fix quiver so masked values are not plotted - JSW Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2008-08-26 13:24:00 UTC (rev 6051) +++ trunk/matplotlib/lib/matplotlib/artist.py 2008-08-28 12:42:52 UTC (rev 6052) @@ -39,7 +39,7 @@ self._alpha = 1.0 self.clipbox = None self._clippath = None - self._clipon = False + self._clipon = True self._lod = False self._label = '' self._picker = None @@ -292,7 +292,6 @@ ACCEPTS: a :class:`matplotlib.transform.Bbox` instance """ self.clipbox = clipbox - self._clipon = clipbox is not None or self._clippath is not None self.pchanged() def set_clip_path(self, path, transform=None): @@ -341,7 +340,6 @@ print type(path), type(transform) raise TypeError("Invalid arguments to set_clip_path") - self._clipon = self.clipbox is not None or self._clippath is not None self.pchanged() def get_alpha(self): @@ -361,7 +359,7 @@ def get_clip_on(self): 'Return whether artist uses clipping' - return self._clipon and (self.clipbox is not None or self._clippath is not None) + return self._clipon def get_clip_box(self): 'Return artist clipbox' @@ -388,16 +386,17 @@ ACCEPTS: [True | False] """ self._clipon = b - if not b: - self.clipbox = None - self._clippath = None self.pchanged() def _set_gc_clip(self, gc): 'set the clip properly for the gc' - if self.clipbox is not None: - gc.set_clip_rectangle(self.clipbox) - gc.set_clip_path(self._clippath) + if self._clipon: + if self.clipbox is not None: + gc.set_clip_rectangle(self.clipbox) + gc.set_clip_path(self._clippath) + else: + gc.set_clip_rectangle(None) + gc.set_clip_path(None) def draw(self, renderer, *args, **kwargs): 'Derived classes drawing method' @@ -511,7 +510,7 @@ def findobj(self, match=None): """ pyplot signature: - findobj(o=gcf(), match=None) + findobj(o=gcf(), match=None) recursively find all :class:matplotlib.artist.Artist instances contained in self This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-08-26 13:24:03
|
Revision: 6051 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6051&view=rev Author: jdh2358 Date: 2008-08-26 13:24:00 +0000 (Tue, 26 Aug 2008) Log Message: ----------- some fixes for exceltools Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/mpl_toolkits/exceltools.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008-08-25 22:21:49 UTC (rev 6050) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-08-26 13:24:00 UTC (rev 6051) @@ -1818,16 +1818,23 @@ #helpers for loading, saving, manipulating and viewing numpy record arrays + def safe_isnan(x): 'isnan for arbitrary types' + if cbook.is_string_like(x): + return False try: b = np.isnan(x) except NotImplementedError: return False + except TypeError: return False else: return b def safe_isinf(x): 'isnan for arbitrary types' + if cbook.is_string_like(x): + return False try: b = np.isinf(x) except NotImplementedError: return False + except TypeError: return False else: return b def rec_append_field(rec, name, arr, dtype=None): Modified: trunk/matplotlib/lib/mpl_toolkits/exceltools.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/exceltools.py 2008-08-25 22:21:49 UTC (rev 6050) +++ trunk/matplotlib/lib/mpl_toolkits/exceltools.py 2008-08-26 13:24:00 UTC (rev 6051) @@ -20,7 +20,7 @@ """ import copy -import numpy as npy +import numpy as np import pyExcelerator as excel import matplotlib.cbook as cbook import matplotlib.mlab as mlab @@ -97,7 +97,7 @@ rownum+=1 - ind = npy.arange(len(r.dtype.names)) + ind = np.arange(len(r.dtype.names)) for row in r: for i in ind: val = row[i] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-25 22:21:56
|
Revision: 6050 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6050&view=rev Author: mdboom Date: 2008-08-25 22:21:49 +0000 (Mon, 25 Aug 2008) Log Message: ----------- Fix locale problems in SVG backend (thanks, Mathieu Leplatre for reporting) Modified Paths: -------------- branches/v0_91_maint/CHANGELOG branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008-08-25 22:14:33 UTC (rev 6049) +++ branches/v0_91_maint/CHANGELOG 2008-08-25 22:21:49 UTC (rev 6050) @@ -1,3 +1,5 @@ +2008-08-25 Fix locale issues in SVG backend - MGD + 2008-08-01 Backported memory leak fixes in _ttconv.cpp - MGD 2008-07-24 Deprecated (raise NotImplementedError) all the mlab2 Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-08-25 22:14:33 UTC (rev 6049) +++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-08-25 22:21:49 UTC (rev 6050) @@ -116,13 +116,13 @@ if seq is None: dashes = '' else: - dashes = 'stroke-dasharray: %s; stroke-dashoffset: %s;' % ( - ','.join(['%s'%val for val in seq]), offset) + dashes = 'stroke-dasharray: %s; stroke-dashoffset: %f;' % ( + ','.join(['%f'%val for val in seq]), offset) linewidth = gc.get_linewidth() if linewidth: - return 'fill: %s; stroke: %s; stroke-width: %s; ' \ - 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %s' % ( + return 'fill: %s; stroke: %s; stroke-width: %f; ' \ + 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %f' % ( fill, rgb2hex(gc.get_rgb()), linewidth, @@ -132,7 +132,7 @@ gc.get_alpha(), ) else: - return 'fill: %s; opacity: %s' % (\ + return 'fill: %s; opacity: %f' % (\ fill, gc.get_alpha(), ) @@ -170,7 +170,7 @@ box = """\ <defs> <clipPath id="%(key)s"> - <rect x="%(x)s" y="%(y)s" width="%(w)s" height="%(h)s" + <rect x="%(x)f" y="%(y)f" width="%(w)f" height="%(h)f" style="%(style)s"/> </clipPath> </defs> @@ -195,7 +195,7 @@ """ Ignores angles for now """ - details = 'cx="%s" cy="%s" rx="%s" ry="%s" transform="rotate(%1.1f %s %s)"' % \ + details = 'cx="%f" cy="%f" rx="%f" ry="%f" transform="rotate(%1.1f %f %f)"' % \ (x, self.height-y, width/2.0, height/2.0, -rotation, x, self.height-y) self._draw_svg_element('ellipse', details, gc, rgbFace) @@ -214,7 +214,7 @@ trans[4] += trans[0] trans[5] += trans[3] trans[5] = -trans[5] - transstr = 'transform="matrix(%s %s %s %s %s %s)" '%tuple(trans) + transstr = 'transform="matrix(%f %f %f %f %f %f)" '%tuple(trans) assert trans[1] == 0 assert trans[2] == 0 numrows,numcols = im.get_size() @@ -258,12 +258,12 @@ hrefstr = filename self._svgwriter.write ( - '<image x="%s" y="%s" width="%s" height="%s" ' + '<image x="%f" y="%f" width="%f" height="%f" ' 'xlink:href="%s" %s/>\n'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, hrefstr, transstr) ) def draw_line(self, gc, x1, y1, x2, y2): - details = 'd="M%s,%sL%s,%s"' % (x1, self.height-y1, + details = 'd="M%f,%fL%f,%f"' % (x1, self.height-y1, x2, self.height-y2) self._draw_svg_element('path', details, gc, None) @@ -273,9 +273,9 @@ raise ValueError('x and y must be the same length') y = self.height - y - details = ['d="M%s,%s' % (x[0], y[0])] + details = ['d="M%f,%f' % (x[0], y[0])] xys = zip(x[1:], y[1:]) - details.extend(['L%s,%s' % tup for tup in xys]) + details.extend(['L%f,%f' % tup for tup in xys]) details.append('"') details = ''.join(details) self._draw_svg_element('path', details, gc, None) @@ -285,12 +285,12 @@ self.draw_arc(gc, gc.get_rgb(), x, y, 1, 0, 0, 0, 0) def draw_polygon(self, gc, rgbFace, points): - details = 'points = "%s"' % ' '.join(['%s,%s'%(x,self.height-y) + details = 'points = "%s"' % ' '.join(['%f,%f'%(x,self.height-y) for x, y in points]) self._draw_svg_element('polygon', details, gc, rgbFace) def draw_rectangle(self, gc, rgbFace, x, y, width, height): - details = 'width="%s" height="%s" x="%s" y="%s"' % (width, height, x, + details = 'width="%f" height="%f" x="%f" y="%f"' % (width, height, x, self.height-y-height) self._draw_svg_element('rect', details, gc, rgbFace) @@ -319,12 +319,12 @@ write(path) write('</defs>\n') - svg = ['<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())] + svg = ['<g style="fill: %s; opacity: %f" transform="' % (color, gc.get_alpha())] if angle != 0: - svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle)) + svg.append('translate(%f,%f)rotate(%1.1f)' % (x,y,-angle)) elif x != 0 or y != 0: - svg.append('translate(%s,%s)' % (x, y)) - svg.append('scale(%s)">\n' % (fontsize / self.FONT_SCALE)) + svg.append('translate(%f,%f)' % (x, y)) + svg.append('scale(%f)">\n' % (fontsize / self.FONT_SCALE)) cmap = font.get_charmap() lastgind = None @@ -347,7 +347,7 @@ svg.append('<use xlink:href="#%s"' % charnum) if currx != 0: - svg.append(' transform="translate(%s)"' % + svg.append(' transform="translate(%f)"' % (currx * (self.FONT_SCALE / fontsize))) svg.append('/>\n') currx += (glyph.linearHoriAdvance / 65536.0) / (self.FONT_SCALE / fontsize) @@ -358,16 +358,16 @@ fontfamily = font.family_name fontstyle = prop.get_style() - style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %s' % + style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %f' % (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) + transform = 'transform="translate(%f,%f) rotate(%1.1f) translate(%f,%f)"' % (x,y,-angle,-x,-y) # Inkscape doesn't support rotate(angle x y) else: transform = '' svg = """\ -<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text> +<text style="%(style)s" x="%(x)f" y="%(y)f" %(transform)s>%(thetext)s</text> """ % locals() write(svg) @@ -389,17 +389,17 @@ currx, curry = 0.0, 0.0 for step in glyph.path: if step[0] == 0: # MOVE_TO - path_data.append("M%s %s" % + path_data.append("M%f %f" % (step[1], -step[2])) elif step[0] == 1: # LINE_TO - path_data.append("l%s %s" % + path_data.append("l%f %f" % (step[1] - currx, -step[2] - curry)) elif step[0] == 2: # CURVE3 - path_data.append("q%s %s %s %s" % + path_data.append("q%f %f %f %f" % (step[1] - currx, -step[2] - curry, step[3] - currx, -step[4] - curry)) elif step[0] == 3: # CURVE4 - path_data.append("c%s %s %s %s %s %s" % + path_data.append("c%f %f %f %f %f %f" % (step[1] - currx, -step[2] - curry, step[3] - currx, -step[4] - curry, step[5] - currx, -step[6] - curry)) @@ -453,16 +453,16 @@ svg = ['<g style="%s" transform="' % style] if angle != 0: - svg.append('translate(%s,%s)rotate(%1.1f)' + svg.append('translate(%f,%f)rotate(%1.1f)' % (x,y,-angle) ) else: - svg.append('translate(%s,%s)' % (x, y)) + svg.append('translate(%f,%f)' % (x, y)) svg.append('">\n') for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: charid = self._get_char_def_id(font, thetext) - svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' % + svg.append('<use xlink:href="#%s" transform="translate(%f,%f)scale(%f)"/>\n' % (charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE)) svg.append('</g>\n') else: # not rcParams['svg.embed_char_paths'] @@ -481,15 +481,15 @@ svg.append('<tspan style="%s"' % style) xadvance = metrics.advance - svg.append(' textLength="%s"' % xadvance) + svg.append(' textLength="%f"' % xadvance) dx = new_x - curr_x if dx != 0.0: - svg.append(' dx="%s"' % dx) + svg.append(' dx="%f"' % dx) dy = new_y - curr_y if dy != 0.0: - svg.append(' dy="%s"' % dy) + svg.append(' dy="%f"' % dy) thetext = escape_xml_text(thetext) @@ -504,14 +504,14 @@ style = "fill: %s; stroke: none" % color svg.append('<g style="%s" transform="' % style) if angle != 0: - svg.append('translate(%s,%s) rotate(%1.1f)' + svg.append('translate(%f,%f) rotate(%1.1f)' % (x,y,-angle) ) else: - svg.append('translate(%s,%s)' % (x, y)) + svg.append('translate(%f,%f)' % (x, y)) svg.append('">\n') for x, y, width, height in svg_rects: - svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height)) + svg.append('<rect x="%f" y="%f" width="%f" height="%f" fill="black" stroke="none" />' % (x, -y + height, width, height)) svg.append("</g>") self.open_group("mathtext") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-25 22:14:40
|
Revision: 6049 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6049&view=rev Author: mdboom Date: 2008-08-25 22:14:33 +0000 (Mon, 25 Aug 2008) Log Message: ----------- Fix locale problems in SVG backend (thanks, Mathieu Leplatre for reporting) Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-22 19:19:29 UTC (rev 6048) +++ trunk/matplotlib/CHANGELOG 2008-08-25 22:14:33 UTC (rev 6049) @@ -1,3 +1,5 @@ +2008-08-25 Fix locale problems in SVG backend - MGD + 2008-08-22 fix quiver so masked values are not plotted - JSW 2008-08-18 improve interactive pan/zoom in qt4 backend on windows - DSD Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-22 19:19:29 UTC (rev 6048) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-25 22:14:33 UTC (rev 6049) @@ -96,13 +96,13 @@ if seq is None: dashes = '' else: - dashes = 'stroke-dasharray: %s; stroke-dashoffset: %s;' % ( - ','.join(['%s'%val for val in seq]), offset) + dashes = 'stroke-dasharray: %s; stroke-dashoffset: %f;' % ( + ','.join(['%f'%val for val in seq]), offset) linewidth = gc.get_linewidth() if linewidth: - return 'fill: %s; stroke: %s; stroke-width: %s; ' \ - 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %s' % ( + return 'fill: %s; stroke: %s; stroke-width: %f; ' \ + 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %f' % ( fill, rgb2hex(gc.get_rgb()[:3]), linewidth, @@ -112,7 +112,7 @@ gc.get_alpha(), ) else: - return 'fill: %s; opacity: %s' % (\ + return 'fill: %s; opacity: %f' % (\ fill, gc.get_alpha(), ) @@ -126,7 +126,7 @@ elif cliprect is not None: x, y, w, h = cliprect.bounds y = self.height-(y+h) - path = '<rect x="%(x)s" y="%(y)s" width="%(w)s" height="%(h)s"/>' % locals() + path = '<rect x="%(x)f" y="%(y)f" width="%(w)f" height="%(h)f"/>' % locals() else: return None @@ -153,10 +153,10 @@ return rcParams['svg.image_noscale'] _path_commands = { - Path.MOVETO: 'M%s %s', - Path.LINETO: 'L%s %s', - Path.CURVE3: 'Q%s %s %s %s', - Path.CURVE4: 'C%s %s %s %s %s %s' + Path.MOVETO: 'M%f %f', + Path.LINETO: 'L%f %f', + Path.CURVE3: 'Q%f %f %f %f', + Path.CURVE4: 'C%f %f %f %f %f %f' } def _make_flip_transform(self, transform): @@ -258,7 +258,7 @@ trans[4] += trans[0] trans[5] += trans[3] trans[5] = -trans[5] - transstr = 'transform="matrix(%s %s %s %s %s %s)" '%tuple(trans) + transstr = 'transform="matrix(%f %f %f %f %f %f)" '%tuple(trans) assert trans[1] == 0 assert trans[2] == 0 numrows,numcols = im.get_size() @@ -269,7 +269,7 @@ h,w = im.get_size_out() self._svgwriter.write ( - '<image x="%s" y="%s" width="%s" height="%s" ' + '<image x="%f" y="%f" width="%f" height="%f" ' '%s xlink:href="'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, transstr) ) @@ -323,12 +323,12 @@ if clipid is not None: svg.append('<g clip-path="url(#%s)">\n' % clipid) - svg.append('<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())) + svg.append('<g style="fill: %s; opacity: %f" transform="' % (color, gc.get_alpha())) if angle != 0: - svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle)) + svg.append('translate(%f,%f)rotate(%1.1f)' % (x,y,-angle)) elif x != 0 or y != 0: - svg.append('translate(%s,%s)' % (x, y)) - svg.append('scale(%s)">\n' % (fontsize / self.FONT_SCALE)) + svg.append('translate(%f,%f)' % (x, y)) + svg.append('scale(%f)">\n' % (fontsize / self.FONT_SCALE)) cmap = font.get_charmap() lastgind = None @@ -350,7 +350,7 @@ svg.append('<use xlink:href="#%s"' % charnum) if currx != 0: - svg.append(' x="%s"' % + svg.append(' x="%f"' % (currx * (self.FONT_SCALE / fontsize))) svg.append('/>\n') @@ -365,16 +365,16 @@ fontfamily = font.family_name fontstyle = prop.get_style() - style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %s' % + style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %f' % (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) + transform = 'transform="translate(%f,%f) rotate(%1.1f) translate(%f,%f)"' % (x,y,-angle,-x,-y) # Inkscape doesn't support rotate(angle x y) else: transform = '' svg = """\ -<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text> +<text style="%(style)s" x="%(x)f" y="%(y)f" %(transform)s>%(thetext)s</text> """ % locals() write(svg) @@ -396,17 +396,17 @@ currx, curry = 0.0, 0.0 for step in glyph.path: if step[0] == 0: # MOVE_TO - path_data.append("M%s %s" % + path_data.append("M%f %f" % (step[1], -step[2])) elif step[0] == 1: # LINE_TO - path_data.append("l%s %s" % + path_data.append("l%f %f" % (step[1] - currx, -step[2] - curry)) elif step[0] == 2: # CURVE3 - path_data.append("q%s %s %s %s" % + path_data.append("q%f %f %f %f" % (step[1] - currx, -step[2] - curry, step[3] - currx, -step[4] - curry)) elif step[0] == 3: # CURVE4 - path_data.append("c%s %s %s %s %s %s" % + path_data.append("c%f %f %f %f %f %f" % (step[1] - currx, -step[2] - curry, step[3] - currx, -step[4] - curry, step[5] - currx, -step[6] - curry)) @@ -460,16 +460,16 @@ svg = ['<g style="%s" transform="' % style] if angle != 0: - svg.append('translate(%s,%s)rotate(%1.1f)' + svg.append('translate(%f,%f)rotate(%1.1f)' % (x,y,-angle) ) else: - svg.append('translate(%s,%s)' % (x, y)) + svg.append('translate(%f,%f)' % (x, y)) svg.append('">\n') for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: charid = self._get_char_def_id(font, thetext) - svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' % + svg.append('<use xlink:href="#%s" transform="translate(%f,%f)scale(%f)"/>\n' % (charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE)) svg.append('</g>\n') else: # not rcParams['svg.embed_char_paths'] @@ -488,15 +488,15 @@ svg.append('<tspan style="%s"' % style) xadvance = metrics.advance - svg.append(' textLength="%s"' % xadvance) + svg.append(' textLength="%f"' % xadvance) dx = new_x - curr_x if dx != 0.0: - svg.append(' dx="%s"' % dx) + svg.append(' dx="%f"' % dx) dy = new_y - curr_y if dy != 0.0: - svg.append(' dy="%s"' % dy) + svg.append(' dy="%f"' % dy) thetext = escape_xml_text(thetext) @@ -511,14 +511,14 @@ style = "fill: %s; stroke: none" % color svg.append('<g style="%s" transform="' % style) if angle != 0: - svg.append('translate(%s,%s) rotate(%1.1f)' + svg.append('translate(%f,%f) rotate(%1.1f)' % (x,y,-angle) ) else: - svg.append('translate(%s,%s)' % (x, y)) + svg.append('translate(%f,%f)' % (x, y)) svg.append('">\n') for x, y, width, height in svg_rects: - svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height)) + svg.append('<rect x="%f" y="%f" width="%f" height="%f" fill="black" stroke="none" />' % (x, -y + height, width, height)) svg.append("</g>") self.open_group("mathtext") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-22 19:19:31
|
Revision: 6048 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6048&view=rev Author: jswhit Date: 2008-08-22 19:19:29 +0000 (Fri, 22 Aug 2008) Log Message: ----------- fix quiver so masked values not plotted. Modified Paths: -------------- trunk/matplotlib/CHANGELOG Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-22 19:19:07 UTC (rev 6047) +++ trunk/matplotlib/CHANGELOG 2008-08-22 19:19:29 UTC (rev 6048) @@ -1,3 +1,5 @@ +2008-08-22 fix quiver so masked values are not plotted - JSW + 2008-08-18 improve interactive pan/zoom in qt4 backend on windows - DSD 2008-08-11 Fix more bugs in NaN/inf handling. In particular, path simplification This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-22 19:19:09
|
Revision: 6047 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6047&view=rev Author: jswhit Date: 2008-08-22 19:19:07 +0000 (Fri, 22 Aug 2008) Log Message: ----------- fix quiver so masked values are not plotted. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/quiver_demo.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/examples/pylab_examples/quiver_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/quiver_demo.py 2008-08-21 15:29:12 UTC (rev 6046) +++ trunk/matplotlib/examples/pylab_examples/quiver_demo.py 2008-08-22 19:19:07 UTC (rev 6047) @@ -9,6 +9,7 @@ ''' from pylab import * +from numpy import ma X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) ) U = cos(X) @@ -64,6 +65,20 @@ axis([-1, 7, -1, 7]) title("triangular head; scale with x view; black edges") +#6 +figure() +M = zeros(U.shape, dtype='bool') +M[U.shape[0]/3:2*U.shape[0]/3,U.shape[1]/3:2*U.shape[1]/3] = True +U = ma.masked_array(U, mask=M) +V = ma.masked_array(V, mask=M) +Q = quiver( U, V) +qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W', + fontproperties={'weight': 'bold'}) +l,r,b,t = axis() +dx, dy = r-l, t-b +axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy]) +title('Minimal arguments, no kwargs - masked values') + show() Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-21 15:29:12 UTC (rev 6046) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-22 19:19:07 UTC (rev 6047) @@ -334,6 +334,12 @@ def __init__(self, ax, *args, **kw): self.ax = ax X, Y, U, V, C = self._parse_args(*args) + if C is not None: + X, Y, U, V, C = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), + V.ravel(),C.ravel()) + else: + X, Y, U, V = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), + V.ravel()) self.X = X self.Y = Y self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mme...@us...> - 2008-08-21 15:29:16
|
Revision: 6046 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6046&view=rev Author: mmetz_bn Date: 2008-08-21 15:29:12 +0000 (Thu, 21 Aug 2008) Log Message: ----------- import warnings; close bug # 2053683 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-08-19 11:58:23 UTC (rev 6045) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-08-21 15:29:12 UTC (rev 6046) @@ -5,6 +5,7 @@ from __future__ import generators import re, os, errno, sys, StringIO, traceback, locale, threading, types import time, datetime +import warnings import numpy as np import numpy.ma as ma from weakref import ref This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-19 11:58:26
|
Revision: 6045 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6045&view=rev Author: jswhit Date: 2008-08-19 11:58:23 +0000 (Tue, 19 Aug 2008) Log Message: ----------- update Modified Paths: -------------- trunk/toolkits/basemap/doc/users/graticule.rst Modified: trunk/toolkits/basemap/doc/users/graticule.rst =================================================================== --- trunk/toolkits/basemap/doc/users/graticule.rst 2008-08-19 09:35:03 UTC (rev 6044) +++ trunk/toolkits/basemap/doc/users/graticule.rst 2008-08-19 11:58:23 UTC (rev 6045) @@ -8,6 +8,13 @@ :func:`~mpl_toolkits.basemap.Basemap.drawparallels` and :func:`~mpl_toolkits.basemap.Basemap.drawmeridians` instance methods. The longitude and latitude lines can be labelled where they -the map projection boundary. +the map projection boundary. There are four exceptions: meridians +and parallels cannot be labelled on maps with +``proj`` set to ``ortho`` (orthographic projection), +and meridians cannot be labelled on maps with +``proj`` set to ``robin`` (robinson), ``moll`` (mollweide) or ``sinu`` +(sinusoidal). This is because the lines can be very close +together where they intersect the boundary on these maps, so that +they really need to be labelled on the interior of the plot. .. toctree:: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fer...@us...> - 2008-08-19 09:35:08
|
Revision: 6044 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6044&view=rev Author: fer_perez Date: 2008-08-19 09:35:03 +0000 (Tue, 19 Aug 2008) Log Message: ----------- Update examples and skeletons in py4science. - Fixes after previous feedback so they are all syntactically correct. - Switch to using nose instead of unittest for an eaiser workflow. Modified Paths: -------------- trunk/py4science/examples/fft_imdenoise.py trunk/py4science/examples/qsort.py trunk/py4science/examples/skel/fft_imdenoise_skel.py trunk/py4science/examples/skel/qsort_skel.py trunk/py4science/examples/skel/trapezoid_skel.py trunk/py4science/examples/skel/wallis_pi_skel.py trunk/py4science/examples/skel/wordfreqs_skel.py trunk/py4science/examples/trapezoid.py Modified: trunk/py4science/examples/fft_imdenoise.py =================================================================== --- trunk/py4science/examples/fft_imdenoise.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/fft_imdenoise.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -20,58 +20,64 @@ print M.shape, M.dtype plt.imshow(M, plt.cm.Blues) -try: - # Read in original image, convert to floating point for further - # manipulation; imread returns a MxNx4 RGBA image. Since the - # image is grayscale, just extrac the 1st channel - im = plt.imread('data/moonlanding.png').astype(float)[:,:,0] -except: - print "Could not open image." - sys.exit(-1) -# Compute the 2d FFT of the input image -F = np.fft.fft2(im) +if __name__ == '__main__': -# Now, make a copy of the original spectrum and truncate coefficients. -keep_fraction = 0.1 + try: + # Read in original image, convert to floating point for further + # manipulation; imread returns a MxNx4 RGBA image. Since the image is + # grayscale, just extrac the 1st channel + im = plt.imread('data/moonlanding.png').astype(float)[:,:,0] + except: + print "Could not open image." + sys.exit(-1) -# Call ff a copy of the original transform. Numpy arrays have a copy method -# for this purpose. -ff = F.copy() + # Compute the 2d FFT of the input image + F = np.fft.fft2(im) -# Set r and c to be the number of rows and columns of the array. -r,c = ff.shape + # Now, make a copy of the original spectrum and truncate coefficients. + keep_fraction = 0.1 -# Set to zero all rows with indices between r*keep_fraction and -# r*(1-keep_fraction): -ff[r*keep_fraction:r*(1-keep_fraction)] = 0 + # Call ff a copy of the original transform. Numpy arrays have a copy + # method for this purpose. + ff = F.copy() -# Similarly with the columns: -ff[:, c*keep_fraction:c*(1-keep_fraction)] = 0 + # Set r and c to be the number of rows and columns of the array. + r,c = ff.shape -# Reconstruct the denoised image from the filtered spectrum, keep only the real -# part for display -im_new = np.fft.ifft2(ff).real + # Set to zero all rows with indices between r*keep_fraction and + # r*(1-keep_fraction): + ff[r*keep_fraction:r*(1-keep_fraction)] = 0 -# Show the results -plt.figure() + # Similarly with the columns: + ff[:, c*keep_fraction:c*(1-keep_fraction)] = 0 -plt.subplot(221) -plt.title('Original image') -plt.imshow(im, plt.cm.gray) + # Reconstruct the denoised image from the filtered spectrum, keep only the + # real part for display + im_new = np.fft.ifft2(ff).real -plt.subplot(222) -plt.title('Fourier transform') -plot_spectrum(F) + # Show the results + plt.figure() -plt.subplot(224) -plt.title('Filtered Spectrum') -plot_spectrum(ff) + plt.subplot(221) + plt.title('Original image') + plt.imshow(im, plt.cm.gray) -plt.subplot(223) -plt.title('Reconstructed Image') -plt.imshow(im_new, plt.cm.gray) + plt.subplot(222) + plt.title('Fourier transform') + plot_spectrum(F) -plt.savefig('fft_imdenoise.png', dpi=150) -plt.savefig('fft_imdenoise.eps') -plt.show() + plt.subplot(224) + plt.title('Filtered Spectrum') + plot_spectrum(ff) + + plt.subplot(223) + plt.title('Reconstructed Image') + plt.imshow(im_new, plt.cm.gray) + + plt.savefig('fft_imdenoise.png', dpi=150) + plt.savefig('fft_imdenoise.eps') + + # Adjust the spacing between subplots for readability + plt.subplots_adjust(hspace=0.32) + plt.show() Modified: trunk/py4science/examples/qsort.py =================================================================== --- trunk/py4science/examples/qsort.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/qsort.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -18,22 +18,28 @@ return qsort(less_than) + [pivot] + qsort(greater_equal) -if __name__ == '__main__': - from unittest import main, TestCase - import random - class qsortTestCase(TestCase): - def test_sorted(self): - seq = range(10) - sseq = qsort(seq) - self.assertEqual(seq,sseq) +#----------------------------------------------------------------------------- +# Tests +#----------------------------------------------------------------------------- +import random - def test_random(self): - tseq = range(10) - rseq = range(10) - random.shuffle(rseq) - sseq = qsort(rseq) - print tseq - print sseq - self.assertEqual(tseq,sseq) - main() +import nose, nose.tools as nt + +def test_sorted(): + seq = range(10) + sseq = qsort(seq) + nt.assert_equal(seq,sseq) + +def test_random(): + tseq = range(10) + rseq = range(10) + random.shuffle(rseq) + sseq = qsort(rseq) + nt.assert_equal(tseq,sseq) + +# If called from the command line, run all the tests +if __name__ == '__main__': + # This call form is ipython-friendly + nose.runmodule(argv=['-s','--with-doctest'], + exit=False) Modified: trunk/py4science/examples/skel/fft_imdenoise_skel.py =================================================================== --- trunk/py4science/examples/skel/fft_imdenoise_skel.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/skel/fft_imdenoise_skel.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -1,10 +1,11 @@ #!/usr/bin/env python """Image denoising example using 2-dimensional FFT.""" -import numpy as N -import pylab as P -import scipy as S +XXX = None # a sentinel for missing pieces +import numpy as np +from matplotlib import pyplot as plt + def mag_phase(F): """Return magnitude and phase components of spectrum F.""" @@ -13,7 +14,7 @@ def plot_spectrum(F, amplify=1000): """Normalise, amplify and plot an amplitude spectrum.""" - M = # XXX use mag_phase to get the magnitude... + M = XXX # use mag_phase to get the magnitude... # XXX Now, rescale M by amplify/maximum_of_M. Numpy arrays can be scaled # in-place with ARR *= number. For the max of an array, look for its max @@ -25,56 +26,58 @@ # Display: this one already works, if you did everything right with M - P.imshow(M, P.cm.Blues) + plt.imshow(M, plt.cm.Blues) -# 'main' script +if __name__ == '__main__': + im = XXX # make an image array from the file 'moonlanding.png', using the + # pylab imread() function. You will need to just extract the red + # channel from the MxNx4 RGBA matrix to represent the grayscale + # intensities -im = # XXX make an image array from the file 'moonlanding.png', using the - # pylab imread() function. You will need to just extract the red - # channel from the MxNx4 RGBA matrix to represent the grayscale - # intensities + F = XXX # Compute the 2d FFT of the input image. Look for a 2-d FFT in + # np.fft. -F = # Compute the 2d FFT of the input image. Look for a 2-d FFT in N.fft. + # Define the fraction of coefficients (in each direction) we keep + keep_fraction = 0.1 -# Define the fraction of coefficients (in each direction) we keep -keep_fraction = 0.1 + # XXX Call ff a copy of the original transform. Numpy arrays have a copy + # method for this purpose. -# XXX Call ff a copy of the original transform. Numpy arrays have a copy method -# for this purpose. + # XXX Set r and c to be the number of rows and columns of the array. Look + # for the shape attribute... -# XXX Set r and c to be the number of rows and columns of the array. Look for -# the shape attribute... + # Set to zero all rows with indices between r*keep_fraction and + # r*(1-keep_fraction): -# Set to zero all rows with indices between r*keep_fraction and -# r*(1-keep_fraction): + # Similarly with the columns: -# Similarly with the columns: + # Reconstruct the denoised image from the filtered spectrum. There's an + # inverse 2d fft in the dft module as well. Call the result im_new -# Reconstruct the denoised image from the filtered spectrum. There's an -# inverse 2d fft in the dft module as well. Call the result im_new + # Show the results. -# Show the results. + # The code below already works, if you did everything above right. + plt.figure() -# The code below already works, if you did everything above right. -P.figure() + plt.subplot(221) + plt.title('Original image') + plt.imshow(im, plt.cm.gray) -P.subplot(221) -P.title('Original image') -P.imshow(im, P.cm.gray) + plt.subplot(222) + plt.title('Fourier transform') + plot_spectrum(F) -P.subplot(222) -P.title('Fourier transform') -plot_spectrum(F) + plt.subplot(224) + plt.title('Filtered Spectrum') + plot_spectrum(ff) -P.subplot(224) -P.title('Filtered Spectrum') -plot_spectrum(ff) + plt.subplot(223) + plt.title('Reconstructed Image') + plt.imshow(im_new, plt.cm.gray) -P.subplot(223) -P.title('Reconstructed Image') -P.imshow(im_new, P.cm.gray) - -P.show() + # Adjust the spacing between subplots for readability + plt.subplots_adjust(hspace=0.32) + plt.show() Modified: trunk/py4science/examples/skel/qsort_skel.py =================================================================== --- trunk/py4science/examples/skel/qsort_skel.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/skel/qsort_skel.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -1,24 +1,45 @@ -"""Simple quicksort implementation.""" +"""Simple quicksort implementation. +From http://en.wikipedia.org/wiki/Quicksort: + +function quicksort(array) + var list less, greater + if length(array) ≤ 1 + return array + select and remove a pivot value pivot from array + for each x in array + if x ≤ pivot then append x to less + else append x to greater + return concatenate(quicksort(less), pivot, quicksort(greater)) +""" + def qsort(lst): """Return a sorted copy of the input list.""" raise NotImplementedError -if __name__ == '__main__': - from unittest import main, TestCase - import random +#----------------------------------------------------------------------------- +# Tests +#----------------------------------------------------------------------------- +import random - class qsortTestCase(TestCase): - def test_sorted(self): - seq = range(10) - sseq = qsort(seq) - self.assertEqual(seq,sseq) +import nose.tools as nt - def test_random(self): - tseq = range(10) - rseq = range(10) - random.shuffle(rseq) - sseq = qsort(rseq) - self.assertEqual(tseq,sseq) - main() +def test_sorted(): + seq = range(10) + sseq = qsort(seq) + nt.assert_equal(seq,sseq) + +def test_random(): + tseq = range(10) + rseq = range(10) + random.shuffle(rseq) + sseq = qsort(rseq) + nt.assert_equal(tseq,sseq) + +if __name__ == '__main__': + # From the command line, run the test suite + import nose + # This call form is ipython-friendly + nose.runmodule(argv=['-s','--with-doctest'], + exit=False) Modified: trunk/py4science/examples/skel/trapezoid_skel.py =================================================================== --- trunk/py4science/examples/skel/trapezoid_skel.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/skel/trapezoid_skel.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -39,29 +39,32 @@ # x? raise NotImplementedError -if __name__ == '__main__': - # Simple tests for trapezoid integrator, when this module is called as a - # script from the command line. - import unittest - import numpy.testing as ntest +#----------------------------------------------------------------------------- +# Tests +#----------------------------------------------------------------------------- +import nose, nose.tools as nt +import numpy.testing as nptest - def square(x): return x**2 +def square(x): return x**2 - class trapzTestCase(unittest.TestCase): - def test_err(self): - self.assertRaises(ValueError,trapz,range(2),range(3)) +def test_err(): + nt.assert_raises(ValueError,trapz,range(2),range(3)) - def test_call(self): - x = N.linspace(0,1,100) - y = N.array(map(square,x)) - ntest.assert_almost_equal(trapz(x,y),1./3,4) +def test_call(): + x = np.linspace(0,1,100) + y = np.array(map(square,x)) + nptest.assert_almost_equal(trapz(x,y),1./3,4) - class trapzfTestCase(unittest.TestCase): - def test_square(self): - ntest.assert_almost_equal(trapzf(square,0,1),1./3,4) +def test_square(): + nptest.assert_almost_equal(trapzf(square,0,1),1./3,4) - def test_square2(self): - ntest.assert_almost_equal(trapzf(square,0,3,350),9.0,4) +def test_square2(): + nptest.assert_almost_equal(trapzf(square,0,3,350),9.0,4) - unittest.main() + +# If called from the command line, run all the tests +if __name__ == '__main__': + # This call form is ipython-friendly + nose.runmodule(argv=['-s','--with-doctest'], + exit=False) Modified: trunk/py4science/examples/skel/wallis_pi_skel.py =================================================================== --- trunk/py4science/examples/skel/wallis_pi_skel.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/skel/wallis_pi_skel.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -8,6 +8,8 @@ from decimal import Decimal +XXX = None # a sentinel for missing pieces + def pi(n): """Compute pi using n terms of Wallis' product. @@ -15,7 +17,7 @@ pi(n) = 2 \prod_{i=1}^{n}\frac{4i^2}{4i^2-1}.""" - XXX + raise NotImplementedError # This part only executes when the code is run as a script, not when it is # imported as a library Modified: trunk/py4science/examples/skel/wordfreqs_skel.py =================================================================== --- trunk/py4science/examples/skel/wordfreqs_skel.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/skel/wordfreqs_skel.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -1,10 +1,14 @@ #!/usr/bin/env python """Word frequencies - count word frequencies in a string.""" +XXX = None # a sentinel for missing pieces + def word_freq(text): """Return a dictionary of word frequencies for the given text.""" - # XXX you need to write this + # you need to write this + return XXX + def print_vk(lst): """Print a list of value/key pairs nicely formatted in key/value order.""" @@ -17,6 +21,7 @@ for v,k in lst: print fmt % (k,v) + def freq_summ(freqs,n=10): """Print a simple summary of a word frequencies dictionary. @@ -26,10 +31,10 @@ Optional inputs: - n: the number of items to print""" - words,counts = # XXX look at the keys and values methods of dicts + words,counts = XXX # look at the keys and values methods of dicts # Sort by count - items = # XXX think of a list, look at zip() and think of sort() + items = XXX # think of a list, look at zip() and think of sort() print 'Number of words:',len(freqs) print @@ -39,10 +44,12 @@ print '%d most frequent words:' % n print_vk(items[-n:]) + if __name__ == '__main__': - text = # XXX - # You need to read the contents of the file HISTORY.gz. Do NOT unzip it - # manually, look at the gzip module from the standard library and the - # read() method of file objects. + # You need to read the contents of the file HISTORY.gz and store it in the + # variable named 'text'. Do NOT unzip it manually, look at the gzip module + # from the standard library and the read() method of file objects. + text = XXX + freqs = word_freq(text) freq_summ(freqs,20) Modified: trunk/py4science/examples/trapezoid.py =================================================================== --- trunk/py4science/examples/trapezoid.py 2008-08-18 21:06:56 UTC (rev 6043) +++ trunk/py4science/examples/trapezoid.py 2008-08-19 09:35:03 UTC (rev 6044) @@ -1,7 +1,7 @@ #!/usr/bin/env python """Simple trapezoid-rule integrator.""" -import numpy as N +import numpy as np def trapz(x, y): """Simple trapezoid integrator for sequence-based innput. @@ -40,43 +40,41 @@ - The value of the trapezoid-rule approximation to the integral.""" # Generate an equally spaced grid to sample the function at - x = N.linspace(a,b,npts) + x = np.linspace(a,b,npts) # For an equispaced grid, the x spacing can just be read off from the first # two points and factored out of the summation. dx = x[1]-x[0] # Sample the input function at all values of x - y = N.array(map(f,x)) + y = np.array(map(f,x)) # Compute the trapezoid rule sum for the final result return 0.5*dx*(y[1:]+y[:-1]).sum() -if __name__ == '__main__': - # Simple tests for trapezoid integrator, when this module is called as a - # script from the command line. From ipython, run it via: - # - # run -e trapezoid - # - # so that ipython ignores the SystemExit exception automatically raised by - # the unittest module at the end. - import unittest - import numpy.testing as ntest +#----------------------------------------------------------------------------- +# Tests +#----------------------------------------------------------------------------- +import nose, nose.tools as nt +import numpy.testing as nptest - def square(x): return x**2 +def square(x): return x**2 - class trapzTestCase(unittest.TestCase): - def test_err(self): - self.assertRaises(ValueError,trapz,range(2),range(3)) +def test_err(): + nt.assert_raises(ValueError,trapz,range(2),range(3)) - def test_call(self): - x = N.linspace(0,1,100) - y = N.array(map(square,x)) - ntest.assert_almost_equal(trapz(x,y),1./3,4) +def test_call(): + x = np.linspace(0,1,100) + y = np.array(map(square,x)) + nptest.assert_almost_equal(trapz(x,y),1./3,4) - class trapzfTestCase(unittest.TestCase): - def test_square(self): - ntest.assert_almost_equal(trapzf(square,0,1),1./3,4) +def test_square(): + nptest.assert_almost_equal(trapzf(square,0,1),1./3,4) - def test_square2(self): - ntest.assert_almost_equal(trapzf(square,0,3,350),9.0,4) +def test_square2(): + nptest.assert_almost_equal(trapzf(square,0,3,350),9.0,4) - unittest.main() + +# If called from the command line, run all the tests +if __name__ == '__main__': + # This call form is ipython-friendly + nose.runmodule(argv=['-s','--with-doctest'], + exit=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2008-08-18 21:07:04
|
Revision: 6043 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6043&view=rev Author: dsdale Date: 2008-08-18 21:06:56 +0000 (Mon, 18 Aug 2008) Log Message: ----------- improved interactive pan/zoom in qt4agg backend on windows Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-08-18 20:18:56 UTC (rev 6042) +++ trunk/matplotlib/CHANGELOG 2008-08-18 21:06:56 UTC (rev 6043) @@ -1,3 +1,5 @@ +2008-08-18 improve interactive pan/zoom in qt4 backend on windows - DSD + 2008-08-11 Fix more bugs in NaN/inf handling. In particular, path simplification (which does not handle NaNs or infs) will be turned off automatically when infs or NaNs are present. Also masked arrays are now converted Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-08-18 20:18:56 UTC (rev 6042) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-08-18 21:06:56 UTC (rev 6043) @@ -132,6 +132,8 @@ self.replot = True FigureCanvasAgg.draw(self) self.update() + # Added following line to improve realtime pan/zoom on windows: + QtGui.qApp.processEvents() def blit(self, bbox=None): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2008-08-18 20:19:03
|
Revision: 6042 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6042&view=rev Author: efiring Date: 2008-08-18 20:18:56 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Fix bug introduced in 6033, reported by Jae-Joon Lee Modified Paths: -------------- trunk/matplotlib/src/agg_py_path_iterator.h Modified: trunk/matplotlib/src/agg_py_path_iterator.h =================================================================== --- trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-18 14:43:13 UTC (rev 6041) +++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-18 20:18:56 UTC (rev 6042) @@ -39,7 +39,7 @@ (codes_obj.ptr(), PyArray_UINT8, 1, 1); if (!m_codes) throw Py::ValueError("Invalid codes array."); - if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 1)) + if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0)) throw Py::ValueError("Codes array is wrong length"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-18 14:43:16
|
Revision: 6041 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6041&view=rev Author: jswhit Date: 2008-08-18 14:43:13 +0000 (Mon, 18 Aug 2008) Log Message: ----------- another minor tweak Modified Paths: -------------- trunk/toolkits/basemap/examples/cubed_sphere.py Modified: trunk/toolkits/basemap/examples/cubed_sphere.py =================================================================== --- trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-18 11:44:30 UTC (rev 6040) +++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-18 14:43:13 UTC (rev 6041) @@ -23,10 +23,10 @@ rsphere=rsphere) m.bluemarble() m.drawparallels(np.arange(-90,91,10),color='0.5') - m.drawmeridians(np.arange(0,360,10),color='0.5') + m.drawmeridians(np.arange(5,365,10),color='0.5') #m.drawlsmask(ocean_color='aqua',land_color='coral') #m.drawparallels(np.arange(-90,91,10)) - #m.drawmeridians(np.arange(0,360,10)) + #m.drawmeridians(np.arange(5,365,10)) fig.text (0.625,0.75,\ 'World Map on a Cube\n Gnomonic Projection',\ fontsize=14) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-18 11:44:34
|
Revision: 6040 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6040&view=rev Author: jswhit Date: 2008-08-18 11:44:30 +0000 (Mon, 18 Aug 2008) Log Message: ----------- minor tweaks Modified Paths: -------------- trunk/toolkits/basemap/examples/cubed_sphere.py Modified: trunk/toolkits/basemap/examples/cubed_sphere.py =================================================================== --- trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:56:20 UTC (rev 6039) +++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-18 11:44:30 UTC (rev 6040) @@ -6,7 +6,7 @@ # face with gnomonic projection. # http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html # suitable for cutting and folding. -fig = plt.figure(figsize=(8,6)) +fig = plt.figure(figsize=(10,7.5)) fig.subplots_adjust(bottom=0, left=0, right=1, top=1, wspace=0, hspace=0) rsphere = 6370997. width = 2.*rsphere; height=width @@ -14,20 +14,20 @@ for lat_0 in [90,0,-90]: for ncol in range(0,4): npanel = npanel + 1 - if lat_0 != 0 and ncol != 1: continue - ax=fig.add_subplot(3,4,npanel) - ax.set_frame_on(False) - lon_0=225 + 90*(ncol+1) - 45 - m = Basemap(width=width,height=height,resolution=None,\ - projection='gnom',lon_0=lon_0,lat_0=lat_0,\ - rsphere=rsphere) - m.bluemarble() - m.drawparallels(np.arange(-90,91,10),color='0.5') - m.drawmeridians(np.arange(0,360,10),color='0.5') - #m.drawlsmask(ocean_color='aqua',land_color='coral') - #m.drawparallels(np.arange(-90,91,10)) - #m.drawmeridians(np.arange(0,360,10)) -fig.text(0.625,0.75,\ - 'World Map on a Cube\n Gnomonic Projection',\ - fontsize=14) + if lat_0 == 0 or ncol == 1: + ax=fig.add_subplot(3,4,npanel) + ax.set_frame_on(False) + lon_0=225 + 90*(ncol+1) - 45 + m = Basemap(width=width,height=height,resolution=None,\ + projection='gnom',lon_0=lon_0,lat_0=lat_0,\ + rsphere=rsphere) + m.bluemarble() + m.drawparallels(np.arange(-90,91,10),color='0.5') + m.drawmeridians(np.arange(0,360,10),color='0.5') + #m.drawlsmask(ocean_color='aqua',land_color='coral') + #m.drawparallels(np.arange(-90,91,10)) + #m.drawmeridians(np.arange(0,360,10)) +fig.text (0.625,0.75,\ + 'World Map on a Cube\n Gnomonic Projection',\ + fontsize=14) plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-17 22:56:23
|
Revision: 6039 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6039&view=rev Author: jswhit Date: 2008-08-17 22:56:20 +0000 (Sun, 17 Aug 2008) Log Message: ----------- update Modified Paths: -------------- trunk/toolkits/basemap/examples/cubed_sphere.py Modified: trunk/toolkits/basemap/examples/cubed_sphere.py =================================================================== --- trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:17:56 UTC (rev 6038) +++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:56:20 UTC (rev 6039) @@ -24,6 +24,9 @@ m.bluemarble() m.drawparallels(np.arange(-90,91,10),color='0.5') m.drawmeridians(np.arange(0,360,10),color='0.5') + #m.drawlsmask(ocean_color='aqua',land_color='coral') + #m.drawparallels(np.arange(-90,91,10)) + #m.drawmeridians(np.arange(0,360,10)) fig.text(0.625,0.75,\ 'World Map on a Cube\n Gnomonic Projection',\ fontsize=14) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-17 22:18:00
|
Revision: 6038 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6038&view=rev Author: jswhit Date: 2008-08-17 22:17:56 +0000 (Sun, 17 Aug 2008) Log Message: ----------- added cubed_sphere.py example Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/MANIFEST.in trunk/toolkits/basemap/examples/README Added Paths: ----------- trunk/toolkits/basemap/examples/cubed_sphere.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008-08-16 22:48:18 UTC (rev 6037) +++ trunk/toolkits/basemap/Changelog 2008-08-17 22:17:56 UTC (rev 6038) @@ -1,4 +1,5 @@ version 0.99.2 (not yet released) + * added cubed_sphere example. * updated NetCDFFile to use pupynere 1.0.2 (now can write as well as read!). * now works with geos version 3. Modified: trunk/toolkits/basemap/MANIFEST.in =================================================================== --- trunk/toolkits/basemap/MANIFEST.in 2008-08-16 22:48:18 UTC (rev 6037) +++ trunk/toolkits/basemap/MANIFEST.in 2008-08-17 22:17:56 UTC (rev 6038) @@ -11,6 +11,7 @@ include setup.cfg include setupegg.py include src/* +include examples/cubed_sphere.py include examples/simpletest.py include examples/hires.py include examples/simpletest_oo.py Modified: trunk/toolkits/basemap/examples/README =================================================================== --- trunk/toolkits/basemap/examples/README 2008-08-16 22:48:18 UTC (rev 6037) +++ trunk/toolkits/basemap/examples/README 2008-08-17 22:17:56 UTC (rev 6038) @@ -111,6 +111,9 @@ plotprecip.py use nonlinear precip colormap included with basemap to make a rainfall plot. +cubed_sphere.py - plot a "cubed globe" suitable for cutting and folding, +a la http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html. + run_all.py is a driver script that runs all the examples except fcstmaps.py, testgdal.py, geos_demo_2.py, warpimage.py, and pnganim.py (which rely on external dependencies and/or an internet connection). Added: trunk/toolkits/basemap/examples/cubed_sphere.py =================================================================== --- trunk/toolkits/basemap/examples/cubed_sphere.py (rev 0) +++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:17:56 UTC (rev 6038) @@ -0,0 +1,30 @@ +from mpl_toolkits.basemap import Basemap +import matplotlib.pyplot as plt +import numpy as np +# 'cubed sphere' +# inscribe the sphere in a cube, then separately project each cube +# face with gnomonic projection. +# http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html +# suitable for cutting and folding. +fig = plt.figure(figsize=(8,6)) +fig.subplots_adjust(bottom=0, left=0, right=1, top=1, wspace=0, hspace=0) +rsphere = 6370997. +width = 2.*rsphere; height=width +npanel=0 +for lat_0 in [90,0,-90]: + for ncol in range(0,4): + npanel = npanel + 1 + if lat_0 != 0 and ncol != 1: continue + ax=fig.add_subplot(3,4,npanel) + ax.set_frame_on(False) + lon_0=225 + 90*(ncol+1) - 45 + m = Basemap(width=width,height=height,resolution=None,\ + projection='gnom',lon_0=lon_0,lat_0=lat_0,\ + rsphere=rsphere) + m.bluemarble() + m.drawparallels(np.arange(-90,91,10),color='0.5') + m.drawmeridians(np.arange(0,360,10),color='0.5') +fig.text(0.625,0.75,\ + 'World Map on a Cube\n Gnomonic Projection',\ + fontsize=14) +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-08-16 22:48:21
|
Revision: 6037 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6037&view=rev Author: jswhit Date: 2008-08-16 22:48:18 +0000 (Sat, 16 Aug 2008) Log Message: ----------- added install instructions to new docs Modified Paths: -------------- trunk/toolkits/basemap/README trunk/toolkits/basemap/doc/users/index.rst Added Paths: ----------- trunk/toolkits/basemap/doc/users/installing.rst Modified: trunk/toolkits/basemap/README =================================================================== --- trunk/toolkits/basemap/README 2008-08-14 13:38:01 UTC (rev 6036) +++ trunk/toolkits/basemap/README 2008-08-16 22:48:18 UTC (rev 6037) @@ -14,8 +14,6 @@ The GEOS (Geometry Engine - Open Source) library (version 2.2.3 or higher). Source code is included in the geos-2.2.3 directory. -setuptools (only if your are using python 2.3) - PIL (http://pythonware.com/products/pil) is optional (only needed for Basemap warpimage and bluemarble methods). @@ -71,11 +69,8 @@ 0) Install pre-requisite python modules numpy and matplotlib. -1) Then download basemap-X.Y.Z.tar.gz (approx 32 mb) from +1) Then download basemap-X.Y.Z.tar.gz (approx 100 mb) from the sourceforge download site, unpack and cd to basemap-X.Y.Z. -If you want the full-resolution coastline dataset (useful if you -will be making maps of very small regions), get -basemap-fullresdata-X.Y.Z.tar.gz (approx. 100 mb). 2) Install the GEOS library. If you already have it on your system, just set the environment variable GEOS_DIR to point to the location Modified: trunk/toolkits/basemap/doc/users/index.rst =================================================================== --- trunk/toolkits/basemap/doc/users/index.rst 2008-08-14 13:38:01 UTC (rev 6036) +++ trunk/toolkits/basemap/doc/users/index.rst 2008-08-16 22:48:18 UTC (rev 6037) @@ -10,6 +10,7 @@ .. toctree:: intro.rst + installing.rst mapsetup.rst geography.rst graticule.rst Added: trunk/toolkits/basemap/doc/users/installing.rst =================================================================== --- trunk/toolkits/basemap/doc/users/installing.rst (rev 0) +++ trunk/toolkits/basemap/doc/users/installing.rst 2008-08-16 22:48:18 UTC (rev 6037) @@ -0,0 +1,99 @@ +.. _installing: + +********** +Installing +********** + +Dependencies +============ + +**Requirements** + +These are external packages which you will need to install before +installing basemap. + + +matplotlib 0.98 (or later, `download <http://sf.net/projects/matplotlib/>`__) + +python 2.4 (or later but not python3) + matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__) + +numpy 1.1 (or later) + array support for python (`download <http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__) + +**Required libraries that ship with basemap** + +`GEOS <http://trac.osgeo.org/geos/>`__ (Geometry Engine - Open Source) library 2.2.3 or later (2.2.3 recommended). + Source code is included in the geos-2.2.3 directory. + When building from source, must be built and installed separately + from basemap (see build instructions below). + Included in Windows binary installers. + +`PROJ4 <http://trac.osgeo.org/proj/>`__ Cartographic Projections Library. + Patched version automatically built into basemap. + +`pyshapelib <http://intevation.de/pipermail/thuban-devel/2004-May/000184.html>`__ + C library with python interface for reading ESRI shapefiles (automatically + built and installed with basemap). + +`pupnyere <http://pypi.python.org/pypi/pupynere/>`__ + Pure python `netCDF <http://www.unidata.ucar.edu/software/netcdf/>`__ + interface automatically installed with basemap. + +`pydap <http://code.google.com/p/pydap>`__ + Pure python `OPeNDAP <http://opendap.org>`__ implementation. + If not present, client (not server) will be installed with basemap. + +`httplib2 <http://code.google.com/p/httplib2>`__ (needed for pydap client). + If not present, will be installed with basemap. + + +**Optional libraries** + +PIL + Python Imaging Library (`download <http://www.pythonware.com/products/pil/>`__), + only needed for :func:`~mpl_toolkits.basemap.Basemap.bluemarble` and :func:`~mpl_toolkits.basemap.Basemap.warpimage` instance methods. + +Installation +============ + +Windows binary installers are available for +`download <http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792/&abmode=1>`__. + +For other platforms, download the source release and follow these steps: + + +* Install pre-requisite requirements. + +* Untar the basemap version X.Y.Z source tar.gz file, and + and cd to the basemap-X.Y.Z directory. + +* Install the GEOS library. If you already have it on your + system, just set the environment variable GEOS_DIR to point to the location + of libgeos_c and geos_c.h (if libgeos_c is in /usr/local/lib and + geos_c.h is in /usr/local/include, set GEOS_DIR to /usr/local). + Then go to next step. If you don't have it, you can build it from + the source code included with basemap by following these steps:: + + cd geos-2.2.3 + export GEOS_DIR=<where you want the libs and headers to go> + # A reasonable choice on a Unix-like system is /usr/local, or + # if you don't have permission to write there, your home directory. + ./configure --prefix=$GEOS_DIR + make; make install + +* cd back to the top level basemap directory (basemap-X.Y.Z) and + run the usual ``python setup.py install``. Check your installation + by running ``from mpl_toolkits.basemap import Basemap`` at the python + prompt. + + Basemap includes two auxilliary packages, pydap and httplib2. + By default, setup.py checks to + see if these are already installed, and if so does not try to overwrite + them. If you get import errors related to either of these two packages, + edit setup.cfg and set pydap and/or httplib2 to True to force + installation of the included versions. + +* To test, cd to the examples directory and run ``python simpletest.py``. + To run all the examples (except those that have extra dependencies + or require an internet connection), execute ``python run_all.py``. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-14 13:38:04
|
Revision: 6036 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6036&view=rev Author: mdboom Date: 2008-08-14 13:38:01 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Remove deprecated Numpy call. Modified Paths: -------------- trunk/matplotlib/src/_backend_gdk.c Modified: trunk/matplotlib/src/_backend_gdk.c =================================================================== --- trunk/matplotlib/src/_backend_gdk.c 2008-08-13 18:25:26 UTC (rev 6035) +++ trunk/matplotlib/src/_backend_gdk.c 2008-08-14 13:38:01 UTC (rev 6036) @@ -12,15 +12,6 @@ static PyTypeObject *_PyGdkPixbuf_Type; #define PyGdkPixbuf_Type (*_PyGdkPixbuf_Type) -/* Implement the equivalent to gtk.gdk.Pixbuf.get_pixels_array() - * To solve these problems with the pygtk version: - * 1) It works for Numeric, but not numarray - * 2) Its only available if pygtk is compiled with Numeric support - * Fedora 1,2,3 has PyGTK, but not Numeric and so does not have - * Pixbuf.get_pixels_array(). - * Fedora 4 does have PyGTK, Numeric and Pixbuf.get_pixels_array() - */ - static PyObject * pixbuf_get_pixels_array(PyObject *self, PyObject *args) { @@ -45,7 +36,7 @@ if (gdk_pixbuf_get_has_alpha(gdk_pixbuf)) dims[2] = 4; - array = (PyArrayObject *)PyArray_FromDimsAndData(3, dims, PyArray_UBYTE, + array = (PyArrayObject *)PyArray_SimpleNewFromData(3, dims, PyArray_UBYTE, (char *)gdk_pixbuf_get_pixels(gdk_pixbuf)); if (array == NULL) return NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-13 18:25:32
|
Revision: 6035 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6035&view=rev Author: mdboom Date: 2008-08-13 18:25:26 +0000 (Wed, 13 Aug 2008) Log Message: ----------- [ 2029956 ] Fix documentation warnings. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-08-13 18:10:33 UTC (rev 6034) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-08-13 18:25:26 UTC (rev 6035) @@ -1464,7 +1464,7 @@ Call signature:: - stop_event_loop_default(self) + stop_event_loop_default(self) """ self._looping = False Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-13 18:10:33 UTC (rev 6034) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-13 18:25:26 UTC (rev 6035) @@ -40,10 +40,12 @@ Arguments: *X*, *Y*: - The x and y coordinates of the arrow locations - (default is tail of arrow; see *pivot* kwarg) + The x and y coordinates of the arrow locations (default is tail of + arrow; see *pivot* kwarg) + *U*, *V*: + give the *x* and *y* components of the arrow vectors *C*: @@ -61,28 +63,31 @@ Keyword arguments: *units*: ['width' | 'height' | 'dots' | 'inches' | 'x' | 'y' ] - arrow units; the arrow dimensions *except for length* are - in multiples of this unit. + arrow units; the arrow dimensions *except for length* are in + multiples of this unit. * 'width' or 'height': the width or height of the axes - * 'dots' or 'inches': pixels or inches, based on the figure dpi + + * 'dots' or 'inches': pixels or inches, based on the figure dpi + * 'x' or 'y': *X* or *Y* data units In all cases the arrow aspect ratio is 1, so that if *U*==*V* the - angle of the arrow on the plot is 45 degrees CCW from the *x*-axis. + angle of the arrow on the plot is 45 degrees CCW from the + *x*-axis. - The arrows scale differently depending on the units, however. - For 'x' or 'y', the arrows get larger as one zooms in; for other + The arrows scale differently depending on the units, however. For + 'x' or 'y', the arrows get larger as one zooms in; for other units, the arrow size is independent of the zoom state. For 'width or 'height', the arrow size increases with the width and height of the axes, respectively, when the the window is resized; for 'dots' or 'inches', resizing does not change the arrows. *scale*: [ None | float ] - data units per arrow unit, e.g. m/s per plot width; - a smaller scale parameter makes the arrow longer. - If *None*, a simple autoscaling algorithm is used, based - on the average vector length and the number of vectors. + data units per arrow unit, e.g. m/s per plot width; a smaller + scale parameter makes the arrow longer. If *None*, a simple + autoscaling algorithm is used, based on the average vector length + and the number of vectors. *width*: shaft width in arrow units; default depends on choice of units, @@ -109,8 +114,8 @@ Default is 1. *pivot*: [ 'tail' | 'middle' | 'tip' ] - The part of the arrow that is at the grid point; the arrow - rotates about this point, hence the name *pivot*. + The part of the arrow that is at the grid point; the arrow rotates + about this point, hence the name *pivot*. *color*: [ color | color sequence ] This is a synonym for the @@ -155,23 +160,23 @@ Keyword arguments: *coordinates* = [ 'axes' | 'figure' | 'data' | 'inches' ] - Coordinate system and units for *X*, *Y*: 'axes' and 'figure' - are normalized coordinate systems with 0,0 in the lower - left and 1,1 in the upper right; 'data' are the axes - data coordinates (used for the locations of the vectors - in the quiver plot itself); 'inches' is position in the - figure in inches, with 0,0 at the lower left corner. + Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are + normalized coordinate systems with 0,0 in the lower left and 1,1 + in the upper right; 'data' are the axes data coordinates (used for + the locations of the vectors in the quiver plot itself); 'inches' + is position in the figure in inches, with 0,0 at the lower left + corner. *color*: overrides face and edge colors from *Q*. *labelpos* = [ 'N' | 'S' | 'E' | 'W' ] - Position the label above, below, to the right, to the left - of the arrow, respectively. + Position the label above, below, to the right, to the left of the + arrow, respectively. *labelsep*: - Distance in inches between the arrow and the label. - Default is 0.1 + Distance in inches between the arrow and the label. Default is + 0.1 *labelcolor*: defaults to default :class:`~matplotlib.text.Text` color. @@ -557,88 +562,100 @@ Default is 9 *pivot*: [ 'tip' | 'middle' ] - The part of the arrow that is at the grid point; the arrow - rotates about this point, hence the name *pivot*. - Default is 'tip' + The part of the arrow that is at the grid point; the arrow rotates + about this point, hence the name *pivot*. Default is 'tip' *barbcolor*: [ color | color sequence ] - Specifies the color all parts of the barb except any flags. - This parameter is analagous to the *edgecolor* parameter - for polygons, which can be used instead. However this parameter - will override facecolor. + Specifies the color all parts of the barb except any flags. This + parameter is analagous to the *edgecolor* parameter for polygons, + which can be used instead. However this parameter will override + facecolor. *flagcolor*: [ color | color sequence ] - Specifies the color of any flags on the barb. - This parameter is analagous to the *facecolor* parameter - for polygons, which can be used instead. However this parameter - will override facecolor. If this is not set (and *C* has not either) - then *flagcolor* will be set to match *barbcolor* so that the barb - has a uniform color. If *C* has been set, *flagcolor* has no effect. + Specifies the color of any flags on the barb. This parameter is + analagous to the *facecolor* parameter for polygons, which can be + used instead. However this parameter will override facecolor. If + this is not set (and *C* has not either) then *flagcolor* will be + set to match *barbcolor* so that the barb has a uniform color. If + *C* has been set, *flagcolor* has no effect. *sizes*: - A dictionary of coefficients specifying the ratio of a given feature - to the length of the barb. Only those values one wishes to override - need to be included. These features include: - 'spacing' - space between features (flags, full/half barbs) - 'height' - height (distance from shaft to top) of a flag or full barb - 'width' - width of a flag, twice the width of a full barb - 'emptybarb' - radius of the circle used for low magnitudes + A dictionary of coefficients specifying the ratio of a given + feature to the length of the barb. Only those values one wishes to + override need to be included. These features include: + - 'spacing' - space between features (flags, full/half barbs) + + - 'height' - height (distance from shaft to top) of a flag or + full barb + + - 'width' - width of a flag, twice the width of a full barb + + - 'emptybarb' - radius of the circle used for low magnitudes + *fill_empty*: - A flag on whether the empty barbs (circles) that are drawn should be filled - with the flag color. If they are not filled, they will be drawn such that - no color is applied to the center. - Default is False + A flag on whether the empty barbs (circles) that are drawn should + be filled with the flag color. If they are not filled, they will + be drawn such that no color is applied to the center. Default is + False *rounding*: - A flag to indicate whether the vector magnitude should be rounded when - allocating barb components. If True, the magnitude is rounded to the - nearest multiple of the half-barb increment. If False, the magnitude - is simply truncated to the next lowest multiple. - Default is True + A flag to indicate whether the vector magnitude should be rounded + when allocating barb components. If True, the magnitude is + rounded to the nearest multiple of the half-barb increment. If + False, the magnitude is simply truncated to the next lowest + multiple. Default is True *barb_increments*: - A dictionary of increments specifying values to associate with different - parts of the barb. Only those values one wishes to override need to be - included. - 'half' - half barbs (Default is 5) - 'full' - full barbs (Default is 10) - 'flag' - flags (default is 50) + A dictionary of increments specifying values to associate with + different parts of the barb. Only those values one wishes to + override need to be included. + - 'half' - half barbs (Default is 5) + + - 'full' - full barbs (Default is 10) + + - 'flag' - flags (default is 50) + *flip_barb*: - Either a single boolean flag or an array of booleans. Single boolean - indicates whether the lines and flags should point opposite to normal - for all barbs. An array (which should be the same size as the other - data arrays) indicates whether to flip for each individual barb. - Normal behavior is for the barbs and lines to point right (comes from - wind barbs having these features point towards low pressure in the - Northern Hemisphere.) - Default is False + Either a single boolean flag or an array of booleans. Single + boolean indicates whether the lines and flags should point + opposite to normal for all barbs. An array (which should be the + same size as the other data arrays) indicates whether to flip for + each individual barb. Normal behavior is for the barbs and lines + to point right (comes from wind barbs having these features point + towards low pressure in the Northern Hemisphere.) Default is + False Barbs are traditionally used in meteorology as a way to plot the speed -and direction of wind observations, but can technically be used to plot -any two dimensional vector quantity. As opposed to arrows, which give -vector magnitude by the length of the arrow, the barbs give more quantitative -information about the vector magnitude by putting slanted lines or a triangle -for various increments in magnitude, as show schematically below: +and direction of wind observations, but can technically be used to +plot any two dimensional vector quantity. As opposed to arrows, which +give vector magnitude by the length of the arrow, the barbs give more +quantitative information about the vector magnitude by putting slanted +lines or a triangle for various increments in magnitude, as show +schematically below:: - /\ \ - / \ \ - / \ \ \ -/ \ \ \ ------------------------------- + : /\ \\ + : / \ \\ + : / \ \ \\ + : / \ \ \\ + : ------------------------------ -The largest increment is given by a triangle (or "flag"). After those come full -lines (barbs). The smallest increment is a half line. There is only, of -course, ever at most 1 half line. If the magnitude is small and only needs a -single half-line and no full lines or triangles, the half-line is offset from -the end of the barb so that it can be easily distinguished from barbs with a -single full line. The magnitude for the barb shown above would nominally be -65, using the standard increments of 50, 10, and 5. +.. note the double \\ at the end of each line to make the figure +.. render correctly +The largest increment is given by a triangle (or "flag"). After those +come full lines (barbs). The smallest increment is a half line. There +is only, of course, ever at most 1 half line. If the magnitude is +small and only needs a single half-line and no full lines or +triangles, the half-line is offset from the end of the barb so that it +can be easily distinguished from barbs with a single full line. The +magnitude for the barb shown above would nominally be 65, using the +standard increments of 50, 10, and 5. + linewidths and edgecolors can be used to customize the barb. -Additional :class:`~matplotlib.collections.PolyCollection` -keyword arguments: +Additional :class:`~matplotlib.collections.PolyCollection` keyword +arguments: %(PolyCollection)s """ % martist.kwdocd @@ -647,15 +664,15 @@ ''' Specialized PolyCollection for barbs. - The only API method is set_UVC(), which can be used - to change the size, orientation, and color of the - arrows. Locations are changed using the set_offsets() collection - method.Possibly this method will be useful in animations. + The only API method is :meth:`set_UVC`, which can be used to + change the size, orientation, and color of the arrows. Locations + are changed using the :meth:`set_offsets` collection method. + Possibly this method will be useful in animations. - There is one internal function _find_tails() which finds exactly - what should be put on the barb given the vector magnitude. From there - _make_barbs() is used to find the vertices of the polygon to represent the - barb based on this information. + There is one internal function :meth:`_find_tails` which finds + exactly what should be put on the barb given the vector magnitude. + From there :meth:`_make_barbs` is used to find the vertices of the + polygon to represent the barb based on this information. ''' #This may be an abuse of polygons here to render what is essentially maybe #1 triangle and a series of lines. It works fine as far as I can tell @@ -714,12 +731,15 @@ half a barb. Mag should be the magnitude of a vector (ie. >= 0). This returns a tuple of: - (number of flags, number of barbs, half_flag, empty_flag) - half_flag is a boolean whether half of a barb is needed, since there - should only ever be one half on a given barb. Empty flag is an array - of flags to easily tell if a barb is empty (too low to plot any - barbs/flags.''' + (*number of flags*, *number of barbs*, *half_flag*, *empty_flag*) + + *half_flag* is a boolean whether half of a barb is needed, + since there should only ever be one half on a given + barb. *empty_flag* flag is an array of flags to easily tell if + a barb is empty (too low to plot any barbs/flags. + ''' + #If rounding, round to the nearest multiple of half, the smallest #increment if rounding: @@ -738,25 +758,41 @@ def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length, pivot, sizes, fill_empty, flip): - '''This function actually creates the wind barbs. u and v are - components of the vector in the x and y directions, respectively. - nflags, nbarbs, and half_barb, empty_flag are, respectively, the number - of flags, number of barbs, flag for half a barb, and flag for empty - barb, ostensibly obtained from _find_tails. length is the length of - the barb staff in points. pivot specifies the point on the barb around - which the entire barb should be rotated. Right now valid options are - 'head' and 'middle'. sizes is a dictionary of coefficients specifying - the ratio of a given feature to the length of the barb. These features + '''This function actually creates the wind barbs. *u* and *v* + are components of the vector in the *x* and *y* directions, + respectively. + + *nflags*, *nbarbs*, and *half_barb*, empty_flag* are, + *respectively, the number of flags, number of barbs, flag for + *half a barb, and flag for empty barb, ostensibly obtained + *from :meth:`_find_tails`. + + *length* is the length of the barb staff in points. + + *pivot* specifies the point on the barb around which the + entire barb should be rotated. Right now, valid options are + 'head' and 'middle'. + + *sizes* is a dictionary of coefficients specifying the ratio + of a given feature to the length of the barb. These features include: - spacing - space between features (flags, full/half barbs) - height - height (distance from shaft of top) of a flag or full barb - width - width of a flag, twice the width of a full barb - emptybarb - radius of the circle used for low magnitudes + - *spacing*: space between features (flags, full/half + barbs) - fill_empty specifies whether the circle representing an empty barb - should be filled or not (this changes the drawing of the polygon). - flip is a flag indicating whether the features should be flipped to + - *height*: distance from shaft of top of a flag or full + barb + + - *width* - width of a flag, twice the width of a full barb + + - *emptybarb* - radius of the circle used for low + magnitudes + + *fill_empty* specifies whether the circle representing an + empty barb should be filled or not (this changes the drawing + of the polygon). + + *flip* is a flag indicating whether the features should be flipped to the other side of the barb (useful for winds in the southern hemisphere. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-13 18:10:38
|
Revision: 6034 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6034&view=rev Author: mdboom Date: 2008-08-13 18:10:33 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Quiet the math -> png conversion. Modified Paths: -------------- trunk/matplotlib/doc/sphinxext/mathmpl.py Modified: trunk/matplotlib/doc/sphinxext/mathmpl.py =================================================================== --- trunk/matplotlib/doc/sphinxext/mathmpl.py 2008-08-13 16:23:48 UTC (rev 6033) +++ trunk/matplotlib/doc/sphinxext/mathmpl.py 2008-08-13 18:10:33 UTC (rev 6034) @@ -100,7 +100,6 @@ if os.path.exists(filename): depth = mathtext_parser.get_depth(latex, dpi=100) else: - print latex.encode("ascii", "backslashreplace") try: depth = mathtext_parser.to_png(filename, latex, dpi=100) except: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-13 16:23:53
|
Revision: 6033 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6033&view=rev Author: mdboom Date: 2008-08-13 16:23:48 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Fix formatting. Modified Paths: -------------- trunk/matplotlib/src/agg_py_path_iterator.h Modified: trunk/matplotlib/src/agg_py_path_iterator.h =================================================================== --- trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-13 16:20:18 UTC (rev 6032) +++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-13 16:23:48 UTC (rev 6033) @@ -19,7 +19,7 @@ public: PathIterator(const Py::Object& path_obj) : - m_vertices(NULL), m_codes(NULL), m_iterator(0) + m_vertices(NULL), m_codes(NULL), m_iterator(0), m_should_simplify(false) { Py::Object vertices_obj = path_obj.getAttr("vertices"); Py::Object codes_obj = path_obj.getAttr("codes"); @@ -28,9 +28,10 @@ m_vertices = (PyArrayObject*)PyArray_FromObject (vertices_obj.ptr(), PyArray_DOUBLE, 2, 2); if (!m_vertices || - PyArray_NDIM(m_vertices) != 2 || PyArray_DIM(m_vertices, 1) != 2) + { throw Py::ValueError("Invalid vertices array."); + } if (codes_obj.ptr() != Py_None) { @@ -38,6 +39,8 @@ (codes_obj.ptr(), PyArray_UINT8, 1, 1); if (!m_codes) throw Py::ValueError("Invalid codes array."); + if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 1)) + throw Py::ValueError("Codes array is wrong length"); } m_should_simplify = should_simplify_obj.isTrue(); @@ -79,11 +82,16 @@ if (m_iterator >= m_total_vertices) return agg::path_cmd_stop; unsigned code = vertex_with_code(m_iterator++, x, y); - if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) { - do { - if (m_iterator < m_total_vertices) { + if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)) + { + do + { + if (m_iterator < m_total_vertices) + { vertex(m_iterator++, x, y); - } else { + } + else + { return agg::path_cmd_stop; } } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)); @@ -207,7 +215,8 @@ // If the queue is now empty, and the path was fully consumed // in the last call to the main loop, return agg::path_cmd_stop to // signal that there are no more points to emit. - if (m_done) { + if (m_done) + { #if DEBUG_SIMPLIFY printf(".\n"); #endif @@ -376,21 +385,26 @@ //direction we are drawing in, move back to we start drawing from //back there. if (m_haveMin) - m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY); + { + m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY); + } m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY); //if we clipped some segments between this line and the next line //we are starting, we also need to move to the last point. - if (m_clipped) - m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty); + if (m_clipped) { + m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty); + } else if (!m_lastMax) + { //if the last line was not the longest line, then move back to //the end point of the last line in the sequence. Only do this //if not clipped, since in that case lastx,lasty is not part of //the line just drawn. //Would be move_to if not for the artifacts - m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty); + m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty); + } //now reset all the variables to get ready for the next line m_origdx = *x - m_lastx; @@ -421,7 +435,9 @@ if (m_origdNorm2 != 0) { if (m_haveMin) + { m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY); + } m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY); } m_done = true; @@ -458,7 +474,8 @@ struct item { item() {} - inline void set(const unsigned cmd_, const double& x_, const double& y_) { + inline void set(const unsigned cmd_, const double& x_, const double& y_) + { cmd = cmd_; x = x_; y = y_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-08-13 16:20:22
|
Revision: 6032 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6032&view=rev Author: mdboom Date: 2008-08-13 16:20:18 +0000 (Wed, 13 Aug 2008) Log Message: ----------- Minor fix to conversion of should_simplify. Modified Paths: -------------- trunk/matplotlib/src/agg_py_path_iterator.h Modified: trunk/matplotlib/src/agg_py_path_iterator.h =================================================================== --- trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-13 15:00:05 UTC (rev 6031) +++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-13 16:20:18 UTC (rev 6032) @@ -40,7 +40,7 @@ throw Py::ValueError("Invalid codes array."); } - m_should_simplify = bool(Py::Int(should_simplify_obj)); + m_should_simplify = should_simplify_obj.isTrue(); m_total_vertices = m_vertices->dimensions[0]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |