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
(6) |
2
(17) |
3
(11) |
4
(12) |
5
(16) |
6
(6) |
7
(5) |
8
(8) |
9
(24) |
10
(15) |
11
(12) |
12
(22) |
13
(30) |
14
(16) |
15
(6) |
16
(15) |
17
(20) |
18
(4) |
19
(11) |
20
(16) |
21
(2) |
22
(17) |
23
(16) |
24
(18) |
25
(4) |
26
(9) |
27
(12) |
28
(2) |
29
|
30
(4) |
|
|
|
|
|
Revision: 5636 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5636&view=rev Author: jdh2358 Date: 2008年06月22日 09:32:47 -0700 (2008年6月22日) Log Message: ----------- Merged revisions 5634 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5634 | jdh2358 | 2008年06月22日 11:30:14 -0500 (2008年6月22日) | 1 line bumped the version num ........ Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5632 + /branches/v0_91_maint:1-5635 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5635 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5635&view=rev Author: jdh2358 Date: 2008年06月22日 09:31:10 -0700 (2008年6月22日) Log Message: ----------- bumped the version num; fixed a collections bug introduced when fixing alpha support Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008年06月22日 16:30:14 UTC (rev 5634) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008年06月22日 16:31:10 UTC (rev 5635) @@ -89,7 +89,7 @@ """ from __future__ import generators -__version__ = '0.98.0' +__version__ = '0.98.1' __revision__ = '$Revision$' __date__ = '$Date$' Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年06月22日 16:30:14 UTC (rev 5634) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年06月22日 16:31:10 UTC (rev 5635) @@ -262,7 +262,7 @@ gc.set_linewidth(linewidths[i % Nlinewidths]) if Nlinestyles: gc.set_dashes(*linestyles[i % Nlinestyles]) - if len(rgbFace)==4: + if rgbFace is not None and len(rgbFace)==4: gc.set_alpha(rgbFace[-1]) rgbFace = rgbFace[:3] gc.set_antialiased(antialiaseds[i % Naa]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5634 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5634&view=rev Author: jdh2358 Date: 2008年06月22日 09:30:14 -0700 (2008年6月22日) Log Message: ----------- bumped the version num Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/__init__.py Modified: branches/v0_91_maint/lib/matplotlib/__init__.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/__init__.py 2008年06月22日 16:24:02 UTC (rev 5633) +++ branches/v0_91_maint/lib/matplotlib/__init__.py 2008年06月22日 16:30:14 UTC (rev 5634) @@ -55,7 +55,7 @@ """ from __future__ import generators -__version__ = '0.91.3' +__version__ = '0.91.4' __revision__ = '$Revision$' __date__ = '$Date$' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5633 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5633&view=rev Author: jdh2358 Date: 2008年06月22日 09:24:02 -0700 (2008年6月22日) Log Message: ----------- Merged revisions 5604,5625,5631 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5604 | efiring | 2008年06月19日 23:53:28 -0500 (2008年6月19日) | 2 lines Don't try to render a line collection with no segments ........ r5625 | dsdale | 2008年06月21日 08:35:30 -0500 (2008年6月21日) | 2 lines improve mlab.load docstring to address bug 1901536 ........ r5631 | jdh2358 | 2008年06月22日 11:15:24 -0500 (2008年6月22日) | 1 line changed wx backend to respect extension over gui dialog default type ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Name: svnmerge-integrated - /branches/v0_91_maint:1-5573,5603 + /branches/v0_91_maint:1-5632 Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年06月22日 16:16:20 UTC (rev 5632) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年06月22日 16:24:02 UTC (rev 5633) @@ -94,6 +94,7 @@ cvs_id = '$Id$' + import sys, os, os.path, math, StringIO, weakref, warnings # Debugging settings here... @@ -1646,8 +1647,14 @@ filename = dlg.GetFilename() DEBUG_MSG('Save file dir:%s name:%s' % (dirname, filename), 3, self) format = exts[dlg.GetFilterIndex()] - # Explicitly pass in the selected filetype to override the - # actual extension if necessary + basename, ext = os.path.splitext(filename) + if ext.startswith('.'): + ext = ext[1:] + if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format!=ext: + #looks like they forgot to set the image type drop + #down, going with the extension. + warnings.warn('extension %s did not match the selected image type %s; going with %s'%(ext, format, ext), stacklevel=0) + format = ext try: self.canvas.print_figure( os.path.join(dirname, filename), format=format) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5632 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5632&view=rev Author: jdh2358 Date: 2008年06月22日 09:16:20 -0700 (2008年6月22日) Log Message: ----------- removed save from scatter demo Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/scatter_demo2.py Modified: trunk/matplotlib/examples/pylab_examples/scatter_demo2.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/scatter_demo2.py 2008年06月22日 16:15:24 UTC (rev 5631) +++ trunk/matplotlib/examples/pylab_examples/scatter_demo2.py 2008年06月22日 16:16:20 UTC (rev 5632) @@ -15,7 +15,7 @@ ylabel(r'$\Delta_{i+1}$', size='x-large') title(r'Volume and percent change') grid(True) -savefig('scatter_demo2') +#savefig('scatter_demo2') colorbar() show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5631 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5631&view=rev Author: jdh2358 Date: 2008年06月22日 09:15:24 -0700 (2008年6月22日) Log Message: ----------- changed wx backend to respect extension over gui dialog default type Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/backends/backend_wx.py Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_wx.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/backends/backend_wx.py 2008年06月22日 15:08:05 UTC (rev 5630) +++ branches/v0_91_maint/lib/matplotlib/backends/backend_wx.py 2008年06月22日 16:15:24 UTC (rev 5631) @@ -94,7 +94,7 @@ cvs_id = '$Id$' -import sys, os, os.path, math, StringIO +import sys, os, os.path, math, StringIO, warnings # Debugging settings here... # Debug level set here. If the debug level is less than 5, information @@ -1716,8 +1716,14 @@ filename = dlg.GetFilename() DEBUG_MSG('Save file dir:%s name:%s' % (dirname, filename), 3, self) format = exts[dlg.GetFilterIndex()] - # Explicitly pass in the selected filetype to override the - # actual extension if necessary + basename, ext = os.path.splitext(filename) + if ext.startswith('.'): + ext = ext[1:] + if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format!=ext: + #looks like they forgot to set the image type drop + #down, going with the extension. + warnings.warn('extension %s did not match the selected image type %s; going with %s'%(ext, format, ext), stacklevel=0) + format = ext try: self.canvas.print_figure( os.path.join(dirname, filename), format=format) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5630 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5630&view=rev Author: jdh2358 Date: 2008年06月22日 08:08:05 -0700 (2008年6月22日) Log Message: ----------- removed axes3d; fixed an alpha bug on backend draw collections Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/scatter_demo2.py trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/examples/pylab_examples/scatter_demo2.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/scatter_demo2.py 2008年06月22日 13:52:43 UTC (rev 5629) +++ trunk/matplotlib/examples/pylab_examples/scatter_demo2.py 2008年06月22日 15:08:05 UTC (rev 5630) @@ -15,7 +15,7 @@ ylabel(r'$\Delta_{i+1}$', size='x-large') title(r'Volume and percent change') grid(True) -#savefig('scatter_demo2') +savefig('scatter_demo2') colorbar() show() Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年06月22日 13:52:43 UTC (rev 5629) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年06月22日 15:08:05 UTC (rev 5630) @@ -262,6 +262,9 @@ gc.set_linewidth(linewidths[i % Nlinewidths]) if Nlinestyles: gc.set_dashes(*linestyles[i % Nlinestyles]) + if len(rgbFace)==4: + gc.set_alpha(rgbFace[-1]) + rgbFace = rgbFace[:3] gc.set_antialiased(antialiaseds[i % Naa]) yield xo, yo, path_id, gc, rgbFace This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5629 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5629&view=rev Author: jdh2358 Date: 2008年06月22日 06:52:43 -0700 (2008年6月22日) Log Message: ----------- removed axes3d Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab_examples/hline_demo.py trunk/matplotlib/examples/pylab_examples/image_demo.py trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/axes3d.py Removed Paths: ------------- trunk/matplotlib/examples/pylab_examples/simple3d.py trunk/matplotlib/examples/user_interfaces/simple3d_oo.py trunk/matplotlib/lib/matplotlib/art3d.py trunk/matplotlib/lib/matplotlib/axis3d.py trunk/matplotlib/lib/matplotlib/proj3d.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/API_CHANGES 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,4 +1,12 @@ +Changes for 0.98.1 +================== +* Removed broken axes3d support and replaced it with a non implemented + error pointing to 0.91.x + +Changes for 0.98.0 +================== + matplotlib.image.imread now no longer always returns RGBA -- if the image is luminance or RGB, it will return a MxN or MxNx3 array if possible. Also uint8 is no longer always forced to float. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/CHANGELOG 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,3 +1,6 @@ +2008年06月22日 Removed axes3d support and replaced it with a + NotImplementedError for one release cycle + 2008年06月21日 fix marker placement bug in backend_ps - DSD 2008年06月20日 [ 1978629 ] scale documentation missing/incorrect for log - MGD Modified: trunk/matplotlib/examples/pylab_examples/hline_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/examples/pylab_examples/hline_demo.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -17,5 +17,6 @@ hlines(t, [0], s) xlabel('time (s)') title('Comparison of model with data') +savefig('test') show() Modified: trunk/matplotlib/examples/pylab_examples/image_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/image_demo.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/examples/pylab_examples/image_demo.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -11,6 +11,6 @@ im = imshow(Z, interpolation='bilinear', cmap=cm.gray, origin='lower', extent=[-3,3,-3,3]) -#savefig('image_demo') +savefig('image_demo') show() Deleted: trunk/matplotlib/examples/pylab_examples/simple3d.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/simple3d.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/examples/pylab_examples/simple3d.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -from numpy import arange, cos, linspace, ones, pi, sin, outer - -import pylab -import matplotlib.axes3d as axes3d - - -fig = pylab.gcf() - -ax3d = axes3d.Axes3D(fig) -plt = fig.axes.append(ax3d) - -delta = pi / 199.0 -u = arange(0, 2*pi+(delta*2), delta*2) -v = arange(0, pi+delta, delta) - -x = outer(cos(u),sin(v)) -y = outer(sin(u),sin(v)) -z = outer(ones(u.shape), cos(v)) - -#ax3d.plot_wireframe(x,y,z) -surf = ax3d.plot_surface(x, y, z) -surf.set_array(linspace(0, 1.0, len(v))) - -ax3d.set_xlabel('X') -ax3d.set_ylabel('Y') -ax3d.set_zlabel('Z') - -pylab.show() -#pylab.savefig('simple3d.svg') Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -132,9 +132,11 @@ import subprocess def run(arglist): try: - subprocess.call(arglist) + ret = subprocess.call(arglist) except KeyboardInterrupt: sys.exit() + else: + return ret except ImportError: def run(arglist): os.system(' '.join(arglist)) @@ -198,12 +200,13 @@ tmpfile.close() start_time = time.time() program = [x % {'name': basename} for x in python] - run(program + [tmpfile_name, switchstring]) + ret = run(program + [tmpfile_name, switchstring]) end_time = time.time() - print (end_time - start_time) + print (end_time - start_time), ret #os.system('%s %s %s' % (python, tmpfile_name, switchstring)) os.remove(tmpfile_name) + if __name__ == '__main__': times = {} default_backends = ['agg', 'ps', 'svg', 'pdf', 'template'] Deleted: trunk/matplotlib/examples/user_interfaces/simple3d_oo.py =================================================================== --- trunk/matplotlib/examples/user_interfaces/simple3d_oo.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/examples/user_interfaces/simple3d_oo.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import matplotlib -matplotlib.use('WXAgg') - -from wx import * -import matplotlib.axes3d -import matplotlib.mlab -import numpy as npy -from matplotlib.figure import Figure -from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg, FigureManager, NavigationToolbar2WxAgg - -class PlotFigure(Frame): - def __init__(self): - Frame.__init__(self, None, -1, "Test embedded wxFigure") - - self.fig = Figure((9,8), 75) - self.canvas = FigureCanvasWxAgg(self, -1, self.fig) - self.toolbar = NavigationToolbar2WxAgg(self.canvas) - self.toolbar.Realize() - - self.figmgr = FigureManager(self.canvas, 1, self) - tw, th = self.toolbar.GetSizeTuple() - fw, fh = self.canvas.GetSizeTuple() - self.toolbar.SetSize(Size(fw, th)) - sizer = BoxSizer(VERTICAL) - - # This way of adding to sizer allows resizing - sizer.Add(self.canvas, 1, LEFT|TOP|GROW) - sizer.Add(self.toolbar, 0, GROW) - self.SetSizer(sizer) - self.Fit() - - self.plot3d() - - def plot3d(self): - # sample taken from http://www.scipy.org/Cookbook/Matplotlib/mplot3D - ax3d = matplotlib.axes3d.Axes3D(self.fig) - plt = self.fig.axes.append(ax3d) - - delta = npy.pi / 199.0 - u = npy.arange(0, 2*npy.pi+(delta*2), delta*2) - v = npy.arange(0, npy.pi+delta, delta) - - x = npy.cos(u)[:,npy.newaxis] * npy.sin(v)[npy.newaxis,:] - y = npy.sin(u)[:,npy.newaxis] * npy.sin(v)[npy.newaxis,:] - z = npy.ones_like(u)[:,npy.newaxis] * npy.cos(v)[npy.newaxis,:] - # (there is probably a better way to calculate z) - print x.shape, y.shape, z.shape - - #ax3d.plot_wireframe(x,y,z) - surf = ax3d.plot_surface(x, y, z) - surf.set_array(matplotlib.mlab.linspace(0, 1.0, len(v))) - - ax3d.set_xlabel('X') - ax3d.set_ylabel('Y') - ax3d.set_zlabel('Z') - #self.fig.savefig('globe') - -if __name__ == '__main__': - app = PySimpleApp(0) - frame = PlotFigure() - frame.Show() - app.MainLoop() Deleted: trunk/matplotlib/lib/matplotlib/art3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/art3d.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/lib/matplotlib/art3d.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,464 +0,0 @@ -#!/usr/bin/python -# art3d.py -# -""" -Wrap 2D artists so that they can pretend to be 3D -""" - -import lines -from collections import LineCollection, PolyCollection -import text - -from colors import Normalize - -import numpy as np -import proj3d - -class Wrap2D: - """Wrapper which wraps a 2D object and makes it 3D - - Artists are normally rendered by calling the draw method, this class - causes call_draw3d to be called instead. - This in turn calls - draw3d which should play with the 2D coordinates and eventually - call the original self.draw method through self.orig_draw. - - overrides the draw method with draw3d - remembers the original draw method of the wrapped 2d instance - """ - def __init__(self, inst2d): - self.__dict__['_wrapped'] = inst2d - self.__dict__['remembered'] = {} - # - inst2d.orig_draw = inst2d.draw - self.draw2d = inst2d.draw - inst2d.draw = self.call_draw3d - - def remember(self, *attrs): - """ - Remember some attributes in the wrapped class - """ - for attr in attrs: - assert(hasattr(self._wrapped, attr)) - self.remembered[attr] = 1 - - def __getattr__(self, k): - return getattr(self.__dict__['_wrapped'], k) - - def __setattr__(self, k, v): - setattr(self.__dict__['_wrapped'], k, v) - - def call_draw3d(self, renderer): - for k in self.remembered.keys(): - self.remembered[k] = getattr(self, k) - # - self.draw3d(renderer) - # - for k in self.remembered.keys(): - setattr(self, k, self.remembered[k]) - - def draw3d(self, renderer): - raise ValueError, "draw3d should be overridden" - -class Text3DW(Wrap2D): - """Wrap a 2D text object and make it look vaguely 3D""" - def __init__(self, inst, z=0, dir='z'): - Wrap2D.__init__(self, inst) - self._z = z - self.dir = dir - - def draw3d(self, renderer): - x,y = self.get_position() - xs,ys,zs = juggle_axes(x,y,self._z,self.dir) - xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M) - self.set_x(xs) - self.set_y(ys) - #text.Text.draw(self._wrapped, renderer) - self.draw2d(renderer) - self.set_x(x) - self.set_y(y) - -class Text3D(Text3DW): - def __init__(self, x=0,y=0,z=0,text='', dir='z'): - inst = text.Text(x,y,text,*args, **kwargs) - Text3DW.__init__(self, z,dir, inst) - -class oText3D(text.Text): - def __init__(self, x=0,y=0,z=0,text='', dir='z', *args, **kwargs): - text.Text.__init__(self, x,y,text,*args,**kwargs) - self.dir = dir - self._z = _z - - def draw(self, renderer): - x,y = self.get_position() - xs,ys,zs = juggle_axes(x,y,self._z,self.dir) - xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M) - self.set_x(xs) - self.set_y(ys) - text.Text.draw(self, renderer) - self.set_x(x) - self.set_y(y) - -class Line3D(lines.Line2D): - """Make a 2D line pretend to be 3D""" - def __init__(self, xs,ys,zs, *args, **kwargs): - lines.Line2D.__init__(self, xs,ys, *args, **kwargs) - self.xs,self.ys,self.zs = xs,ys,zs - - def draw(self, renderer): - xs,ys,zs = proj3d.proj_transform(self.xs,self.ys,self.zs, renderer.M) - self._x,self._y = xs,ys - - lines.Line2D.draw(self, renderer) - -class Line3DCollectionW(Wrap2D): - def __init__(self, inst, segments): - Wrap2D.__init__(self, inst) - self.segments_3d = segments - - def draw3d(self, renderer): - xyslist = [ - proj3d.proj_trans_points(points, renderer.M) for points in - self.segments_3d] - segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist] - self._segments = segments_2d - self.draw2d(renderer) - -class Line3DCollection(Line3DCollectionW): - def __init__(self, segments, *args, **kwargs): - inst = LineCollection(segments, *args, **kwargs) - Line3DCollectionW.__init__(self, inst, segments) - -class Line2DCollectionW(Wrap2D): - def __init__(self, inst, z=0, dir='z'): - Wrap2D.__init__(self, inst) - self.z = z - self.dir = dir - self.remember('_segments') - - def draw3d(self, renderer): - # - segments_3d = [[juggle_axes(x,y,self.z,self.dir) for (x,y) in points] - for points in self._segments] - xyslist = [ - proj3d.proj_trans_points(points, renderer.M) for points in - segments_3d] - segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist] - #orig_segments = self._segments - self._segments = segments_2d - self.draw2d(renderer) - #self._segments = orig_segments - -class Line3DCollection(Line3DCollectionW): - def __init__(self, segments, *args, **kwargs): - inst = LineCollection(segments, *args, **kwargs) - Line3DCollectionW.__init__(self, inst, segments) - -class Patch3D(Wrap2D): - def __init__(self, inst, zs, dir='z'): - Wrap2D.__init__(self, inst) - self.zs = zs - self.dir = dir - self.remember('get_verts') - - def draw3d(self, renderer): - xs,ys = zip(*self.get_verts()) - xs,ys,zs = juggle_axes(xs,ys,self.zs,self.dir) - vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M) - def get_verts(*args): - verts = zip(vxs,vys) - return verts - - self.get_verts = get_verts - self.draw2d(renderer) - -class Patch3DCollectionW(Wrap2D): - def __init__(self, inst, zs, dir='z'): - Wrap2D.__init__(self, inst) - self.zs = zs - self.dir = dir - self.remember('_offsets','_facecolors','_edgecolors') - - def draw3d(self, renderer): - xs,ys = zip(*self._offsets) - xs,ys,zs = juggle_axes(xs,ys,self.zs,self.dir) - if 0: - vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M) - # mess with colors - # - vxs = [x for x,i in zip(vxs,vis) if i] - vys = [y for y,i in zip(vys,vis) if i] - else: - vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M) - self._facecolors = zalpha(self._facecolors,vzs) - self._edgecolors = zalpha(self._edgecolors,vzs) - self._offsets = zip(vxs,vys) - self.draw2d(renderer) - -class Poly3DCollectionW(Wrap2D): - def __init__(self, inst, zs=None, dir='z'): - Wrap2D.__init__(self, inst) - if not zs: - zs = [0 for v in inst._verts] - self.zs = [[z for v in verts] for z,verts in zip(zs,inst._verts)] - self.dir = dir - self.remember('_verts','_facecolors','_edgecolors') - - def draw3d(self, renderer): - vverts = [] - for zs,verts in zip(self.zs,self._verts): - xs,ys = zip(*verts) - xs,ys,zs = juggle_axes(xs,ys,zs,self.dir) - vxs,vys,vzs,vis = proj3d.proj_transform_clip(xs,ys,zs, renderer.M) - vverts.append((max(vzs),zip(vxs,vys))) - vverts.sort() - vverts.reverse() - # mess with colors - self._verts = [verts for (z,verts) in vverts] - self.draw2d(renderer) - -class oLine3DCollection(LineCollection): - def __init__(self, segments, *args, **kwargs): - LineCollection.__init__(self, segments, *args, **kwargs) - self.segments_3d = segments - - def draw(self, renderer): - orig_segments = self._segments - xyslist = [ - proj3d.proj_trans_points(points, renderer.M) for points in - self.segments_3d] - segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist] - self._segments = segments_2d - LineCollection.draw(self, renderer) - self._segments = orig_segments - -class Poly3DCollection(Wrap2D): - def __init__(self, segments, *args, **kwargs): - inst = PolyCollection(segments, *args, **kwargs) - Wrap2D.__init__(self, inst) - self._zsort = 1 - self.get_vector() - self.remember('_facecolors') - self.remember('_verts') - - def get_vector(self): - """optimise points for projection""" - si = 0 - ei = 0 - segis = [] - points = [] - for p in self._verts: - points.extend(p) - ei = si+len(p) - segis.append((si,ei)) - si = ei - xs,ys,zs = zip(*points) - ones = np.ones(len(xs)) - self.vec = np.array([xs,ys,zs,ones]) - self.segis = segis - - def draw3d(self, renderer): - # - txs,tys,tzs,tis = proj3d.proj_transform_vec_clip(self.vec,renderer.M) - xyslist = [(txs[si:ei],tys[si:ei],tzs[si:ei],tis[si:ei]) for si,ei in self.segis] - colors = get_colors(self._facecolors, len(self._verts)) - # - # if required sort by depth (furthest drawn first) - if self._zsort: - z_segments_2d = [(min(zs),max(tis),zip(xs,ys),c) for - (xs,ys,zs,tis),c in zip(xyslist,colors)] - z_segments_2d.sort() - z_segments_2d.reverse() - else: - raise ValueError, "whoops" - segments_2d = [s for z,i,s,c in z_segments_2d if i] - colors = [c for z,i,s,c in z_segments_2d if i] - self._verts = segments_2d - self._facecolors = colors - - self.draw2d(renderer) - -def juggle_axes(xs,ys,zs, dir): - """Depending on the direction of the plot re-order the axis - - This is so that 2d plots can be plotted along any direction. - """ - if dir == 'x': return zs,xs,ys - elif dir == 'y': return xs,zs,ys - else: return xs,ys,zs - -class Line2DW(Wrap2D): - def __init__(self, inst, z=0, dir='z'): - Wrap2D.__init__(self, inst) - self.z = z - self.dir = dir - self.remember('_x','_y') - - def draw3d(self, renderer): - zs = [self.z for x in self._x] - xs,ys,zs = juggle_axes(self._x,self._y,zs,self.dir) - xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M) - self._x = xs - self._y = ys - self.draw2d(renderer) - -def line_draw(self, renderer): - """Draw a 2D line as a 3D line""" - oxs,oys = self.get_xdata(),self.get_ydata() - xs,ys,zs = juggle_axes(oxs,oys,self.zs,self.dir) - xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M) - self._x = xs - self._y = ys - self.old_draw(renderer) - self._x = oxs - self._y = oys - -def wrap_line(line, zs,dir='z'): - """Wrap a 2D line so that it draws as a 3D line""" - line.zs = zs - line.dir = dir - line.old_draw = line.draw - def wrapped_draw(renderer,line=line): - return line_draw(line,renderer) - line.draw = wrapped_draw - -def image_draw(image,renderer): - source = image._A - w,h,p = source.shape - X,Y = meshgrid(arange(w),arange(h)) - Z = np.zeros((w,h)) - tX,tY,tZ = proj3d.transform(X.flat,Y.flat,Z.flat,M) - tX = reshape(tX,(w,h)) - tY = reshape(tY,(w,h)) - -def wrap_image(image, extent): - image.extent3D = extent - image.old_draw = image.draw - def wrapped_draw(renderer,image=image): - return image_draw(image,renderer) - image.draw = wrapped_draw - - -def set_line_data(line, xs,ys,zs): - try: line = line[0] - except: pass - line.set_data(xs,ys) - line.zs = zs - -def iscolor(c): - try: - return (len(c)==4 or len(c)==3) and (type(c[0])==float) - except (IndexError): - return None - -def get_colors(c, num): - """Stretch the color argument to provide the required number num""" - if type(c)==type("string"): - c = colors.colorConverter.to_rgba(colors) - if iscolor(c): - return [c]*num - elif iscolor(c[0]): - return c*num - elif len(c)==num: - return c[:] - else: - raise ValueError, 'unknown color format %s' % c - -def zalpha(colors, zs): - """Modify the alphas of the color list according to depth""" - colors = get_colors(colors,len(zs)) - norm = Normalize(min(zs),max(zs)) - sats = 1 - norm(zs)*0.7 - colors = [(c[0],c[1],c[2],c[3]*s) for c,s in zip(colors,sats)] - return colors - -def patch_draw(self, renderer): - orig_offsets = self._offsets - xs,ys = zip(*self._offsets) - xs,ys,zs = juggle_axes(xs,ys,self.zs,self.dir) - xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M) - # mess with colors - orig_fcolors = self._facecolors - orig_ecolors = self._edgecolors - self._facecolors = zalpha(orig_fcolors,zs) - self._edgecolors = zalpha(orig_ecolors,zs) - - self._offsets = zip(xs,ys) - self.old_draw(renderer) - self._offsets = orig_offsets - self._facecolors = orig_fcolors - self._edgecolors = orig_ecolors - -def wrap_patch(patch, zs, dir='z'): - return Patch3DCollectionW(patch, zs, dir) - -def draw_linec(self, renderer): - orig_segments = self._segments - segments_3d = [[(x,y,z) for (x,y),z in zip(points,zs)] - for zs, points in zip(self.zs, self._segments)] - xyslist = [ - proj3d.proj_trans_points(points, renderer.M) for points in - segments_3d] - segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist] - self._segments = segments_2d - LineCollection.draw(self, renderer) - self._segments = orig_segments - -def draw_polyc(self, renderer): - orig_segments = self._verts - # process the list of lists of 2D points held in _verts to generate - # a list of lists of 3D points - segments_3d = [[(x,y,z) for (x,y),z in zip(points,self.zs)] - for points in self._verts] - # - xyslist = [ - proj3d.proj_trans_points(points, renderer.M) for points in - segments_3d] - segments_2d = [zip(xs,ys) for (xs,ys,zs) in xyslist] - self._verts = segments_2d - PolyCollection.draw(self, renderer) - self._verts = orig_segments - -def text_draw(self, renderer): - x,y = self.get_position() - xs,ys,zs = juggle_axes(x,y,self._z,self.dir) - xs,ys,zs = proj3d.proj_transform(xs,ys,zs, renderer.M) - self.set_x(xs) - self.set_y(ys) - self.old_draw(renderer) - self.set_x(x) - self.set_y(y) - -def wrap_text(text, zs, dir='z'): - text._z = zs - text.dir = dir - text.old_draw = text.draw - def wrapped_draw(renderer,text=text): - return text_draw(text,renderer) - text.draw = wrapped_draw - -def set_text_data(text, x,y,z): - text._x,text._y,text._z = x,y,z - -def draw(text, renderer): - print 'call draw text', text - print text.get_visible() - print 'text "%s"' % text._text - res = text._get_layout(renderer) - print res - text._draw(renderer) - -def owrap(text): - text._draw = text.draw - def draw_text(renderer,text=text): - draw(text,renderer) - text.draw = draw_text - -def wrap_2d_fn(patch, zs,dir='z',fn=patch_draw): - patch.zs = zs - patch.dir = dir - patch.old_draw = patch.draw - def wrapped_draw(renderer,patch=patch,fn=fn): - return fn(patch,renderer) - patch.draw = wrapped_draw - return patch Modified: trunk/matplotlib/lib/matplotlib/axes3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes3d.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/lib/matplotlib/axes3d.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,835 +1 @@ -#!/usr/bin/python -# axes3d.py -# -# Created: 23 Sep 2005 -# -""" -3D projection glued onto 2D Axes. - -Axes3D -""" - -import random - -from axes import Axes -import cbook -from transforms import unit_bbox - -import numpy as np -from colors import Normalize - -import art3d -import proj3d -import axis3d - -def sensible_format_data(self, value): - """Used to generate more comprehensible numbers in status bar""" - if abs(value) > 1e4 or abs(value)<1e-3: - s = '%1.4e'% value - return self._formatSciNotation(s) - else: - return '%4.3f' % value - -class Axes3DI(Axes): - """Wrap an Axes object - - The x,y data coordinates, which are manipulated by set_xlim and - set_ylim are used as the target view coordinates by the 3D - transformations. These coordinates are mostly invisible to the - outside world. - - set_w_xlim, set_w_ylim and set_w_zlim manipulate the 3D world - coordinates which are scaled to represent the data and are stored - in the xy_dataLim, zz_datalim bboxes. - - The axes representing the x,y,z world dimensions are self.w_xaxis, - self.w_yaxis and self.w_zaxis. They can probably be controlled in - more or less the normal ways. - """ - def __init__(self, fig, rect=[0.0, 0.0, 1.0, 1.0], *args, **kwargs): - self.fig = fig - - azim = cbook.popd(kwargs, 'azim', -60) - elev = cbook.popd(kwargs, 'elev', 30) - - self.xy_viewLim = unit_bbox() - self.zz_viewLim = unit_bbox() - self.xy_dataLim = unit_bbox() - self.zz_dataLim = unit_bbox() - # inihibit autoscale_view until the axises are defined - # they can't be defined until Axes.__init__ has been called - self._ready = 0 - Axes.__init__(self, self.fig, rect, - frameon=True, - xticks=[], yticks=[], *args, **kwargs) - - self.M = None - self._ready = 1 - - self.view_init(elev, azim) - self.mouse_init() - self.create_axes() - self.set_top_view() - - #self.axesPatch.set_edgecolor((1,0,0,0)) - self.axesPatch.set_linewidth(0) - #self.axesPatch.set_facecolor((0,0,0,0)) - self.fig.add_axes(self) - - def set_top_view(self): - # this happens to be the right view for the viewing coordinates - # moved up and to the left slightly to fit labels and axes - xdwl = (0.95/self.dist) - xdw = (0.9/self.dist) - ydwl = (0.95/self.dist) - ydw = (0.9/self.dist) - # - self.set_xlim(-xdwl,xdw) - self.set_ylim(-ydwl,ydw) - - def really_set_xlim(self, vmin, vmax): - self.viewLim.intervalx().set_bounds(vmin, vmax) - - def really_set_ylim(self, vmin, vmax): - self.viewLim.intervaly().set_bounds(vmin, vmax) - - def vlim_argument(self, get_lim, *args): - if not args: - vmin,vmax = get_lim() - elif len(args)==2: - vmin,vmax = args - elif len(args)==1: - vmin,vmax = args[0] - return vmin,vmax - - def nset_xlim(self, *args): - raise - vmin,vmax = self.vlim_argument(self.get_xlim) - print 'xlim', vmin,vmax - - def nset_ylim(self, *args): - vmin,vmax = self.vlim_argument(self.get_ylim) - print 'ylim', vmin,vmax - - def create_axes(self): - self.w_xaxis = axis3d.Axis('x',self.xy_viewLim.intervalx, - self.xy_dataLim.intervalx, self) - self.w_yaxis = axis3d.Axis('y',self.xy_viewLim.intervaly, - self.xy_dataLim.intervaly, self) - self.w_zaxis = axis3d.Axis('z',self.zz_viewLim.intervalx, - self.zz_dataLim.intervalx, self) - - def unit_cube(self,vals=None): - minpy,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims() - xs,ys,zs = ([minpy,maxx,maxx,minpy,minpy,maxx,maxx,minpy], - [miny,miny,maxy,maxy,miny,miny,maxy,maxy], - [minz,minz,minz,minz,maxz,maxz,maxz,maxz]) - return zip(xs,ys,zs) - - def tunit_cube(self,vals=None,M=None): - if M is None: - M = self.M - xyzs = self.unit_cube(vals) - tcube = proj3d.proj_points(xyzs,M) - return tcube - - def tunit_edges(self, vals=None,M=None): - tc = self.tunit_cube(vals,M) - edges = [(tc[0],tc[1]), - (tc[1],tc[2]), - (tc[2],tc[3]), - (tc[3],tc[0]), - - (tc[0],tc[4]), - (tc[1],tc[5]), - (tc[2],tc[6]), - (tc[3],tc[7]), - - (tc[4],tc[5]), - (tc[5],tc[6]), - (tc[6],tc[7]), - (tc[7],tc[4])] - return edges - - def draw(self, renderer): - # draw the background patch - self.axesPatch.draw(renderer) - self._frameon = False - - # add the projection matrix to the renderer - self.M = self.get_proj() - renderer.M = self.M - renderer.vvec = self.vvec - renderer.eye = self.eye - renderer.get_axis_position = self.get_axis_position - - #self.set_top_view() - self.w_xaxis.draw(renderer) - self.w_yaxis.draw(renderer) - self.w_zaxis.draw(renderer) - Axes.draw(self, renderer) - - def get_axis_position(self): - vals = self.get_w_lims() - tc = self.tunit_cube(vals,self.M) - xhigh = tc[1][2]>tc[2][2] - yhigh = tc[3][2]>tc[2][2] - zhigh = tc[0][2]>tc[2][2] - return xhigh,yhigh,zhigh - - def update_datalim(self, xys): - pass - - def update_datalim_numerix(self, x, y): - pass - - def auto_scale_xyz(self, X,Y,Z=None,had_data=None): - x,y,z = map(np.asarray, (X,Y,Z)) - try: - x,y = X.flat,Y.flat - if Z is not None: - z = Z.flat - except AttributeError: - pass - - self.xy_dataLim.update_numerix(x, y, not had_data) - if z is not None: - self.zz_dataLim.update_numerix(z, z, not had_data) - self.autoscale_view() - - def autoscale_view(self, scalex=True, scaley=True, scalez=True): - self.set_top_view() - if not self._ready: return - - if not self._autoscaleon: return - - if scalex: - locator = self.w_xaxis.get_major_locator() - self.set_w_xlim(locator.autoscale()) - if scaley: - locator = self.w_yaxis.get_major_locator() - self.set_w_ylim(locator.autoscale()) - if scalez: - locator = self.w_zaxis.get_major_locator() - self.set_w_zlim(locator.autoscale()) - - def get_w_lims(self): - minpy,maxx = self.get_w_xlim() - miny,maxy = self.get_w_ylim() - minz,maxz = self.get_w_zlim() - return minpy,maxx,miny,maxy,minz,maxz - - def set_w_zlim(self, *args, **kwargs): - gl,self.get_xlim = self.get_xlim,self.get_w_zlim - vl,self.viewLim = self.viewLim,self.zz_viewLim - vmin,vmax = Axes.set_xlim(self, *args, **kwargs) - self.get_xlim = gl - self.viewLim = vl - return vmin,vmax - - def set_w_xlim(self, *args, **kwargs): - gl,self.get_xlim = self.get_xlim,self.get_w_xlim - vl,self.viewLim = self.viewLim,self.xy_viewLim - vmin,vmax = Axes.set_xlim(self, *args, **kwargs) - self.get_xlim = gl - self.viewLim = vl - return vmin,vmax - - def set_w_ylim(self, *args, **kwargs): - gl,self.get_ylim = self.get_ylim,self.get_w_ylim - vl,self.viewLim = self.viewLim,self.xy_viewLim - vmin,vmax = Axes.set_ylim(self, *args, **kwargs) - self.get_ylim = gl - self.viewLim = vl - return vmin,vmax - - def get_w_zlim(self): - return self.zz_viewLim.intervalx().get_bounds() - - def get_w_xlim(self): - return self.xy_viewLim.intervalx().get_bounds() - - def get_w_ylim(self): - return self.xy_viewLim.intervaly().get_bounds() - - def pany(self, numsteps): - print 'numsteps', numsteps - - def panpy(self, numsteps): - print 'numsteps', numsteps - - def view_init(self, elev, azim): - self.dist = 10 - self.elev = elev - self.azim = azim - - def get_proj(self): - """Create the projection matrix from the current viewing - position. - - elev stores the elevation angle in the z plane - azim stores the azimuth angle in the x,y plane - - dist is the distance of the eye viewing point from the object - point. - - """ - relev,razim = np.pi * self.elev/180, np.pi * self.azim/180 - - xmin,xmax = self.get_w_xlim() - ymin,ymax = self.get_w_ylim() - zmin,zmax = self.get_w_zlim() - - # transform to uniform world coordinates 0-1.0,0-1.0,0-1.0 - worldM = proj3d.world_transformation(xmin,xmax, - ymin,ymax, - zmin,zmax) - - # look into the middle of the new coordinates - R = np.array([0.5,0.5,0.5]) - # - xp = R[0] + np.cos(razim)*np.cos(relev)*self.dist - yp = R[1] + np.sin(razim)*np.cos(relev)*self.dist - zp = R[2] + np.sin(relev)*self.dist - - E = np.array((xp, yp, zp)) - # - self.eye = E - self.vvec = R - E - self.vvec = self.vvec / proj3d.mod(self.vvec) - - if abs(relev) > np.pi/2: - # upside down - V = np.array((0,0,-1)) - else: - V = np.array((0,0,1)) - zfront,zback = -self.dist,self.dist - - viewM = proj3d.view_transformation(E,R,V) - perspM = proj3d.persp_transformation(zfront,zback) - M0 = np.dot(viewM,worldM) - M = np.dot(perspM,M0) - return M - - def mouse_init(self): - self.button_pressed = None - if self.figure.canvas != None: - self.figure.canvas.mpl_connect('motion_notify_event', self.on_move) - self.figure.canvas.mpl_connect('button_press_event', self.button_press) - self.figure.canvas.mpl_connect('button_release_event', self.button_release) - - def button_press(self, event): - self.button_pressed = event.button - self.sx,self.sy = event.xdata,event.ydata - - def button_release(self, event): - self.button_pressed = None - - def format_xdata(self, x): - """ - Return x string formatted. This function will use the attribute - self.fmt_xdata if it is callable, else will fall back on the xaxis - major formatter - """ - try: return self.fmt_xdata(x) - except TypeError: - fmt = self.w_xaxis.get_major_formatter() - return sensible_format_data(fmt,x) - - def format_ydata(self, y): - """ - Return y string formatted. This function will use the attribute - self.fmt_ydata if it is callable, else will fall back on the yaxis - major formatter - """ - try: return self.fmt_ydata(y) - except TypeError: - fmt = self.w_yaxis.get_major_formatter() - return sensible_format_data(fmt,y) - - def format_zdata(self, z): - """ - Return y string formatted. This function will use the attribute - self.fmt_ydata if it is callable, else will fall back on the yaxis - major formatter - """ - try: return self.fmt_zdata(z) - except (AttributeError,TypeError): - fmt = self.w_zaxis.get_major_formatter() - return sensible_format_data(fmt,z) - - def format_coord(self, xd, yd): - """Given the 2D view coordinates attempt to guess a 3D coordinate - - Looks for the nearest edge to the point and then assumes that the point is - at the same z location as the nearest point on the edge. - """ - - if self.button_pressed == 1: - return 'azimuth=%d deg, elevation=%d deg ' % (self.azim, self.elev) - # ignore xd and yd and display angles instead - - p = (xd,yd) - edges = self.tunit_edges() - #lines = [proj3d.line2d(p0,p1) for (p0,p1) in edges] - ldists = [(proj3d.line2d_seg_dist(p0,p1,p),i) for i,(p0,p1) in enumerate(edges)] - ldists.sort() - # nearest edge - edgei = ldists[0][1] - # - p0,p1 = edges[edgei] - - # scale the z value to match - x0,y0,z0 = p0 - x1,y1,z1 = p1 - d0 = np.hypot(x0-xd,y0-yd) - d1 = np.hypot(x1-xd,y1-yd) - dt = d0+d1 - z = d1/dt * z0 + d0/dt * z1 - #print 'mid', edgei, d0, d1, z0, z1, z - - x,y,z = proj3d.inv_transform(xd,yd,z,self.M) - - xs = self.format_xdata(x) - ys = self.format_ydata(y) - zs = self.format_ydata(z) - return 'x=%s, y=%s, z=%s'%(xs,ys,zs) - - def on_move(self, event): - """Mouse moving - - button-1 rotates - button-3 zooms - """ - if not self.button_pressed: - return - - if self.M is None: - return - # this shouldn't be called before the graph has been drawn for the first time! - - x, y = event.xdata, event.ydata - dx,dy = x-self.sx,y-self.sy - x0,x1 = self.get_xlim() - y0,y1 = self.get_ylim() - w = (x1-x0) - h = (y1-y0) - self.sx,self.sy = x,y - - if self.button_pressed == 1: - # rotate viewing point - # get the x and y pixel coords - if dx == 0 and dy == 0: return - # - self.elev = axis3d.norm_angle(self.elev - (dy/h)*180) - self.azim = axis3d.norm_angle(self.azim - (dx/w)*180) - self.get_proj() - self.figure.canvas.draw() - elif self.button_pressed == 2: - # pan view - # project xv,yv,zv -> xw,yw,zw - # pan - # - pass - elif self.button_pressed == 3: - # zoom view - # hmmm..this needs some help from clipping.... - minpy,maxx,miny,maxy,minz,maxz = self.get_w_lims() - df = 1-((h - dy)/h) - dx = (maxx-minpy)*df - dy = (maxy-miny)*df - dz = (maxz-minz)*df - self.set_w_xlim(minpy-dx,maxx+dx) - self.set_w_ylim(miny-dy,maxy+dy) - self.set_w_zlim(minz-dz,maxz+dz) - self.get_proj() - self.figure.canvas.draw() - - def set_xlabel(self, xlabel, fontdict=None, **kwargs): - #par = cbook.popd(kwargs, 'par',None) - #label.set_par(par) - # - label = self.w_xaxis.get_label() - label.set_text(xlabel) - if fontdict is not None: label.update(fontdict) - label.update(kwargs) - return label - - def set_ylabel(self, ylabel, fontdict=None, **kwargs): - label = self.w_yaxis.get_label() - label.set_text(ylabel) - if fontdict is not None: label.update(fontdict) - label.update(kwargs) - return label - - def set_zlabel(self, zlabel, fontdict=None, **kwargs): - label = self.w_zaxis.get_label() - label.set_text(zlabel) - if fontdict is not None: label.update(fontdict) - label.update(kwargs) - return label - - def plot(self, *args, **kwargs): - had_data = self.has_data() - - zval = cbook.popd(kwargs, 'z', 0) - zdir = cbook.popd(kwargs, 'dir', 'z') - lines = Axes.plot(self, *args, **kwargs) - # - linecs = [art3d.Line2DW(l, z=zval, dir=zdir) for l in lines] - # - xs = lines[0].get_xdata() - ys = lines[0].get_ydata() - zs = [zval for x in xs] - xs,ys,zs = art3d.juggle_axes(xs,ys,zs,zdir) - # - self.auto_scale_xyz(xs,ys,zs, had_data) - # - return linecs - - def plot3D(self, xs, ys, zs, *args, **kwargs): - had_data = self.has_data() - lines = Axes.plot(self, xs,ys, *args, **kwargs) - if len(lines)==1: - line = lines[0] - art3d.wrap_line(line, zs) - # - self.auto_scale_xyz(xs,ys,zs, had_data) - return lines - - plot3d=plot3D - - def plot_surface(self, X, Y, Z, *args, **kwargs): - had_data = self.has_data() - - rows, cols = Z.shape - tX,tY,tZ = np.transpose(X), np.transpose(Y), np.transpose(Z) - rstride = cbook.popd(kwargs, 'rstride', 10) - cstride = cbook.popd(kwargs, 'cstride', 10) - # - polys = [] - boxes = [] - for rs in np.arange(0,rows-1,rstride): - for cs in np.arange(0,cols-1,cstride): - ps = [] - corners = [] - for a,ta in [(X,tX),(Y,tY),(Z,tZ)]: - ztop = a[rs][cs:min(cols,cs+cstride+1)] - zleft = ta[min(cols-1,cs+cstride)][rs:min(rows,rs+rstride+1)] - zbase = a[min(rows-1,rs+rstride)][cs:min(cols,cs+cstride+1):] - zbase = zbase[::-1] - zright = ta[cs][rs:min(rows,rs+rstride+1):] - zright = zright[::-1] - corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]]) - z = np.concatenate((ztop,zleft,zbase,zright)) - ps.append(z) - boxes.append(map(np.array,zip(*corners))) - polys.append(zip(*ps)) - # - lines = [] - shade = [] - for box in boxes: - n = proj3d.cross(box[0]-box[1], - box[0]-box[2]) - n = n/proj3d.mod(n)*5 - shade.append(np.dot(n,[-1,-1,0.5])) - lines.append((box[0],n+box[0])) - # - color = np.array([0,0,1,1]) - norm = Normalize(min(shade),max(shade)) - colors = [color * (0.5+norm(v)*0.5) for v in shade] - for c in colors: c[3] = 1 - polyc = art3d.Poly3DCollection(polys, facecolors=colors, *args, **kwargs) - polyc._zsort = 1 - self.add_collection(polyc) - # - self.auto_scale_xyz(X,Y,Z, had_data) - return polyc - - def plot_wireframe(self, X, Y, Z, *args, **kwargs): - rstride = cbook.popd(kwargs, "rstride", 1) - cstride = cbook.popd(kwargs, "cstride", 1) - - had_data = self.has_data() - rows,cols = Z.shape - - tX,tY,tZ = np.transpose(X), np.transpose(Y), np.transpose(Z) - - rii = [i for i in range(0,rows,rstride)]+[rows-1] - cii = [i for i in range(0,cols,cstride)]+[cols-1] - xlines = [X[i] for i in rii] - ylines = [Y[i] for i in rii] - zlines = [Z[i] for i in rii] - # - txlines = [tX[i] for i in cii] - tylines = [tY[i] for i in cii] - tzlines = [tZ[i] for i in cii] - # - lines = [zip(xl,yl,zl) for xl,yl,zl in zip(xlines,ylines,zlines)] - lines += [zip(xl,yl,zl) for xl,yl,zl in zip(txlines,tylines,tzlines)] - linec = self.add_lines(lines, *args, **kwargs) - - self.auto_scale_xyz(X,Y,Z, had_data) - return linec - - def contour3D(self, X, Y, Z, *args, **kwargs): - had_data = self.has_data() - cset = self.contour(X, Y, Z, *args, **kwargs) - for z,linec in zip(cset.levels,cset.collections): - zl = [] - linew = art3d.Line2DCollectionW(linec, z) - self.auto_scale_xyz(X,Y,Z, had_data) - return cset - - def clabel(self, *args, **kwargs): - r = Axes.clabel(self, *args, **kwargs) - return r - - def contourf3D(self, X, Y, Z, *args, **kwargs): - raise NotImplementedError("contourf3D is broken") - had_data = self.has_data() - - cset = self.contourf(X, Y, Z, *args, **kwargs) - levels = cset.levels - colls = cset.collections - for z1,z2,linec in zip(levels,levels[1:],colls): - zs = [z1] * (len(linec._verts[0])/2) - zs += [z2] * (len(linec._verts[0])/2) - # The following is clearly wrong. - art3d.wrap_patch(linec, zs, fn=art3d.draw_polyc) - self.auto_scale_xyz(X,Y,Z, had_data) - return cset - - def scatter3D(self, xs, ys, zs, *args, **kwargs): - had_data = self.has_data() - patches = Axes.scatter(self,xs,ys,*args,**kwargs) - patches = art3d.wrap_patch(patches, zs) - # - self.auto_scale_xyz(xs,ys,zs, had_data) - return patches - scatter3d = scatter3D - - def add_lines(self, lines, *args, **kwargs): - linec = art3d.Line3DCollection(lines, *args, **kwargs) - self.add_collection(linec) - return linec - - def text3D(self, x,y,z,s, *args, **kwargs): - text = Axes.text(self,x,y,s,*args,**kwargs) - art3d.wrap_text(text,z) - return text - - def ahvline(self, x,y): - pass - - def ahvxplane(self, x): - pass - - def ahvyplane(self, y): - pass - -class Scaler: - def __init__(self, points): - self.inpoints = points - self.drawpoints = None - - def update(self, lims): - for x,y,z in self.points: - pass - -class Axes3D: - """ - Wrapper for Axes3DI - - Provides set_xlim, set_ylim etc. - - 2D functions can be caught here and mapped - to their 3D approximations. - - This should probably be the case for plot etc... - """ - def __init__(self, fig, *args, **kwargs): - self.__dict__['wrapped'] = Axes3DI(fig, *args, **kwargs) - - def set_xlim(self, *args, **kwargs): - self.wrapped.set_w_xlim(*args, **kwargs) - - def set_ylim(self, *args, **kwargs): - self.wrapped.set_w_ylim(*args, **kwargs) - - def set_zlim(self, *args, **kwargs): - self.wrapped.set_w_zlim(*args, **kwargs) - - def __getattr__(self, k): - return getattr(self.wrapped,k) - - def __setattr__(self, k,v): - return setattr(self.wrapped,k,v) - - def add_collection(self, polys, zs=None, dir='z'): - patches = art3d.Poly3DCollectionW(polys, zs=zs,dir=dir) - self.add_3DCollection(patches) - - def add_3DCollection(self, patches): - self.wrapped.add_collection(patches) - - def text(self, x,y, text, *args,**kwargs): - self.wrapped.text3D(x,y,0,text,*args,**kwargs) - - def scatter(self, xs,ys,zs=None,dir='z',*args,**kwargs): - patches = self.wrapped.scatter(xs,ys,*args,**kwargs) - if zs is None: - zs = [0]*len(xs) - patches = art3d.wrap_patch(patches, zs=zs, dir=dir) - return patches - - def bar(self, left, height, z=0, dir='z', *args, **kwargs): - had_data = self.has_data() - patches = self.wrapped.bar(left, height, *args, **kwargs) - # - verts = [] - for p in patches: - vs = p.get_verts() - zs = [z]*len(vs) - verts += vs - patch3d = art3d.Patch3D(p, zs, dir=dir) - xs,ys = zip(*verts) - zs = [z]*len(xs) - xs,ys,zs=art3d.juggle_axes(xs,ys,zs,dir) - self.wrapped.auto_scale_xyz(xs,ys,zs, had_data) - -def test_scatter(): - - ax = Axes3D() - # - # - n = 100 - for c,zl,zh in [('r',-50,-25),('b',-30,-5)]: - xs,ys,zs = zip(* - [(random.randrange(23,32), - random.randrange(100), - random.randrange(zl,zh) - ) for i in range(n)]) - ax.scatter3D(xs,ys,zs, c=c) - # - ax.set_xlabel('------------ X Label --------------------') - ax.set_ylabel('------------ Y Label --------------------') - ax.set_zlabel('------------ Z Label --------------------') - -def get_test_data(delta=0.05): - from mlab import bivariate_normal - x = y = np.arange(-3.0, 3.0, delta) - X, Y = np.meshgrid(x,y) - - Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) - Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) - Z = Z2-Z1 - - X = X * 10 - Y = Y * 10 - Z = Z * 500 - return X,Y,Z - -def test_wire(): - ax = Axes3D() - - X,Y,Z = get_test_data(0.05) - ax.plot_wireframe(X,Y,Z, rstride=10,cstride=10) - # - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - -def test_surface(): - ax = Axes3D() - - X,Y,Z = get_test_data(0.05) - ax.plot_surface(X,Y,Z, rstride=10,cstride=10) - # - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - - -def test_contour(): - ax = Axes3D() - - X,Y,Z = get_test_data(0.05) - cset = ax.contour3D(X,Y,Z) - ax.clabel(cset, fontsize=9, inline=1) - # - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - -def test_plot(): - ax = Axes3D() - xs = np.arange(0,4*np.pi+0.1,0.1) - ys = np.sin(xs) - ax.plot(xs,ys, label='zl') - ax.plot(xs,ys+max(xs),label='zh') - ax.plot(xs,ys,dir='x', label='xl') - ax.plot(xs,ys,dir='x', z=max(xs),label='xh') - ax.plot(xs,ys,dir='y', label='yl') - ax.plot(xs,ys,dir='y', z=max(xs), label='yh') - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - ax.legend() - - -def test_polys(): - from matplotlib.collections import LineCollection, PolyCollection - from matplotlib.colors import colorConverter - - cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6) - - ax = Axes3D() - xs = np.arange(0,10,0.4) - verts = [] - zs = [0.0,1.0,2.0,3.0] - for z in zs: - ys = [random.random() for x in xs] - ys[0],ys[-1] = 0,0 - verts.append(zip(xs,ys)) - - poly = PolyCollection(verts, facecolors = [cc('r'),cc('g'),cc('b'), - cc('y')]) - #patches = art3d.Poly3DCollectionW(poly, zs=zs, dir='y') - #poly = PolyCollection(verts) - ax.add_collection(poly,zs=zs,dir='y') - #ax.wrapped.add_collection(poly) - # - ax.plot(xs,ys, z=z, dir='y', c='r') - ax.set_xlim(0,10) - ax.set_ylim(-1,4) - ax.set_zlim(0,1) - -def test_scatter2D(): - xs = [random.random() for i in range(20)] - ys = [random.random() for x in xs] - ax = Axes3D() - ax.scatter(xs,ys) - ax.scatter(xs,ys, dir='y', c='r') - ax.scatter(xs,ys, dir='x', c='g') - -def test_bar2D(): - ax = Axes3D() - - for c,z in zip(['r','g','b','y'],[30,20,10,0]): - xs = np.arange(20) - ys = [random.random() for x in xs] - ax.bar(xs,ys,z=z,dir='y',color=c) - #ax.plot(xs,ys) - -if __name__ == "__main__": - import pylab - #test_scatter() - #test_wire() - #test_surface() - #test_contour() - #test_plot() - test_polys() - #test_scatter2D() - test_bar2D() - pylab.show() +raise NotImplmentedError('axes3d is not supported in matplotlib-0.98. You may want to try the 0.91.x maintenance branch') Deleted: trunk/matplotlib/lib/matplotlib/axis3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis3d.py 2008年06月22日 08:19:56 UTC (rev 5628) +++ trunk/matplotlib/lib/matplotlib/axis3d.py 2008年06月22日 13:52:43 UTC (rev 5629) @@ -1,394 +0,0 @@ -#!/usr/bin/python -# axis3d.py -# -# Created: 23 Sep 2005 - -import math - -import lines -import axis -import patches -import text - -import art3d -import proj3d - -import numpy as np - -def norm_angle(a): - """Return angle between -180 and +180""" - a = (a+360)%360 - if a > 180: a = a-360 - return a - -def text_update_coords(self, renderer): - """Modified method update_coords from TextWithDash - - I could not understand the original text offset calculations and - it gave bad results for the angles I was using. This looks - better, although the text bounding boxes look a little - inconsistent - """ - - (x, y) = self.get_position() - dashlength = self.get_dashlength() - - # Shortcircuit this process if we don't have a dash - if dashlength == 0.0: - self._mytext.set_position((x, y)) - return - - dashrotation = self.get_dashrotation() - dashdirection = self.get_dashdirection() - dashpad = self.get_dashpad() - dashpush = self.get_dashpush() - transform = self.get_transform() - - angle = text.get_rotation(dashrotation) - - theta = math.pi*(angle/180.0+dashdirection-1) - cos_theta, sin_theta = math.cos(theta), math.sin(theta) - - # Compute the dash end points - # The 'c' prefix is for canvas coordinates - cxy = np.array(transform.xy_tup((x, y))) - cd = np.array([cos_theta, sin_theta]) - c1 = cxy+dashpush*cd - c2 = cxy+(dashpush+dashlength)*cd - (x1, y1) = transform.inverse_xy_tup(tuple(c1)) - (x2, y2) = transform.inverse_xy_tup(tuple(c2)) - self.dashline.set_data((x1, x2), (y1, y2)) - - # We now need to extend this vector out to - # the center of the text area. - # The basic problem here is that we're "rotating" - # two separate objects but want it to appear as - # if they're rotated together. - # This is made non-trivial because of the - # interaction between text rotation and alignment - - # text alignment is based on the bbox after rotation. - # We reset/force both alignments to 'center' - # so we can do something relatively reasonable. - # There's probably a better way to do this by - # embedding all this in the object's transformations, - # but I don't grok the transformation stuff - # well enough yet. - we = self._mytext.get_window_extent(renderer=renderer) - w, h = we.width(), we.height() - off = np.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1]) - off = np.array([cos_theta*(w/2),sin_theta*(h/2)]) - dir = np.array([cos_theta,sin_theta])*dashpad - cw = c2 + off +dir - - self._mytext.set_position(transform.inverse_xy_tup(tuple(cw))) - # Now set the window extent - # I'm not at all sure this is the right way to do this. - we = self._mytext.get_window_extent(renderer=renderer) - self._window_extent = we.deepcopy() - self._window_extent.update(((c1[0], c1[1]),), False) - - # Finally, make text align center - self._mytext.set_horizontalalignment('center') - self._mytext.set_verticalalignment('center') - -def tick_update_position(tick, x,y,z, angle): - # - tick.tick1On = False - tick.tick2On = False - tick.tick1line.set_data((x, x),(y,y)) - tick.tick2line.set_data((x, x),(y,y)) - tick.gridline.set_data((x, x),(y,y)) - # - tick.label1.set_dashlength(8) - tick.label1.set_dashrotation(angle) - tick.label1.set_position((x,y)) - tick.label2.set_position((x,y)) - -class Axis(axis.XAxis): - def __init__(self, adir, v_intervalx, d_intervalx, axes, *args, **kwargs): - # adir identifies which axes this is - self.adir = adir - # data and viewing intervals for this direction - self.d_interval = d_intervalx - self.v_interval = v_intervalx - # - axis.XAxis.__init__(self, axes, *args, **kwargs) - self.line = lines.Line2D(xdata=(0,0),ydata=(0,0), - linewidth=0.75, - color=(0,0,0,0), - antialiased=True, - ) - # - # these are the panes which surround the boundary of the view - self.pane_bg_color = (0.95,0.95,0.95,0.1) - self.pane_fg_color = (0.9,0.9,0.9,0.5) - self.pane = patches.Polygon([], - alpha=0.2, - facecolor=self.pane_fg_color, - edgecolor=self.pane_fg_color) - # - self.axes._set_artist_props(self.line) - self.axes._set_artist_props(self.pane) - self.gridlines = art3d.Line3DCollection([]) - self.axes._set_artist_props(self.gridlines) - self.axes._set_artist_props(self.label) - self.label._transform = self.axes.transData - - def get_tick_positions(self): - majorTicks = self.get_major_ticks() - majorLocs = self.major.locator() - self.major.formatter.set_locs(majorLocs) - majorLabels = [self.major.formatter(val, i) for i, val in enumerate(majorLocs)] - return majorLabels,majorLocs - - def get_major_ticks(self): - ticks = axis.XAxis.get_major_ticks(self) - for t in ticks: - def update_coords(renderer,self=t.label1): - return text_update_coords(self, renderer) - # Text overrides setattr so need this to force new method - #t.label1.__dict__['update_coords'] = update_coords - t.tick1line.set_transform(self.axes.transData) - t.tick2line.set_transform(self.axes.transData) - t.gridline.set_transform(self.axes.transData) - t.label1.set_transform(self.axes.transData) - t.label2.set_transform(self.axes.transData) - # - return ticks - - def set_pane_fg(self, xys): - self.pane.xy = xys - self.pane.set_edgecolor(self.pane_fg_color) - self.pane.set_facecolor(self.pane_fg_color) - self.pane.set_alpha(self.pane_fg_color[-1]) - - def set_pane_bg(self, xys): - self.pane.xy = xys - self.pane.set_edgecolor(self.pane_bg_color) - self.pane.set_facecolor(self.pane_bg_color) - self.pane.set_alpha(self.pane_bg_color[-1]) - - def draw(self, renderer): - # - self.label._transform = self.axes.transData - renderer.open_group('axis3d') - ticklabelBoxes = [] - ticklabelBoxes2 = [] - - # code from XAxis - majorTicks = self.get_major_ticks() - majorLocs = self.major.locator() - self.major.formatter.set_locs(majorLocs) - majorLabels = [self.major.formatter(val, i) - for i, val in enumerate(majorLocs)] - # - minx,maxx,miny,maxy,minz,maxz = self.axes.get_w_lims() - - interval = self.get_view_interval() - # filter locations here so that no extra grid lines are drawn - majorLocs = [loc for loc in majorLocs if interval.contains(loc)] - # these will generate spacing for labels and ticks - dx = (maxx-minx)/12 - dy = (maxy-miny)/12 - dz = (maxz-minz)/12 - - # stretch the boundary slightly so that the ticks have a better fit - minx,maxx,miny,maxy,minz,maxz = ( - minx-dx/4,maxx+dx/4,miny-dy/4,maxy+dy/4,minz-dz/4,maxz+dz/4) - - # generate the unit_cubes and transformed unit_cubes from the stretched - # limits - vals = minx,maxx,miny,maxy,minz,maxz - uc = self.axes.unit_cube(vals) - tc = self.axes.tunit_cube(vals,renderer.M) - # - # these are flags which decide whether the axis should be drawn - # on the high side (ie on the high side of the paired axis) - xhigh = tc[1][2]>tc[2][2] - yhigh = tc[3][2]>tc[2][2] - zhigh = tc[0][2]>tc[2][2] - # - aoff = 0 - - # lx,ly,lz are the label positions in user coordinates - # to and te are the locations of the origin and the end of the axis - # - if self.adir == 'x': - lx = (minx+maxx)/2 - if xhigh: - # xaxis at front - self.set_pane_fg([tc[0],tc[1],tc[5],tc[4]]) - to = tc[3] - te = tc[2] - xyz = [(x,maxy,minz) for x in majorLocs] - nxyz = [(x,miny,minz) for x in majorLocs] - lxyz = [(x,miny,maxz) for x in majorLocs] - aoff = -90 - - ly = maxy + dy - lz = minz - dz - else: - self.set_pane_bg([tc[3],tc[2],tc[6],tc[7]]) - to = tc[0] - te = tc[1] - xyz = [(x,miny,minz) for x in majorLocs] - nxyz = [(x,maxy,minz) for x in majorLocs] - lxyz = [(x,maxy,maxz) for x in majorLocs] - aoff = 90 - - ly = miny - dy - lz = minz - dz - - elif self.adir == 'y': - # cube 3 is minx,maxy,minz - # cube 2 is maxx,maxy,minz - ly = (maxy+miny)/2 - if yhigh: - # yaxis at front - self.set_pane_fg([tc[0],tc[3],tc[7],tc[4]]) - to = tc[1] - te = tc[2] - xyz = [(maxx,y,minz) for y in majorLocs] - nxyz = [(minx,y,minz) for y in majorLocs] - lxyz = [(minx,y,maxz) for y in majorLocs] - aoff = 90 - - # - lx = maxx + dx - lz = minz - dz - - else: - # yaxis at back - self.set_pane_bg([tc[1],tc[5],tc[6],tc[2]]) - to = tc[0] - te = tc[3] - xyz = [(minx,y,minz) for y in majorLocs] - nxyz = [(maxx,y,minz) for y in majorLocs] - lxyz = [(maxx,y,maxz) for y in majorLocs] - aoff = -90 - # - lx = minx - dx - lz = minz - dz - - elif self.adir == 'z': - nxyz = None - self.set_pane_bg([tc[0],tc[1],tc[2],tc[3]]) - aoff = -90 - lz = (maxz+minz)/2 - if xhigh and yhigh: - to = tc[1] - te = tc[5] - xyz = [(maxx,miny,z) for z in majorLocs] - nxyz = [(minx,miny,z) for z in ma... [truncated message content]
Revision: 5625 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5625&view=rev Author: dsdale Date: 2008年06月21日 06:35:30 -0700 (2008年6月21日) Log Message: ----------- improve mlab.load docstring to address bug 1901536 Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/mlab.py Modified: branches/v0_91_maint/lib/matplotlib/mlab.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/mlab.py 2008年06月21日 13:28:57 UTC (rev 5624) +++ branches/v0_91_maint/lib/matplotlib/mlab.py 2008年06月21日 13:35:30 UTC (rev 5625) @@ -1236,14 +1236,14 @@ skiprows is the number of rows from the top to skip usecols, if not None, is a sequence of integer column indexes to - extract where 0 is the first column, eg usecols=(1,4,5) to extract + extract where 0 is the first column, eg usecols=[1,4,5] to extract just the 2nd, 5th and 6th columns unpack, if True, will transpose the matrix allowing you to unpack into named arguments on the left hand side t,y = load('test.dat', unpack=True) # for two column data - x,y,z = load('somefile.dat', usecols=(3,5,7), unpack=True) + x,y,z = load('somefile.dat', usecols=[3,5,7], unpack=True) See examples/load_demo.py which exeercises many of these options. """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5618 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5618&view=rev Author: jdh2358 Date: 2008年06月20日 10:09:12 -0700 (2008年6月20日) Log Message: ----------- added origin support for composite images Modified Paths: -------------- trunk/matplotlib/examples/api/mathtext_asarray.py trunk/matplotlib/examples/pylab_examples/figimage_demo.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/src/_gtkagg.cpp trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/examples/api/mathtext_asarray.py =================================================================== --- trunk/matplotlib/examples/api/mathtext_asarray.py 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/examples/api/mathtext_asarray.py 2008年06月20日 17:09:12 UTC (rev 5618) @@ -10,6 +10,7 @@ parser = mathtext.MathTextParser("Bitmap") + parser.to_png('test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100) @@ -20,5 +21,4 @@ fig.figimage(rgba1.astype(float)/255., 100, 100) fig.figimage(rgba2.astype(float)/255., 100, 300) - plt.show() Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008年06月20日 17:09:12 UTC (rev 5618) @@ -13,8 +13,9 @@ im1 = figimage(Z, xo=50, yo=0) im2 = figimage(Z, xo=100, yo=100, alpha=.8) #gray() # overrides current and sets default -savefig('figimage_demo') +#savefig('figimage_demo') show() + Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年06月20日 17:09:12 UTC (rev 5618) @@ -1442,6 +1442,9 @@ im = mimage.from_images(height, width, ims) + if self.images[0].origin=='upper': + im.flipud_out() + im.is_grayscale = False l, b, w, h = self.bbox.bounds # composite images need special args so they will not Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008年06月20日 17:09:12 UTC (rev 5618) @@ -47,7 +47,7 @@ class FigureCanvasGTKAgg(FigureCanvasGTK, FigureCanvasAgg): filetypes = FigureCanvasGTK.filetypes.copy() filetypes.update(FigureCanvasAgg.filetypes) - + def configure_event(self, widget, event=None): if DEBUG: print 'FigureCanvasGTKAgg.configure_event' @@ -80,6 +80,14 @@ ren = self.get_renderer() w = int(ren.width) h = int(ren.height) + + # There apparently is a bug here on some versions of pygtk + # (2.6) that crops up in corner cases. Eg, in + # figimage_demo.py, there is background pixel noise because + # the figure frame is off and the blended image background has + # alpha 0. and you see the uninitialzed data ("screen noise"). + # If in _image.cpp Image:from_image you fill the background + # with a non transparent value, it goes away. pixbuf = gtk.gdk.pixbuf_new_from_data( buf, gtk.gdk.COLORSPACE_RGB, True, 8, w, h, w*4) pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h, Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008年06月20日 17:09:12 UTC (rev 5618) @@ -807,6 +807,9 @@ im = _image.from_images(self.bbox.height * mag, self.bbox.width * mag, ims) + if self.images[0].origin=='upper': + im.flipud_out() + im.is_grayscale = False l, b, w, h = self.bbox.bounds clippath, affine = self.get_transformed_clip_path_and_affine() Modified: trunk/matplotlib/src/_gtkagg.cpp =================================================================== --- trunk/matplotlib/src/_gtkagg.cpp 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/src/_gtkagg.cpp 2008年06月20日 17:09:12 UTC (rev 5618) @@ -94,8 +94,9 @@ destrbuf.attach(destbuffer, destwidth, destheight, deststride); pixfmt destpf(destrbuf); renderer_base destrb(destpf); - //destrb.clear(agg::rgba(1, 0, 0)); + //destrb.clear(agg::rgba(1, 1, 1, 0)); + agg::rect_base<int> region(destx, desty, (int)r, srcheight-(int)b); destrb.copy_from(*aggRenderer->renderingBuffer, ®ion, -destx, -desty); Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2008年06月20日 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/src/_image.cpp 2008年06月20日 17:09:12 UTC (rev 5618) @@ -739,11 +739,14 @@ renderer_base rb(pixf); + //clear the background of the rendering buffer with alpha 1 and the + //gtkagg screen noise problem in figimage_demo.py goes away -- see + //comment backend_gtkagg.py _render_figure method JDH + //rb.clear(agg::rgba(1, 1, 1, 1)); + for (size_t imnum=0; imnum< N; imnum++) { tup = Py::Tuple(tups[imnum]); Image* thisim = static_cast<Image*>(tup[0].ptr()); - if (imnum==0) - rb.clear(thisim->bg); ox = Py::Int(tup[1]); oy = Py::Int(tup[2]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5619 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5619&view=rev Author: mdboom Date: 2008年06月20日 10:23:55 -0700 (2008年6月20日) Log Message: ----------- Make legend less hacky looking, with a "cute" math expression. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/mathtext_demo.py Modified: trunk/matplotlib/examples/pylab_examples/mathtext_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/mathtext_demo.py 2008年06月20日 17:09:12 UTC (rev 5618) +++ trunk/matplotlib/examples/pylab_examples/mathtext_demo.py 2008年06月20日 17:23:55 UTC (rev 5619) @@ -20,10 +20,10 @@ ax.text(1, 1.6, tex, fontsize=20, va='bottom') -ax.legend(("Foo", "Testing $x^2$")) +ax.legend([r"$\sqrt{x^2}$"]) ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} \Delta_{i+1}^j$', fontsize=20) -#fig.savefig('mathtext_demo') +fig.savefig('mathtext_demo') show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5623 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5623&view=rev Author: dsdale Date: 2008年06月21日 06:09:07 -0700 (2008年6月21日) Log Message: ----------- fix marker placement bug in backend_ps Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年06月20日 19:46:05 UTC (rev 5622) +++ trunk/matplotlib/CHANGELOG 2008年06月21日 13:09:07 UTC (rev 5623) @@ -1,3 +1,5 @@ +2008年06月21日 fix marker placement bug in backend_ps - DSD + 2008年06月20日 [ 1978629 ] scale documentation missing/incorrect for log - MGD 2008年06月20日 Added closed kwarg to PolyCollection. Fixes bug [ 1994535 Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年06月20日 19:46:05 UTC (rev 5622) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年06月21日 13:09:07 UTC (rev 5623) @@ -501,7 +501,7 @@ tpath = trans.transform_path(path) for x, y in tpath.vertices: - ps_cmd.append("%1.3g %1.3g o" % (x, y)) + ps_cmd.append("%g %g o" % (x, y)) ps = '\n'.join(ps_cmd) self._draw_ps(ps, gc, rgbFace, fill=False, stroke=False) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5622 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5622&view=rev Author: mdboom Date: 2008年06月20日 12:46:05 -0700 (2008年6月20日) Log Message: ----------- Lots more docstring formatting. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/artist.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2008年06月20日 18:43:08 UTC (rev 5621) +++ trunk/matplotlib/lib/matplotlib/artist.py 2008年06月20日 19:46:05 UTC (rev 5622) @@ -268,12 +268,16 @@ return self.figure is not None def get_figure(self): - 'return the figure instance' + """ + Return the :class:`~matplotlib.figure.Figure` instance the + artist belongs to. + """ return self.figure def set_figure(self, fig): """ - Set the figure instance the artist belong to + Set the :class:`~matplotlib.figure.Figure` instance the artist + belongs to. ACCEPTS: a matplotlib.figure.Figure instance """ @@ -476,7 +480,7 @@ self.pchanged() def update_from(self, other): - 'copy properties from other to self' + 'Copy properties from *other* to *self*.' self._transform = other._transform self._transformSet = other._transformSet self._visible = other._visible @@ -504,15 +508,17 @@ class ArtistInspector: """ - A helper class to inspect an Artist and return information about - it's settable properties and their current values + A helper class to inspect an :class:`~matplotlib.artist.Artist` + and return information about it's settable properties and their + current values. """ def __init__(self, o): """ - Initialize the artist inspector with an artist or sequence of - artists. Id a sequence is used, we assume it is a homogeneous - sequence (all Artists are of the same type) and it is your - responsibility to make sure this is so. + Initialize the artist inspector with an + :class:`~matplotlib.artist.Artist` or sequence of + :class:`Artists`. If a sequence is used, we assume it is a + homogeneous sequence (all :class:`Artists` are of the same + type) and it is your responsibility to make sure this is so. """ if cbook.iterable(o) and len(o): o = o[0] self.o = o @@ -520,9 +526,11 @@ def get_aliases(self): """ - get a dict mapping fullname -> alias for each alias in o. - Eg for lines:: + Get a dict mapping *fullname* -> *alias* for each alias in the + :class:`~matplotlib.artist.ArtistInspector`. + Eg., for lines:: + {'markerfacecolor': 'mfc', 'linewidth' : 'lw', } @@ -543,12 +551,12 @@ _get_valid_values_regex = re.compile(r"\n\s*ACCEPTS:\s*(.*)\n") def get_valid_values(self, attr): """ - get the legal arguments for the setter associated with attr + Get the legal arguments for the setter associated with *attr*. - This is done by querying the doc string of the function set_attr + This is done by querying the docstring of the function set_ *attr* for a line that begins with ACCEPTS: - Eg, for a line linestyle, return + Eg., for a line linestyle, return [ '-' | '--' | '-.' | ':' | 'steps' | 'None' ] """ @@ -570,8 +578,8 @@ def get_setters(self): """ - Get the attribute strings with setters for object h. Eg, for a line, - return ['markerfacecolor', 'linewidth', ....] + Get the attribute strings with setters for object. Eg., for a line, + return ``['markerfacecolor', 'linewidth', ....]``. """ setters = [] @@ -585,7 +593,10 @@ return setters def is_alias(self, o): - 'return true if method object o is an alias for another function' + """ + Return *True* if method object *o* is an alias for another + function. + """ ds = o.__doc__ if ds is None: return False return ds.startswith('alias for ') @@ -605,12 +616,12 @@ def pprint_setters(self, prop=None, leadingspace=2): """ - if prop is None, return a list of strings of all settable properies - and their valid values + If *prop* is *None*, return a list of strings of all settable properies + and their valid values. - if prop is not None, it is a valid property name and that + If *prop* is not *None*, it is a valid property name and that property will be returned as a string of property : valid - values + values. """ if leadingspace: pad = ' '*leadingspace @@ -655,7 +666,7 @@ def pprint_getters(self): """ - return the getters and actual values as list of strings' + Return the getters and actual values as list of strings. """ getters = [name for name in dir(self.o) if name.startswith('get_') @@ -678,6 +689,8 @@ def getp(o, *args): """ + .. TODO: What are 's' and 'h' arguments described below? + Return the value of handle property s h is an instance of a class, eg a Line2D or an Axes or Text. @@ -751,8 +764,8 @@ with python kwargs. For example, the following are equivalent >>> setp(lines, 'linewidth', 2, 'color', r') # matlab style + >>> setp(lines, linewidth=2, color='r') # python style - """ insp = ArtistInspector(h) Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008年06月20日 18:43:08 UTC (rev 5621) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008年06月20日 19:46:05 UTC (rev 5622) @@ -11,7 +11,7 @@ from matplotlib import verbose import artist from artist import Artist -from cbook import iterable, is_string_like, is_numlike, ls_mapper +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 @@ -25,34 +25,34 @@ # COVERAGE NOTE: Never called internally or from examples def unmasked_index_ranges(mask, compressed = True): ''' - Calculate the good data ranges in a masked 1-D np.array, based on mask. + Calculate the good data ranges in a masked 1-D np.array, based on + mask. - Returns Nx2 np.array with each row the start and stop indices - for slices of the compressed np.array corresponding to each of N - uninterrupted runs of unmasked values. - If optional argument compressed is False, it returns the - start and stop indices into the original np.array, not the - compressed np.array. - Returns None if there are no unmasked values. + Returns Nx2 :class:`numpy.array` with each row the start and stop + indices for slices of the compressed :class:`numpy.array` + corresponding to each of *N* uninterrupted runs of unmasked + values. If optional argument *compressed* is *False*, it returns + the start and stop indices into the original :class:`numpy.array`, + not the compressed :class:`numpy.array`. Returns *None* if there + are no unmasked values. - Example: + Example:: - y = ma.array(np.arange(5), mask = [0,0,1,0,0]) - #ii = unmasked_index_ranges(y.mask()) - ii = unmasked_index_ranges(ma.getmask(y)) - # returns [[0,2,] [2,4,]] + y = ma.array(np.arange(5), mask = [0,0,1,0,0]) + #ii = unmasked_index_ranges(y.mask()) + ii = unmasked_index_ranges(ma.getmask(y)) + # returns [[0,2,] [2,4,]] - y.compressed().filled()[ii[1,0]:ii[1,1]] - # returns np.array [3,4,] - # (The 'filled()' method converts the masked np.array to a numerix np.array.) + y.compressed().filled()[ii[1,0]:ii[1,1]] + # returns np.array [3,4,] + # (The 'filled()' method converts the masked np.array to a numerix np.array.) - #i0, i1 = unmasked_index_ranges(y.mask(), compressed=False) - i0, i1 = unmasked_index_ranges(ma.getmask(y), compressed=False) - # returns [[0,3,] [2,5,]] + #i0, i1 = unmasked_index_ranges(y.mask(), compressed=False) + i0, i1 = unmasked_index_ranges(ma.getmask(y), compressed=False) + # returns [[0,3,] [2,5,]] - y.filled()[ii[1,0]:ii[1,1]] - # returns np.array [3,4,] - + y.filled()[ii[1,0]:ii[1,1]] + # returns np.array [3,4,] ''' m = np.concatenate(((1,), mask, (1,))) indices = np.arange(len(mask) + 1) @@ -195,38 +195,11 @@ **kwargs ): """ - Create a Line2D instance with x and y data in sequences xdata, - ydata + Create a :class:`~matplotlib.lines.Line2D` instance with *x* + and *y* data in sequences *xdata*, *ydata*. The kwargs are Line2D properties: - alpha: float - animated: [True | False] - antialiased or aa: [True | False] - clip_box: a matplotlib.transform.Bbox instance - clip_on: [True | False] - color or c: any matplotlib color - dash_capstyle: ['butt' | 'round' | 'projecting'] - dash_joinstyle: ['miter' | 'round' | 'bevel'] - dashes: sequence of on/off ink in points - data: (np.array xdata, np.array ydata) - figure: a matplotlib.figure.Figure instance - label: any string - linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ] - linewidth or lw: float value in points - lod: [True | False] - marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4' ] - markeredgecolor or mec: any matplotlib color - markeredgewidth or mew: float value in points (default 5) - markerfacecolor or mfc: any matplotlib color - markersize or ms: float - pickradius: mouse event radius for pick items in points (default 5) - solid_capstyle: ['butt' | 'round' | 'projecting'] - solid_joinstyle: ['miter' | 'round' | 'bevel'] - transform: a matplotlib.transform transformation instance - visible: [True | False] - xdata: np.array - ydata: np.array - zorder: any number + %(Line2D)s """ Artist.__init__(self) @@ -290,12 +263,16 @@ self.set_data(xdata, ydata) def contains(self, mouseevent): - """Test whether the mouse event occurred on the line. The pick radius determines - the precision of the location test (usually within five points of the value). Use - get/set pickradius() to view or modify it. + """ + Test whether the mouse event occurred on the line. The pick + radius determines the precision of the location test (usually + within five points of the value). Use + :meth:`~matplotlib.lines.Line2D.get_pickradius`/:meth:`~matplotlib.lines.Line2D.set_pickradius` + to view or modify it. - Returns True if any values are within the radius along with {'ind': pointlist}, - np.where pointlist is the set of points within the radius. + Returns *True* if any values are within the radius along with + ``{'ind': pointlist}``, where *pointlist* is the set of points + within the radius. TODO: sort returned indices by distance """ @@ -530,14 +507,20 @@ def get_markersize(self): return self._markersize def get_data(self, orig=True): - 'return the xdata, ydata; if orig is True, return the original data' + """ + Return the xdata, ydata. + + If *orig* is *True*, return the original data + """ return self.get_xdata(orig=orig), self.get_ydata(orig=orig) def get_xdata(self, orig=True): """ - return the xdata; if orig is true return the original data, - else the processed data + Return the xdata. + + If *orig* is *True*, return the original data, else the + processed data. """ if orig: return self._xorig @@ -547,8 +530,10 @@ def get_ydata(self, orig=True): """ - return the ydata; if orig is true return the original data, - else the processed data + Return the ydata. + + If *orig* is *True*, return the original data, else the + processed data. """ if orig: return self._yorig @@ -558,13 +543,17 @@ def get_path(self): """ - Return the Path object associated with this line. + Return the :class:`~matplotlib.path.Path` object associated + with this line. """ if self._invalid: self.recache() return self._path def get_xydata(self): + """ + Return the *xy* data as a Nx2 numpy array. + """ if self._invalid: self.recache() return self._xy @@ -1140,6 +1129,7 @@ def set_dash_capstyle(self, s): """ Set the cap style for dashed linestyles + ACCEPTS: ['butt' | 'round' | 'projecting'] """ s = s.lower() @@ -1153,6 +1143,7 @@ def set_solid_capstyle(self, s): """ Set the cap style for solid linestyles + ACCEPTS: ['butt' | 'round' | 'projecting'] """ s = s.lower() @@ -1183,9 +1174,10 @@ class VertexSelector: """ - manage the callbacks to maintain a list of selected vertices for - matplotlib.lines.Line2D. Derived classes should override - process_selected to do something with the picks + Manage the callbacks to maintain a list of selected vertices for + :class:`matplotlib.lines.Line2D`. Derived classes should override + :meth:`~matplotlib.lines.VertexSelector.process_selected` to do + something with the picks. Here is an example which highlights the selected verts with red circles:: @@ -1214,9 +1206,10 @@ """ def __init__(self, line): """ - Initialize the class with a matplotlib.lines.Line2D instance. - The line should already be added to some matplotlib.axes.Axes - instance and should have the picker property set. + Initialize the class with a :class:`matplotlib.lines.Line2D` + instance. The line should already be added to some + :class:`matplotlib.axes.Axes` instance and should have the + picker property set. """ if not hasattr(line, 'axes'): raise RuntimeError('You must first add the line to the Axes') @@ -1234,15 +1227,16 @@ def process_selected(self, ind, xs, ys): """ - Default do nothing implementation of the process_selected method. + Default "do nothing" implementation of the + :meth:`process_selected` method. - ind are the indices of the selected vertices. xs and ys are - the coordinates of the selected vertices. + *ind* are the indices of the selected vertices. *xs* and *ys* + are the coordinates of the selected vertices. """ pass def onpick(self, event): - 'when the line is picked, update the set of selected indicies' + 'When the line is picked, update the set of selected indicies.' if event.artist is not self.line: return for i in event.ind: @@ -1261,3 +1255,7 @@ lineMarkers = Line2D._markers artist.kwdocd['Line2D'] = artist.kwdoc(Line2D) + +# You can not set the docstring of an instancemethod, +# but you can on the underlying function. Go figure. +Line2D.__init__.im_func.__doc__ = dedent(Line2D.__init__.__doc__) % artist.kwdocd Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008年06月20日 18:43:08 UTC (rev 5621) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008年06月20日 19:46:05 UTC (rev 5622) @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from __future__ import division import math @@ -40,11 +42,10 @@ class Patch(artist.Artist): """ - A patch is a 2D thingy with a face color and an edge color + A patch is a 2D thingy with a face color and an edge color. - If any of edgecolor, facecolor, linewidth, or antialiased are - None, they default to their rc params setting - + If any of *edgecolor*, *facecolor*, *linewidth*, or *antialiased* + are *None*, they default to their rc params setting. """ zorder = 1 def __str__(self): @@ -82,9 +83,9 @@ def get_verts(self): """ - return a copy of the vertices used in this patch + Return a copy of the vertices used in this patch - If the patch contains Bezier curves, the curves will be + If the patch contains Bézier curves, the curves will be interpolated by line segments. To access the curves as curves, use :meth:`get_path`. """ @@ -205,23 +206,24 @@ """ Set the hatching pattern - hatch can be one of: - / - diagonal hatching - \ - back diagonal - | - vertical - - - horizontal - # - crossed - x - crossed diagonal - letters can be combined, in which case all the specified - hatchings are done - if same letter repeats, it increases the density of hatching - in that direction + hatch can be one of:: + / - diagonal hatching + \ - back diagonal + | - vertical + - - horizontal + # - crossed + x - crossed diagonal + + Letters can be combined, in which case all the specified + hatchings are done. If same letter repeats, it increases the + density of hatching in that direction. + CURRENT LIMITATIONS: - 1. Hatching is supported in the PostScript - backend only. - 2. Hatching is done with solid black lines of width 0. + 1. Hatching is supported in the PostScript backend only. + + 2. Hatching is done with solid black lines of width 0. """ self._hatch = h @@ -280,9 +282,10 @@ def __init__(self, patch, ox, oy, props=None, **kwargs): """ - Create a shadow of the patch offset by ox, oy. props, if not None is - a patch property update dictionary. If None, the shadow will have - have the same color as the face, but darkened + Create a shadow of the given *patch* offset by *ox*, *oy*. + *props*, if not *None*, is a patch property update dictionary. + If *None*, the shadow will have have the same color as the face, + but darkened. kwargs are %(Patch)s @@ -332,9 +335,8 @@ class Rectangle(Patch): """ - Draw a rectangle with lower left at xy=(x,y) with specified + Draw a rectangle with lower left at *xy*=(*x*, *y*) with specified width and height - """ def __str__(self): @@ -343,12 +345,8 @@ def __init__(self, xy, width, height, **kwargs): """ - xy is an x,y tuple lower, left + *fill* is a boolean indicating whether to fill the rectangle - width and height are width and height of rectangle - - fill is a boolean indicating whether to fill the rectangle - Valid kwargs are: %(Patch)s """ @@ -462,11 +460,18 @@ def __init__(self, xy, numVertices, radius=5, orientation=0, **kwargs): """ - xy is a length 2 tuple (the center) - numVertices is the number of vertices. - radius is the distance from the center to each of the vertices. - orientation is in radians and rotates the polygon. + *xy* + A length 2 tuple (*x*, *y*) of the center. + *numVertices* + the number of vertices. + + *radius* + The distance from the center to each of the vertices. + + *orientation* + rotates the polygon (in radians). + Valid kwargs are: %(Patch)s """ @@ -528,7 +533,7 @@ def __init__(self, path, **kwargs): """ - path is a Path object + *path* is a :class:`matplotlib.path.Path` object. Valid kwargs are: %(Patch)s @@ -550,8 +555,11 @@ def __init__(self, xy, closed=True, **kwargs): """ - xy is a numpy array with shape Nx2 + *xy* is a numpy array with shape Nx2. + If *closed* is *True*, the polygon will be closed so the + starting and ending points are the same. + Valid kwargs are: %(Patch)s See Patch documentation for additional kwargs @@ -580,23 +588,30 @@ xy = xy[0:-1] self._set_xy(xy) - def _get_xy(self): + def get_xy(self): return self._path.vertices - def _set_xy(self, vertices): + def set_xy(self, vertices): self._path = Path(vertices) - xy = property(_get_xy, _set_xy) + xy = property( + get_xy, set_xy, None, + """Set/get the vertices of the polygon. This property is + provided for backward compatibility with matplotlib 0.91.x + only. New code should use + :meth:`~matplotlib.patches.Polygon.get_xy` and + :meth:`~matplotlib.patches.Polygon.set_xy` instead.""") class Wedge(Patch): def __str__(self): return "Wedge(%g,%g)"%self.xy[0] + def __init__(self, center, r, theta1, theta2, **kwargs): """ - Draw a wedge centered at x,y tuple center with radius r that - sweeps theta1 to theta2 (angles) + Draw a wedge centered at *x*, *y* center with radius *r* that + sweeps *theta1* to *theta2* (in degrees). Valid kwargs are: + %(Patch)s - """ Patch.__init__(self, **kwargs) self.center = center @@ -621,7 +636,7 @@ # COVERAGE NOTE: Not used internally or from examples class Arrow(Patch): """ - An arrow patch + An arrow patch. """ def __str__(self): return "Arrow()" @@ -633,8 +648,9 @@ [ 0.8, 0.1 ], [ 0.0, 0.1] ] ) def __init__( self, x, y, dx, dy, width=1.0, **kwargs ): - """Draws an arrow, starting at (x,y), direction and length - given by (dx,dy) the width of the arrow is scaled by width + """ + Draws an arrow, starting at (*x*, *y*), direction and length + given by (*dx*, *dy*) the width of the arrow is scaled by *width*. Valid kwargs are: %(Patch)s @@ -658,7 +674,9 @@ return self._patch_transform class FancyArrow(Polygon): - """Like Arrow, but lets you set head width and head height independently.""" + """ + Like Arrow, but lets you set head width and head height independently. + """ def __str__(self): return "FancyArrow()" @@ -666,18 +684,20 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, \ head_width=None, head_length=None, shape='full', overhang=0, \ head_starts_at_zero=False,**kwargs): - """Returns a new Arrow. + """ + *length_includes_head*: + *True* if head is counted in calculating the length. - length_includes_head: True if head is counted in calculating the length. + *shape*: ['full', 'left', 'right'] - shape: ['full', 'left', 'right'] + *overhang*: + distance that the arrow is swept back (0 overhang means + triangular shape). - overhang: distance that the arrow is swept back (0 overhang means - triangular shape). + *head_starts_at_zero*: + If *True*, the head starts being drawn at coordinate 0 + instead of ending at coordinate 0. - head_starts_at_zero: if True, the head starts being drawn at coordinate - 0 instead of ending at coordinate 0. - Valid kwargs are: %(Patch)s @@ -731,23 +751,35 @@ class YAArrow(Patch): """ - Yet another arrow class + Yet another arrow class. This is an arrow that is defined in display space and has a tip at - x1,y1 and a base at x2, y2. + *x1*, *y1* and a base at *x2*, *y2*. """ def __str__(self): return "YAArrow()" def __init__(self, figure, xytip, xybase, width=4, frac=0.1, headwidth=12, **kwargs): """ - xytip : (x,y) location of arrow tip - xybase : (x,y) location the arrow base mid point - figure : the figure instance (fig.dpi) - width : the width of the arrow in points - frac : the fraction of the arrow length occupied by the head - headwidth : the width of the base of the arrow head in points + *xytip* + (*x*, *y*) location of arrow tip + *xybase* + (*x*, *y*) location the arrow base mid point + + *figure* + The :class:`~matplotlib.figure.Figure` instance + (fig.dpi) + + *width* + The width of the arrow in points + + *frac* + The fraction of the arrow length occupied by the head + + *headwidth* + The width of the base of the arrow head in points + Valid kwargs are: %(Patch)s @@ -790,9 +822,10 @@ def getpoints(self, x1,y1,x2,y2, k): """ - for line segment defined by x1,y1 and x2,y2, return the points on - the line that is perpendicular to the line and intersects x2,y2 - and the distance from x2,y2 ot the returned points is k + For line segment defined by (*x1*, *y1*) and (*x2*, *y2*) + return the points on the line that is perpendicular to the + line and intersects (*x2*, *y2*) and the distance from (*x2*, + *y2*) of the returned points is *k*. """ x1,y1,x2,y2,k = map(float, (x1,y1,x2,y2,k)) m = (y2-y1)/(x2-x1) @@ -811,7 +844,7 @@ class CirclePolygon(RegularPolygon): """ - A circle patch + A polygon-approximation of a circle patch. """ def __str__(self): return "CirclePolygon(%d,%d)"%self.center @@ -820,7 +853,10 @@ resolution=20, # the number of vertices **kwargs): """ - Create a circle at xy=(x,y) with radius given by 'radius' + Create a circle at *xy* = (*x*, *y*) with given *radius*. + This circle is approximated by a regular polygon with + *resolution* sides. For a smoother circle drawn with splines, + see :class:`~matplotlib.patches.Circle`. Valid kwargs are: %(Patch)s @@ -836,18 +872,25 @@ class Ellipse(Patch): """ - A scale-free ellipse + A scale-free ellipse. """ def __str__(self): return "Ellipse(%s,%s;%sx%s)"%(self.center[0],self.center[1],self.width,self.height) def __init__(self, xy, width, height, angle=0.0, **kwargs): """ - xy - center of ellipse - width - length of horizontal axis - height - length of vertical axis - angle - rotation in degrees (anti-clockwise) + *xy* + center of ellipse + *width* + length of horizontal axis + + *height* + length of vertical axis + + *angle* + rotation in degrees (anti-clockwise) + Valid kwargs are: %(Patch)s """ @@ -888,16 +931,17 @@ class Circle(Ellipse): """ - A circle patch + A circle patch. """ def __str__(self): return "Circle((%g,%g),r=%g)"%(self.center[0],self.center[1],self.radius) def __init__(self, xy, radius=5, **kwargs): """ - Create true circle at center xy=(x,y) with given radius; - unlike circle polygon which is a polygonal approcimation, this - uses splines and is much closer to a scale free circle + Create true circle at center *xy* = (*x*, *y*) with given + *radius*. Unlike :class:`~matplotlib.patches.CirclePolygon` + which is a polygonal approximation, this uses Bézier splines + and is much closer to a scale-free circle. Valid kwargs are: %(Patch)s @@ -917,27 +961,40 @@ An elliptical arc. Because it performs various optimizations, it can not be filled. - The arc must be used in an Axes instance it cannot be added - directly to a Figure) because it is optimized to only render the - segments that are inside the axes bounding box with high - resolution. + The arc must be used in an :class:`~matplotlib.axes.Axes` + instance---it cannot be added directly to a + :class:`~matplotlib.figure.Figure`---because it is optimized to + only render the segments that are inside the axes bounding box + with high resolution. """ def __str__(self): return "Arc(%s,%s;%sx%s)"%(self.center[0],self.center[1],self.width,self.height) def __init__(self, xy, width, height, angle=0.0, theta1=0.0, theta2=360.0, **kwargs): """ - xy - center of ellipse - width - length of horizontal axis - height - length of vertical axis - angle - rotation in degrees (anti-clockwise) - theta1 - starting angle of the arc in degrees - theta2 - ending angle of the arc in degrees + *xy* + center of ellipse - If theta1 and theta2 are not provided, the arc will form a + *width* + length of horizontal axis + + *height* + length of vertical axis + + *angle* + rotation in degrees (anti-clockwise) + + *theta1* + starting angle of the arc in degrees + + *theta2* + ending angle of the arc in degrees + + If *theta1* and *theta2* are not provided, the arc will form a complete ellipse. Valid kwargs are: + %(Patch)s """ fill = kwargs.pop('fill') @@ -974,24 +1031,26 @@ (8). The algorithm proceeds as follows: 1. The points where the ellipse intersects the axes bounding - box are located. (This is done be performing an inverse - transformation on the axes bbox such that it is relative to - the unit circle -- this makes the intersection calculation - much easier than doing rotated ellipse intersection - directly). + box are located. (This is done be performing an inverse + transformation on the axes bbox such that it is relative + to the unit circle -- this makes the intersection + calculation much easier than doing rotated ellipse + intersection directly). - This uses the "line intersecting a circle" algorithm from: + This uses the "line intersecting a circle" algorithm + from: - Vince, John. Geometry for Computer Graphics: Formulae, - Examples & Proofs. London: Springer-Verlag, 2005. + Vince, John. Geometry for Computer Graphics: Formulae, + Examples & Proofs. London: Springer-Verlag, 2005. 2. The angles of each of the intersection points are - calculated. + calculated. 3. Proceeding counterclockwise starting in the positive - x-direction, each of the visible arc-segments between the - pairs of vertices are drawn using the bezier arc - approximation technique implemented in Path.arc(). + x-direction, each of the visible arc-segments between the + pairs of vertices are drawn using the bezier arc + approximation technique implemented in + :meth:`matplotlib.path.Path.arc`. """ if not hasattr(self, 'axes'): raise RuntimeError('Arcs can only be used in Axes instances') @@ -1100,11 +1159,12 @@ def bbox_artist(artist, renderer, props=None, fill=True): """ This is a debug function to draw a rectangle around the bounding - box returned by get_window_extent of an artist, to test whether - the artist is returning the correct bbox + box returned by + :meth:`~matplotlib.artist.Artist.get_window_extent` of an artist, + to test whether the artist is returning the correct bbox. - props is a dict of rectangle props with the additional property - 'pad' that sets the padding around the bbox in points + *props* is a dict of rectangle props with the additional property + 'pad' that sets the padding around the bbox in points. """ if props is None: props = {} props = props.copy() # don't want to alter the pad externally @@ -1130,8 +1190,9 @@ def draw_bbox(bbox, renderer, color='k', trans=None): """ This is a debug function to draw a rectangle around the bounding - box returned by get_window_extent of an artist, to test whether - the artist is returning the correct bbox + box returned by + :meth:`~matplotlib.artist.Artist.get_window_extent` of an artist, + to test whether the artist is returning the correct bbox. """ l,b,w,h = bbox.get_bounds() @@ -1147,5 +1208,5 @@ artist.kwdocd['Patch'] = patchdoc = artist.kwdoc(Patch) for k in ('Rectangle', 'Circle', 'RegularPolygon', 'Polygon', 'Wedge', 'Arrow', - 'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse'): + 'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse', 'Arc'): artist.kwdocd[k] = patchdoc Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008年06月20日 18:43:08 UTC (rev 5621) +++ trunk/matplotlib/lib/matplotlib/text.py 2008年06月20日 19:46:05 UTC (rev 5622) @@ -97,7 +97,8 @@ **kwargs ): """ - Create a Text instance at x,y with string text. + Create a :class:`~matplotlib.text.Text` instance at *x*, *y* + with string *text*. Valid kwargs are %(Text)s @@ -648,50 +649,51 @@ class TextWithDash(Text): """ - This is basically a Text with a dash (drawn with a Line2D) - before/after it. It is intended to be a drop-in replacement - for Text, and should behave identically to Text when - dashlength=0.0. + This is basically a :class:`~matplotlib.text.Text` with a dash + (drawn with a :class:`~matplotlib.lines.Line2D`) before/after + it. It is intended to be a drop-in replacement for + :class:`~matplotlib.text.Text`, and should behave identically to + it when *dashlength* = 0.0. The dash always comes between the point specified by - set_position() and the text. When a dash exists, the - text alignment arguments (horizontalalignment, - verticalalignment) are ignored. + :meth:`~matplotlib.text.Text.set_position` and the text. When a + dash exists, the text alignment arguments (*horizontalalignment*, + *verticalalignment*) are ignored. - dashlength is the length of the dash in canvas units. - (default=0.0). + *dashlength* is the length of the dash in canvas units. + (default = 0.0). - dashdirection is one of 0 or 1, np.where 0 draws the dash - after the text and 1 before. - (default=0). + *dashdirection* is one of 0 or 1, where 0 draws the dash after the + text and 1 before. (default = 0). - dashrotation specifies the rotation of the dash, and - should generally stay None. In this case - self.get_dashrotation() returns self.get_rotation(). - (I.e., the dash takes its rotation from the text's - rotation). Because the text center is projected onto - the dash, major deviations in the rotation cause + *dashrotation* specifies the rotation of the dash, and should + generally stay *None*. In this case + :meth:`~matplotlib.text.TextWithDash.get_dashrotation` returns + :meth:`~matplotlib.text.Text.get_rotation`. (I.e., the dash takes + its rotation from the text's rotation). Because the text center is + projected onto the dash, major deviations in the rotation cause what may be considered visually unappealing results. - (default=None). + (default = *None*) - dashpad is a padding length to add (or subtract) space + *dashpad* is a padding length to add (or subtract) space between the text and the dash, in canvas units. - (default=3). + (default = 3) - dashpush "pushes" the dash and text away from the point - specified by set_position() by the amount in canvas units. - (default=0) + *dashpush* "pushes" the dash and text away from the point + specified by :meth:`~matplotlib.text.Text.set_position` by the + amount in canvas units. (default = 0) - NOTE: The alignment of the two objects is based on the - bbox of the Text, as obtained by get_window_extent(). - This, in turn, appears to depend on the font metrics - as given by the rendering backend. Hence the quality - of the "centering" of the label text with respect to - the dash varies depending on the backend used. + *NOTE*: The alignment of the two objects is based on the bounding + box of the :class:`~matplotlib.text.Text`, as obtained by + :meth:`~matplotlib.artist.Artist.get_window_extent`. This, in + turn, appears to depend on the font metrics as given by the + rendering backend. Hence the quality of the "centering" of the + label text with respect to the dash varies depending on the + backend used. - NOTE2: I'm not sure that I got the get_window_extent() - right, or whether that's sufficient for providing the - object bbox. + *NOTE 2*: I'm not sure that I got the + :meth:`~matplotlib.text.TextWithDash.get_window_extent` right, or + whether that's sufficient for providing the object bounding box. """ __name__ = 'textwithdash' @@ -749,11 +751,11 @@ def get_prop_tup(self): """ - Return a hashable tuple of properties + Return a hashable tuple of properties. Not intended to be human readable, but useful for backends who want to cache derived information about text (eg layouts) and - need to know if the text has changed + need to know if the text has changed. """ props = [p for p in Text.get_prop_tup(self)] props.extend([self._x, self._y, self._dashlength, self._dashdirection, self._dashrotation, self._dashpad, self._dashpush]) @@ -973,8 +975,10 @@ class Annotation(Text): """ - A Text class to make annotating things in the figure: Figure, - Axes, Point, Rectangle, etc... easier + A :class:`~matplotlib.text.Text` class to make annotating things + in the figure, such as :class:`~matplotlib.figure.Figure`, + :class:`~matplotlib.axes.Axes`, + :class:`~matplotlib.patches.Rectangle`, etc., easier. """ def __str__(self): return "Annotation(%g,%g,%s)"%(self.xy[0],self.xy[1],self._text) @@ -985,9 +989,9 @@ arrowprops=None, **kwargs): """ - Annotate the *x*, *y* point *xy* with text *s* at *x*, *y* location *xytext*. - (If *xytext* = *None*, defaults to *xy*, and if *textcoords* = *None*, defaults - to *xycoords*). + Annotate the *x*, *y* point *xy* with text *s* at *x*, *y* + location *xytext*. (If *xytext* = *None*, defaults to *xy*, + and if *textcoords* = *None*, defaults to *xycoords*). *arrowprops*, if not *None*, is a dictionary of line properties (see :class:`matplotlib.lines.Line2D`) for the arrow that connects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5621 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5621&view=rev Author: jdh2358 Date: 2008年06月20日 11:43:08 -0700 (2008年6月20日) Log Message: ----------- start of a menu widget Added Paths: ----------- trunk/matplotlib/examples/widgets/menu.py Added: trunk/matplotlib/examples/widgets/menu.py =================================================================== --- trunk/matplotlib/examples/widgets/menu.py (rev 0) +++ trunk/matplotlib/examples/widgets/menu.py 2008年06月20日 18:43:08 UTC (rev 5621) @@ -0,0 +1,140 @@ +import numpy as np +import matplotlib +import matplotlib.patches as patches +import matplotlib.mathtext as mathtext +import matplotlib.pyplot as plt +import matplotlib.artist as artist +import matplotlib.image as image + +matplotlib.rc('image', origin='upper') + +class MenuItem(artist.Artist): + parser = mathtext.MathTextParser("Bitmap") + padx = 5 + pady =5 + def __init__(self, fig, labelstr): + artist.Artist.__init__(self) + self.set_figure(fig) + + + x, self.depth = self.parser.to_rgba( + labelstr, color='black', fontsize=14, dpi=100) + xHover, depth = self.parser.to_rgba( + labelstr, color='white', fontsize=14, dpi=100) + + + self.labelwidth = x.shape[1] + self.labelheight = x.shape[0] + print 'h', self.labelheight + self.label = image.FigureImage(fig) + self.label.set_array(x.astype(float)/255.) + + self.labelHover = image.FigureImage(fig) + self.labelHover.set_array(xHover.astype(float)/255.) + + + + # we'll update these later + self.rect = patches.Rectangle((0,0), 1,1, facecolor='yellow', alpha=0.2) + self.rectHover = patches.Rectangle((0,0), 1,1, facecolor='blue', alpha=0.2) + + + + def set_extent(self, x, y, w, h): + print x, y, w, h + self.rect.set_x(x) + self.rect.set_y(y) + self.rect.set_width(w) + self.rect.set_height(h) + + self.rectHover.set_x(x) + self.rectHover.set_y(y) + self.rectHover.set_width(w) + self.rectHover.set_height(h) + + self.label.ox = x+self.padx + self.label.oy = y-self.depth+self.pady/2. + + self.rect._update_patch_transform() + self.rectHover._update_patch_transform() + self.labelHover.ox = x+self.padx + self.labelHover.oy = y-self.depth+self.pady/2. + self.hover = False + + self.activeRect = self.rect + self.activeLabel = self.label + + def draw(self, renderer): + self.activeRect.draw(renderer) + self.activeLabel.draw(renderer) + + def set_hover(self, event): + 'check the hover status of event and return true if status is changed' + b,junk = self.rect.contains(event) + if b: + self.activeRect = self.rectHover + self.activeLabel = self.labelHover + else: + self.activeRect = self.rect + self.activeLabel = self.label + + h = self.hover + self.hover = b + return b!=h + +class Menu: + + def __init__(self, fig, labels): + self.figure = fig + fig.suppressComposite = True + menuitems = [] + self.numitems = len(labels) + for label in labels: + menuitems.append(MenuItem(fig, label)) + + self.menuitems = menuitems + + + maxw = max([item.labelwidth for item in menuitems]) + maxh = max([item.labelheight for item in menuitems]) + + + totalh = self.numitems*maxh + (self.numitems+1)*2*MenuItem.pady + + x0 = 100 + y0 = 400 + + width = maxw + 2*MenuItem.padx + height = maxh+MenuItem.pady + for item in menuitems: + left = x0 + bottom = y0-maxh-MenuItem.pady + + + item.set_extent(left, bottom, width, height) + + fig.artists.append(item) + y0 -= maxh + MenuItem.pady + + + fig.canvas.mpl_connect('motion_notify_event', self.on_move) + + def on_move(self, event): + draw = False + for item in self.menuitems: + b = item.set_hover(event) + draw = b + + if draw: + print 'draw' + self.figure.canvas.draw() + + +fig = plt.figure() +menu = Menu(fig, ('open', 'close', 'save', 'save as', 'quit')) + +plt.show() + + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5624 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5624&view=rev Author: dsdale Date: 2008年06月21日 06:28:57 -0700 (2008年6月21日) Log Message: ----------- improve docstring for mlab.load to clarify for bugreport 1901536 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008年06月21日 13:09:07 UTC (rev 5623) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008年06月21日 13:28:57 UTC (rev 5624) @@ -1237,14 +1237,14 @@ skiprows is the number of rows from the top to skip usecols, if not None, is a sequence of integer column indexes to - extract where 0 is the first column, eg usecols=(1,4,5) to extract + extract where 0 is the first column, eg usecols=[1,4,5] to extract just the 2nd, 5th and 6th columns unpack, if True, will transpose the matrix allowing you to unpack into named arguments on the left hand side t,y = load('test.dat', unpack=True) # for two column data - x,y,z = load('somefile.dat', usecols=(3,5,7), unpack=True) + x,y,z = load('somefile.dat', usecols=[3,5,7], unpack=True) dtype, the array will have this dtype. default: numpy.float_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5628 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5628&view=rev Author: efiring Date: 2008年06月22日 01:19:56 -0700 (2008年6月22日) Log Message: ----------- Improve docstrings, inheritance of ListedColormap Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/colors.py Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2008年06月21日 21:07:54 UTC (rev 5627) +++ trunk/matplotlib/lib/matplotlib/colors.py 2008年06月22日 08:19:56 UTC (rev 5628) @@ -540,18 +540,19 @@ self._set_extremes() -class ListedColormap(LinearSegmentedColormap): +class ListedColormap(Colormap): """Colormap object generated from a list of colors. - Color boundaries are evenly spaced. This is intended for simulating - indexed color selection, but may be useful for generating - special colormaps also. + This may be most useful when indexing directly into a colormap, + but it can also be used to generate special colormaps for ordinary + mapping. """ def __init__(self, colors, name = 'from_list', N = None): """ Make a colormap from a list of colors. - colors is a list of matplotlib color specifications + colors is a list of matplotlib color specifications, + or an equivalent Nx3 floating point array (N rgb values) name is a string to identify the colormap N is the number of entries in the map. The default is None, in which case there is one colormap entry for each This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5627 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5627&view=rev Author: mdboom Date: 2008年06月21日 14:07:54 -0700 (2008年6月21日) Log Message: ----------- Fixing [ matplotlib-Bugs-1994535 ] still missing lines on graph with svn (r 5548) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/patches.py Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008年06月21日 17:07:25 UTC (rev 5626) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008年06月21日 21:07:54 UTC (rev 5627) @@ -596,6 +596,8 @@ return self._path.vertices def set_xy(self, vertices): self._path = Path(vertices) + _get_xy = get_xy + _set_xy = set_xy xy = property( get_xy, set_xy, None, """Set/get the vertices of the polygon. This property is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.