From: <md...@us...> - 2008-06-23 12:35:16
|
Revision: 5641 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5641&view=rev Author: mdboom Date: 2008-06-23 05:34:45 -0700 (Mon, 23 Jun 2008) Log Message: ----------- Use splines to render circles in scatter plots. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/collections.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-06-23 12:10:31 UTC (rev 5640) +++ trunk/matplotlib/CHANGELOG 2008-06-23 12:34:45 UTC (rev 5641) @@ -1,3 +1,5 @@ +2008-06-23 Use splines to render circles in scatter plots - MGD + =============================================================== 2008-06-22 Released 0.98.1 at revision 5637 Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-23 12:10:31 UTC (rev 5640) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-23 12:34:45 UTC (rev 5641) @@ -4561,22 +4561,23 @@ The marker can also be a tuple (*numsides*, *style*, *angle*), which will create a custom, regular symbol. - *numsides*: - the number of sides + *numsides*: + the number of sides - *style*: - the style of the regular symbol: + *style*: + the style of the regular symbol: - ===== ================== - Value Description - ===== ================== - 0 a regular polygon - 1 a star-like symbol - 2 an asterisk - ===== ================== + ===== ================== + Value Description + ===== ========================================= + 0 a regular polygon + 1 a star-like symbol + 2 an asterisk + 3 a circle (numsides and angle is ignored) + ===== ========================================= - *angle*: - the angle of rotation of the symbol + *angle*: + the angle of rotation of the symbol Finally, *marker* can be (*verts*, 0): *verts* is a sequence of (*x*, *y*) vertices for a custom scatter @@ -4640,7 +4641,7 @@ syms = { # a dict from symbol to (numsides, angle) 's' : (4,math.pi/4.0,0), # square - 'o' : (20,0,0), # circle + 'o' : (20,3,0), # circle '^' : (3,0,0), # triangle up '>' : (3,math.pi/2.0,0), # triangle right 'v' : (3,math.pi,0), # triangle down @@ -4748,9 +4749,16 @@ offsets = zip(x,y), transOffset = self.transData, ) + elif symstyle==3: + collection = mcoll.CircleCollection( + scales, + facecolors = colors, + edgecolors = edgecolors, + linewidths = linewidths, + offsets = zip(x,y), + transOffset = self.transData, + ) else: - # MGDTODO: This has dpi problems - # rescale verts rescale = np.sqrt(max(verts[:,0]**2+verts[:,1]**2)) verts /= rescale Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008-06-23 12:10:31 UTC (rev 5640) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008-06-23 12:34:45 UTC (rev 5641) @@ -805,6 +805,32 @@ return self._edgecolors get_colors = get_color # for compatibility with old versions +class CircleCollection(Collection): + """ + A collection of circles, drawn using splines. + """ + def __init__(self, sizes): + """ + *sizes* + Gives the area of the circle in points^2 + + %(Collection)s + """ + Collection.__init__(self,**kwargs) + self._sizes = sizes + self.set_transform(transforms.IdentityTransform()) + self._paths = [mpath.Path.unit_circle()] + + def draw(self, renderer): + # sizes is the area of the circle circumscribing the polygon + # in points^2 + self._transforms = [ + transforms.Affine2D().scale( + (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi)) + for x in self._sizes] + return Collection.draw(self, renderer) + + class PatchCollection(Collection): """ A generic collection of patches. @@ -870,6 +896,6 @@ artist.kwdocd['Collection'] = patchstr = artist.kwdoc(Collection) for k in ('QuadMesh', 'PolyCollection', 'BrokenBarHCollection', 'RegularPolyCollection', - 'StarPolygonCollection'): + 'StarPolygonCollection', 'PatchCollection', 'CircleCollection'): artist.kwdocd[k] = patchstr artist.kwdocd['LineCollection'] = artist.kwdoc(LineCollection) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |