Revision: 7255
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7255&view=rev
Author: jdh2358
Date: 2009-07-11 16:52:44 +0000 (Sat, 11 Jul 2009)
Log Message:
-----------
added fillstyle property to Line2D
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/lines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-07-11 12:42:46 UTC (rev 7254)
+++ trunk/matplotlib/CHANGELOG 2009-07-11 16:52:44 UTC (rev 7255)
@@ -1,3 +1,6 @@
+2009-07-11 Added a fillstyle Line2D property for half filled markers
+ -- see examples/pylab_examples/fillstyle_demo.py JDH
+
2009-07-08 Attempt to improve performance of qt4 backend, do not call
qApp.processEvents while processing an event. Thanks Ole
Streicher for tracking this down - DSD
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2009-07-11 12:42:46 UTC (rev
7254)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2009-07-11 16:52:44 UTC (rev
7255)
@@ -172,6 +172,7 @@
markeredgewidth = None,
markeredgecolor = None,
markerfacecolor = None,
+ fillstyle = 'full',
antialiased = None,
dash_capstyle = None,
solid_capstyle = None,
@@ -238,6 +239,8 @@
self.set_markerfacecolor(markerfacecolor)
self.set_markeredgecolor(markeredgecolor)
self.set_markeredgewidth(markeredgewidth)
+ self.set_fillstyle(fillstyle)
+
self._point_size_reduction = 0.5
self.verticalOffset = None
@@ -324,7 +327,22 @@
"""
self.pickradius = d
+ def get_fillstyle(self):
+ """
+ return the marker fillstyle
+ """
+ return self._fillstyle
+ def set_fillstyle(self, fs):
+ """
+ Set the marker fill style; full means fill the whole marker.
+ The other options are for half fills
+
+ ACCEPTS: string ['full' | 'left' | 'right' | 'bottom' | 'top']
+ """
+ assert fs in ['full', 'left' , 'right' , 'bottom' , 'top']
+ self._fillstyle = fs
+
def set_markevery(self, every):
"""
Set the markevery property to subsample the plot when using
@@ -918,6 +936,10 @@
def _draw_point(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
w = renderer.points_to_pixels(self._markersize) * \
self._point_size_reduction * 0.5
gc.set_snap(renderer.points_to_pixels(self._markersize) > 3.0)
@@ -929,6 +951,10 @@
_draw_pixel_transform = Affine2D().translate(-0.5, -0.5)
def _draw_pixel(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
rgbFace = self._get_rgb_face()
gc.set_snap(False)
renderer.draw_markers(gc, Path.unit_rectangle(),
@@ -937,6 +963,10 @@
def _draw_circle(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
w = renderer.points_to_pixels(self._markersize) * 0.5
gc.set_snap(renderer.points_to_pixels(self._markersize) > 3.0)
rgbFace = self._get_rgb_face()
@@ -948,6 +978,11 @@
_triangle_path = Path([[0.0, 1.0], [-1.0, -1.0], [1.0, -1.0], [0.0, 1.0]])
def _draw_triangle_up(self, renderer, gc, path, path_trans):
+
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, offset)
@@ -957,6 +992,10 @@
def _draw_triangle_down(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, -offset)
@@ -966,6 +1005,10 @@
def _draw_triangle_left(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, offset).rotate_deg(90)
@@ -975,6 +1018,10 @@
def _draw_triangle_right(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
+
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5*renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset, offset).rotate_deg(-90)
@@ -988,11 +1035,31 @@
side = renderer.points_to_pixels(self._markersize)
transform = Affine2D().translate(-0.5, -0.5).scale(side)
rgbFace = self._get_rgb_face()
- renderer.draw_markers(gc, Path.unit_rectangle(), transform,
- path, path_trans, rgbFace)
+ fs = self.get_fillstyle()
+ if fs=='full':
+ renderer.draw_markers(gc, Path.unit_rectangle(), transform,
+ path, path_trans, rgbFace)
+ else:
+ # build a bottom filled square out of two rectangles, one
+ # filled. Use the rotation to support left, right, bottom
+ # or top
+ if fs=='bottom': rotate = 0.
+ elif fs=='top': rotate = 180.
+ elif fs=='left': rotate = 270.
+ else: rotate = 90.
+ bottom = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 0.5], [0.0, 0.5],
[0.0, 0.0]])
+ top = Path([[0.0, 0.5], [1.0, 0.5], [1.0, 1.0], [0.0, 1.0], [0.0,
0.05]])
+ transform = transform.rotate_deg(rotate)
+ renderer.draw_markers(gc, bottom, transform,
+ path, path_trans, rgbFace)
+ renderer.draw_markers(gc, top, transform,
+ path, path_trans, None)
def _draw_diamond(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
side = renderer.points_to_pixels(self._markersize)
transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45).scale(side)
@@ -1002,6 +1069,9 @@
def _draw_thin_diamond(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 3.0)
offset = renderer.points_to_pixels(self._markersize)
transform = Affine2D().translate(-0.5, -0.5) \
@@ -1012,6 +1082,9 @@
def _draw_pentagon(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset)
@@ -1020,6 +1093,9 @@
path, path_trans, rgbFace)
def _draw_star(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset)
@@ -1030,6 +1106,9 @@
def _draw_hexagon1(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset)
@@ -1039,6 +1118,9 @@
def _draw_hexagon2(self, renderer, gc, path, path_trans):
+ fs = self.get_fillstyle()
+ if fs!='full':
+ raise NotImplementedError('non-full markers have not been
implemented for this marker style yet; please contribute')
gc.set_snap(renderer.points_to_pixels(self._markersize) >= 5.0)
offset = 0.5 * renderer.points_to_pixels(self._markersize)
transform = Affine2D().scale(offset).rotate_deg(30)
@@ -1203,6 +1285,7 @@
self._markerfacecolor = other._markerfacecolor
self._markeredgecolor = other._markeredgecolor
self._markeredgewidth = other._markeredgewidth
+ self._fillstyle = other._fillstyle
self._dashSeq = other._dashSeq
self._dashcapstyle = other._dashcapstyle
self._dashjoinstyle = other._dashjoinstyle
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins