From: <jd...@us...> - 2007-10-14 19:00:52
|
Revision: 3941 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3941&view=rev Author: jdh2358 Date: 2007-10-14 12:00:50 -0700 (Sun, 14 Oct 2007) Log Message: ----------- added ellipse compare script Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Added Paths: ----------- trunk/matplotlib/unit/ellipse_compare.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-10-14 14:16:48 UTC (rev 3940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-10-14 19:00:50 UTC (rev 3941) @@ -143,7 +143,7 @@ """ if __debug__: verbose.report('RendererAgg.draw_arc', 'debug-annoying') self._renderer.draw_ellipse( - gcEdge, rgbFace, x, y, width/2, height/2, rotation) # ellipse takes radius + gcEdge, rgbFace, x, y, width/2., height/2., rotation) # ellipse takes radius def draw_line(self, gc, x1, y1, x2, y2): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-10-14 14:16:48 UTC (rev 3940) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-10-14 19:00:50 UTC (rev 3941) @@ -882,7 +882,7 @@ """ # local variable eliminates all repeated attribute lookups write = self._pswriter.write - + write('gsave\n') if debugPS and command: write("% "+command+"\n") @@ -915,7 +915,7 @@ write("stroke\n") if cliprect: write("grestore\n") - + write('grestore\n') def push_gc(self, gc, store=1): """ Push the current onto stack, with the exception of the clip box, which Added: trunk/matplotlib/unit/ellipse_compare.py =================================================================== --- trunk/matplotlib/unit/ellipse_compare.py (rev 0) +++ trunk/matplotlib/unit/ellipse_compare.py 2007-10-14 19:00:50 UTC (rev 3941) @@ -0,0 +1,53 @@ +""" +Compare the ellipse generated with arcs versus a polygonal approximation +""" +import numpy as npy +from matplotlib import patches +from pylab import figure, show + +xcenter, ycenter = 0.38, 0.52 +#xcenter, ycenter = 0., 0. +width, height = 1e-1, 3e-1 +angle = -30 + +theta = npy.arange(0.0, 360.0, 1.0)*npy.pi/180.0 +x = width/2. * npy.cos(theta) +y = height/2. * npy.sin(theta) + +rtheta = angle*npy.pi/180. +R = npy.array([ + [npy.cos(rtheta), -npy.sin(rtheta)], + [npy.sin(rtheta), npy.cos(rtheta)], + ]) + + +x, y = npy.dot(R, npy.array([x, y])) +x += xcenter +y += ycenter + +fig = figure() +ax = fig.add_subplot(211, aspect='auto') +ax.fill(x, y, alpha=0.2, facecolor='yellow') + +e1 = patches.Ellipse((xcenter, ycenter), width, height, + angle=angle, linewidth=2, fill=False) + +ax.add_artist(e1) + +ax = fig.add_subplot(212, aspect='equal') +ax.fill(x, y, alpha=0.2, facecolor='yellow') +e2 = patches.Ellipse((xcenter, ycenter), width, height, + angle=angle, linewidth=2, fill=False) + + +ax.add_artist(e2) +ax.autoscale_view() + + +ax.set_xlim(0.2, .5) +ax.set_ylim(0.3, 0.7) + +#fig.savefig('ellipse_compare.png') +#fig.savefig('ellipse_compare.ps') + +show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |