Revision: 3954
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3954&view=rev
Author: jdh2358
Date: 2007-10-16 06:45:59 -0700 (Tue, 16 Oct 2007)
Log Message:
-----------
restored unit support for ellipses -- and added
examples/units/ellipse_with_units.py
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/patches.py
Added Paths:
-----------
trunk/matplotlib/examples/units/ellipse_with_units.py
Added: trunk/matplotlib/examples/units/ellipse_with_units.py
===================================================================
--- trunk/matplotlib/examples/units/ellipse_with_units.py
(rev 0)
+++ trunk/matplotlib/examples/units/ellipse_with_units.py 2007-10-16
13:45:59 UTC (rev 3954)
@@ -0,0 +1,49 @@
+"""
+Compare the ellipse generated with arcs versus a polygonal approximation
+"""
+from basic_units import cm
+import numpy as npy
+from matplotlib import patches
+from pylab import figure, show
+
+xcenter, ycenter = 0.38*cm, 0.52*cm
+#xcenter, ycenter = 0., 0.
+width, height = 1e-1*cm, 3e-1*cm
+angle = -30
+
+theta = npy.arange(0.0, 360.0, 1.0)*npy.pi/180.0
+x = 0.5 * width * npy.cos(theta)
+y = 0.5 * height * 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', edgecolor='yellow', linewidth=1,
zorder=1)
+
+e1 = patches.Ellipse((xcenter, ycenter), width, height,
+ angle=angle, linewidth=2, fill=False, zorder=2)
+
+ax.add_patch(e1)
+
+ax = fig.add_subplot(212, aspect='equal')
+ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
+e2 = patches.Ellipse((xcenter, ycenter), width, height,
+ angle=angle, linewidth=2, fill=False, zorder=2)
+
+
+ax.add_patch(e2)
+
+#fig.savefig('ellipse_compare.png')
+fig.savefig('ellipse_compare')
+
+show()
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2007-10-16 12:28:49 UTC (rev
3953)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2007-10-16 13:45:59 UTC (rev
3954)
@@ -820,6 +820,8 @@
[npy.sin(rtheta), npy.cos(rtheta)],
])
+ x = self.convert_xunits(x)
+ y = self.convert_yunits(y)
x, y = npy.dot(R, npy.array([x, y]))
x += xcenter
@@ -845,10 +847,7 @@
if self._hatch:
gc.set_hatch(self._hatch )
- offset = self.offset
-
-
if not hasattr(renderer, 'draw_path'):
verbose.report('patches.Ellipse renderer does not support path
drawing; falling back on vertex approximation for nonlinear transformation')
renderer.draw_polygon(gc, rgbFace, self.get_verts())
@@ -856,15 +855,23 @@
x, y = self.center
+ x = self.convert_xunits(x)
+ y = self.convert_yunits(y)
+
theta = self.angle * npy.pi/180.
T = npy.array([
[1, 0, x],
[0, 1, y],
[0, 0, 1]])
+ w, h = self.width/2, self.height/2.
+ w = self.convert_xunits(w)
+ h = self.convert_yunits(h)
+
+
S = npy.array([
- [self.width/2., 0, 0],
- [0, self.height/2., 0],
+ [w, 0, 0],
+ [0, h, 0],
[0, 0, 1]])
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins