Revision: 4708
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4708&view=rev
Author: mdboom
Date: 2007-12-12 07:01:20 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
Merged revisions 4689-4706 via svnmerge from
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib
........
r4697 | pkienzle | 2007-12-11 12:14:44 -0500 (Tue, 11 Dec 2007) | 1 line
remove wx specific gui_repaint comment
........
r4698 | jdh2358 | 2007-12-11 16:17:59 -0500 (Tue, 11 Dec 2007) | 2 lines
fixed text with dash bug
........
r4706 | mdboom | 2007-12-12 09:08:15 -0500 (Wed, 12 Dec 2007) | 2 lines
Support alpha-blended text in the Agg and Svg backends.
........
Modified Paths:
--------------
branches/transforms/examples/dashpointlabel.py
branches/transforms/examples/lasso_demo.py
branches/transforms/lib/matplotlib/backend_bases.py
branches/transforms/lib/matplotlib/backends/backend_svg.py
branches/transforms/lib/matplotlib/cbook.py
branches/transforms/lib/matplotlib/patches.py
branches/transforms/lib/matplotlib/text.py
branches/transforms/src/_backend_agg.cpp
Property Changed:
----------------
branches/transforms/
Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/matplotlib:1-4688
+ /trunk/matplotlib:1-4706
Modified: branches/transforms/examples/dashpointlabel.py
===================================================================
--- branches/transforms/examples/dashpointlabel.py 2007-12-12 14:52:01 UTC
(rev 4707)
+++ branches/transforms/examples/dashpointlabel.py 2007-12-12 15:01:20 UTC
(rev 4708)
@@ -1,4 +1,4 @@
-from matplotlib import pylab
+import pylab
DATA = ((1, 3),
(2, 4),
@@ -15,26 +15,27 @@
(1, 20, 30, 60, 10),
)
-def test_dashpointlabel(save=False):
- pylab.clf()
- (x,y) = zip(*DATA)
- pylab.plot(x, y, marker='o')
- for i in xrange(len(DATA)):
- (x,y) = DATA[i]
- (dd, dl, r, dr, dp) = dash_style[i]
- pylab.text(x, y, str((x,y)), withdash=True,
- dashdirection=dd,
- dashlength=dl,
- rotation=r,
- dashrotation=dr,
- dashpush=dp,
- )
- axis = pylab.gca()
- axis.set_xlim((0.0, 5.0))
- axis.set_ylim((0.0, 5.0))
- if save:
- pylab.savefig('dashpointlabel')
- pylab.show()
+fig = pylab.figure()
+ax = fig.add_subplot(111)
-if __name__ == '__main__':
- test_dashpointlabel()
+
+(x,y) = zip(*DATA)
+ax.plot(x, y, marker='o')
+for i in xrange(len(DATA)):
+ (x,y) = DATA[i]
+ (dd, dl, r, dr, dp) = dash_style[i]
+ #print 'dashlen call', dl
+ t = ax.text(x, y, str((x,y)), withdash=True,
+ dashdirection=dd,
+ dashlength=dl,
+ rotation=r,
+ dashrotation=dr,
+ dashpush=dp,
+ )
+
+ax.set_xlim((0.0, 5.0))
+ax.set_ylim((0.0, 5.0))
+#if save:
+# pylab.savefig('dashpointlabel')
+pylab.show()
+
Modified: branches/transforms/examples/lasso_demo.py
===================================================================
--- branches/transforms/examples/lasso_demo.py 2007-12-12 14:52:01 UTC (rev
4707)
+++ branches/transforms/examples/lasso_demo.py 2007-12-12 15:01:20 UTC (rev
4708)
@@ -59,6 +59,7 @@
self.canvas.draw_idle()
self.canvas.widgetlock.release(self.lasso)
del self.lasso
+
def onpress(self, event):
if self.canvas.widgetlock.locked(): return
if event.inaxes is None: return
Modified: branches/transforms/lib/matplotlib/backend_bases.py
===================================================================
--- branches/transforms/lib/matplotlib/backend_bases.py 2007-12-12 14:52:01 UTC
(rev 4707)
+++ branches/transforms/lib/matplotlib/backend_bases.py 2007-12-12 15:01:20 UTC
(rev 4708)
@@ -843,7 +843,6 @@
a.set_facecolor('lightblue')
else: self._active[a] = None
self.draw_idle()
- #self.gui_repaint()
def pick(self, mouseevent):
if not self.widgetlock.locked():
Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12
14:52:01 UTC (rev 4707)
+++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-12
15:01:20 UTC (rev 4708)
@@ -296,7 +296,7 @@
color = rgb2hex(gc.get_rgb()[:3])
if rcParams['svg.embed_char_paths']:
- svg = ['<g style="fill: %s" transform="' % color]
+ svg = ['<g style="fill: %s; opacity: %s" transform="' % (color,
gc.get_alpha())]
if angle != 0:
svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle))
elif x != 0 or y != 0:
@@ -335,7 +335,8 @@
fontfamily = font.family_name
fontstyle = prop.get_style()
- style = 'font-size: %f; font-family: %s; font-style: %s; fill:
%s;'%(fontsize, fontfamily,fontstyle, color)
+ style = ('font-size: %f; font-family: %s; font-style: %s; fill:
%s; opacity: %s' %
+ (fontsize, fontfamily,fontstyle, color, gc.get_alpha()))
if angle!=0:
transform = 'transform="translate(%s,%s) rotate(%1.1f)
translate(%s,%s)"' % (x,y,-angle,-x,-y)
# Inkscape doesn't support rotate(angle x y)
Modified: branches/transforms/lib/matplotlib/cbook.py
===================================================================
--- branches/transforms/lib/matplotlib/cbook.py 2007-12-12 14:52:01 UTC (rev
4707)
+++ branches/transforms/lib/matplotlib/cbook.py 2007-12-12 15:01:20 UTC (rev
4708)
@@ -11,7 +11,7 @@
set = set
except NameError:
from sets import Set as set
-
+
major, minor1, minor2, s, tmp = sys.version_info
@@ -974,9 +974,9 @@
.get().
The objects being joined must be hashable.
-
+
For example:
-
+
>>> g = grouper.Grouper()
>>> g.join('a', 'b')
>>> g.join('b', 'c')
@@ -989,7 +989,7 @@
True
>>> g.joined('a', 'd')
False
- """
+ """
def __init__(self, init=[]):
mapping = self._mapping = {}
for x in init:
@@ -997,7 +997,7 @@
def __contains__(self, item):
return item in self._mapping
-
+
def join(self, a, *args):
"""
Join given arguments into the same set.
@@ -1045,7 +1045,7 @@
"""
return self._mapping.get(a, [a])
-
+
def simple_linear_interpolation(a, steps):
steps = npy.floor(steps)
new_length = ((len(a) - 1) * steps) + 1
@@ -1061,7 +1061,7 @@
for i in range(1, int(steps)):
result[i::steps] = delta * i + a0
result[steps::steps] = a1
-
+
return result
if __name__=='__main__':
Modified: branches/transforms/lib/matplotlib/patches.py
===================================================================
--- branches/transforms/lib/matplotlib/patches.py 2007-12-12 14:52:01 UTC
(rev 4707)
+++ branches/transforms/lib/matplotlib/patches.py 2007-12-12 15:01:20 UTC
(rev 4708)
@@ -1006,7 +1006,6 @@
dx = x1 - x0
dy = y1 - y0
dr2 = dx*dx + dy*dy
- dr = npy.sqrt(dr2)
D = x0*y1 - x1*y0
D2 = D*D
discrim = dr2 - D2
@@ -1017,7 +1016,9 @@
y = (-D*dx) / dr2
yield x, y
elif discrim > 0.0:
- if dy < 0:
+ # The definition of "sign" here is different from
+ # npy.sign: we never want to get 0.0
+ if dy < 0.0:
sign_dy = -1.0
else:
sign_dy = 1.0
@@ -1057,10 +1058,10 @@
x0, y0 = p0
x1, y1 = p1
for x, y in iter_circle_intersect_on_line_seg(x0, y0, x1, y1):
- # Convert radians to angles
theta = npy.arccos(x)
if y < 0:
theta = TWOPI - theta
+ # Convert radians to angles
theta *= RAD2DEG
if theta > theta1 and theta < theta2:
thetas[theta] = None
@@ -1072,7 +1073,6 @@
last_theta = theta1
theta1_rad = theta1 * DEG2RAD
inside = box_path.contains_point((npy.cos(theta1_rad),
npy.sin(theta1_rad)))
-
for theta in thetas:
if inside:
self._path = Path.arc(last_theta, theta, 8)
Modified: branches/transforms/lib/matplotlib/text.py
===================================================================
--- branches/transforms/lib/matplotlib/text.py 2007-12-12 14:52:01 UTC (rev
4707)
+++ branches/transforms/lib/matplotlib/text.py 2007-12-12 15:01:20 UTC (rev
4708)
@@ -368,6 +368,11 @@
"Return the horizontal alignment as string"
return self._horizontalalignment
+
+ def _get_xy_display(self):
+ 'get the (possibly unit converted) transformed x,y in display coords'
+ return self.get_transform().transform_point((self._x, self._y))
+
def get_position(self):
"Return x, y as tuple"
x = float(self.convert_xunits(self._x))
@@ -631,6 +636,8 @@
ACCEPTS: a matplotlib.font_manager.FontProperties instance
"""
+ if is_string_like(fp):
+ fp = FontProperties(fp)
self._fontproperties = fp
artist.kwdocd['Text'] = artist.kwdoc(Text)
@@ -731,6 +738,24 @@
#self.set_bbox(dict(pad=0))
+ def get_position(self):
+ "Return x, y as tuple"
+ x = float(self.convert_xunits(self._dashx))
+ y = float(self.convert_yunits(self._dashy))
+ return x, y
+
+ def get_prop_tup(self):
+ """
+ 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
+ """
+ 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])
+ return tuple(props)
+
def draw(self, renderer):
self.update_coords(renderer)
Text.draw(self, renderer)
@@ -808,7 +833,8 @@
cwd *= 1+dashpad/npy.sqrt(npy.dot(cwd,cwd))
cw = c2+(dashdirection*2-1)*cwd
- self._x, self._y = inverse.transform_point(tuple(cw))
+ newx, newy = inverse.transform_point(tuple(cw))
+ self._x, self._y = newx, newy
# Now set the window extent
# I'm not at all sure this is the right way to do this.
@@ -892,9 +918,6 @@
"""
self._dashpush = dp
- def get_position(self):
- "Return x, y as tuple"
- return self._dashx, self._dashy
def set_position(self, xy):
"""
Modified: branches/transforms/src/_backend_agg.cpp
===================================================================
--- branches/transforms/src/_backend_agg.cpp 2007-12-12 14:52:01 UTC (rev
4707)
+++ branches/transforms/src/_backend_agg.cpp 2007-12-12 15:01:20 UTC (rev
4708)
@@ -625,7 +625,7 @@
do {
*output_span = _color;
- output_span->a = input_span->v;
+ output_span->a = ((unsigned int)_color.a * (unsigned int)input_span->v)
>> 8;
++output_span;
++input_span;
} while (--len);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins