From 213459eabb44b4b84bfafc51a9c6964f1e0494cf Mon Sep 17 00:00:00 2001 From: Craig M Date: Wed, 31 Aug 2011 12:12:32 -0600 Subject: [PATCH 1/6] first commit to allow fillstyle none --- lib/matplotlib/lines.py | 13 +++++++------ lib/matplotlib/markers.py | 17 ++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index b57704024265..7e0ddf4a70c0 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -305,9 +305,9 @@ def get_fillstyle(self): def set_fillstyle(self, fs): """ Set the marker fill style; 'full' means fill the whole marker. - The other options are for half filled markers + 'none' means no filling; other options are for half-filled markers. - ACCEPTS: ['full' | 'left' | 'right' | 'bottom' | 'top'] + ACCEPTS: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none'] """ self._marker.set_fillstyle(fs) @@ -585,10 +585,11 @@ def _get_markerfacecolor(self, alt=False): else: fc = self._markerfacecolor - if (fc is None or (is_string_like(fc) and fc.lower()=='none') ): - return fc - elif (is_string_like(fc) and fc.lower() == 'auto'): - return self._color + if (is_string_like(fc) and fc.lower() == 'auto'): + if self.get_fillstyle() == 'none': + return 'none' + else: + return self._color else: return fc diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index cd0116031aa7..b0a4462ee587 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -101,13 +101,12 @@ class MarkerStyle: filled_markers = ( 'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd') - fillstyles = ('full', 'left' , 'right' , 'bottom' , 'top') + fillstyles = ('full', 'left' , 'right' , 'bottom' , 'top', 'none') # TODO: Is this ever used as a non-constant? _point_size_reduction = 0.5 def __init__(self, marker=None, fillstyle='full'): - self._fillstyle = fillstyle self.set_marker(marker) self.set_fillstyle(fillstyle) @@ -329,7 +328,7 @@ def _set_square(self): self._transform = Affine2D().translate(-0.5, -0.5) self._snap_threshold = 2.0 fs = self.get_fillstyle() - if fs=='full': + if fs == 'full' or fs == 'none': self._path = Path.unit_rectangle() else: # build a bottom filled square out of two rectangles, one @@ -349,7 +348,7 @@ def _set_diamond(self): self._transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45) self._snap_threshold = 5.0 fs = self.get_fillstyle() - if fs=='full': + if fs == 'full' or fs == 'none': self._path = Path.unit_rectangle() else: self._path = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 0.0]]) @@ -374,7 +373,7 @@ def _set_pentagon(self): polypath = Path.unit_regular_polygon(5) fs = self.get_fillstyle() - if fs == 'full': + if fs == 'full' or fs == 'none': self._path = polypath else: verts = polypath.vertices @@ -404,7 +403,7 @@ def _set_star(self): fs = self.get_fillstyle() polypath = Path.unit_regular_star(5, innerCircle=0.381966) - if fs == 'full': + if fs == 'full' or fs == 'none': self._path = polypath else: verts = polypath.vertices @@ -433,7 +432,7 @@ def _set_hexagon1(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(6) - if fs == 'full': + if fs == 'full' or fs == 'none': self._path = polypath else: verts = polypath.vertices @@ -465,7 +464,7 @@ def _set_hexagon2(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(6) - if fs == 'full': + if fs == 'full' or fs == 'none': self._path = polypath else: verts = polypath.vertices @@ -497,7 +496,7 @@ def _set_octagon(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(8) - if fs == 'full': + if fs == 'full' or fs == 'none': self._transform.rotate_deg(22.5) self._path = polypath else: From 785e66fb94a0a2dcb5c8c8577ed7f980d8cd4dd3 Mon Sep 17 00:00:00 2001 From: Craig M Date: Wed, 31 Aug 2011 12:38:31 -0600 Subject: [PATCH 2/6] auto markeredgecolor returns default color if fillstyle==none --- lib/matplotlib/lines.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 7e0ddf4a70c0..ebd4d295b1f7 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -566,17 +566,15 @@ def get_linewidth(self): return self._linewidth def get_marker(self): return self._marker def get_markeredgecolor(self): - if (is_string_like(self._markeredgecolor) and - self._markeredgecolor == 'auto'): - if self._marker.is_filled(): + mec = self._markeredgecolor + if (is_string_like(mec) and mec == 'auto'): + if self._marker.is_filled() and self.get_fillstyle() != 'none': return 'k' else: return self._color else: - return self._markeredgecolor + return mec - - return self._markeredgecolor def get_markeredgewidth(self): return self._markeredgewidth def _get_markerfacecolor(self, alt=False): From 5a2ced18187a9b3d220b21e1369d68cca0a2d0f3 Mon Sep 17 00:00:00 2001 From: Craig M Date: Thu, 8 Sep 2011 12:55:53 -0600 Subject: [PATCH 3/6] added missing fillstyle=='none' conditionals --- lib/matplotlib/markers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index b0a4462ee587..2a093b8397fa 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -247,7 +247,7 @@ def _set_circle(self, reduction = 1.0): self._transform = Affine2D().scale(0.5 * reduction) self._snap_threshold = 3.0 fs = self.get_fillstyle() - if fs=='full': + if fs == 'full' or fs == 'none': self._path = Path.unit_circle() else: # build a right-half circle @@ -289,7 +289,7 @@ def _set_triangle(self, rot, skip): self._snap_threshold = 5.0 fs = self.get_fillstyle() - if fs=='full': + if fs == 'full' or fs == 'none': self._path = self._triangle_path else: mpaths = [self._triangle_path_u, From 1982c51e74e52e27fcac116236a9d990ba4b7383 Mon Sep 17 00:00:00 2001 From: Craig M Date: Thu, 8 Sep 2011 13:05:35 -0600 Subject: [PATCH 4/6] trying to track down self._fillstyle error --- lib/matplotlib/markers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index 2a093b8397fa..5112278463ec 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -107,6 +107,7 @@ class MarkerStyle: _point_size_reduction = 0.5 def __init__(self, marker=None, fillstyle='full'): + self._fillstyle = fillstyle self.set_marker(marker) self.set_fillstyle(fillstyle) From 9ac0f3d7bffdb8a74de7ff0838b65454df8feee3 Mon Sep 17 00:00:00 2001 From: Craig M Date: Wed, 7 Dec 2011 16:52:55 -0700 Subject: [PATCH 5/6] Use local function to check for half-filled markers. --- lib/matplotlib/markers.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index 5112278463ec..72ae8196eddd 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -102,6 +102,7 @@ class MarkerStyle: 'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd') fillstyles = ('full', 'left' , 'right' , 'bottom' , 'top', 'none') + _half_fillstyles = ('left' , 'right' , 'bottom' , 'top') # TODO: Is this ever used as a non-constant? _point_size_reduction = 0.5 @@ -244,11 +245,16 @@ def _set_mathtext_path(self): self._path = text self._snap = False + def _half_fill(self): + fs = self.get_fillstyle() + result = fs in _half_fillstyles + return result + def _set_circle(self, reduction = 1.0): self._transform = Affine2D().scale(0.5 * reduction) self._snap_threshold = 3.0 fs = self.get_fillstyle() - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = Path.unit_circle() else: # build a right-half circle @@ -290,7 +296,7 @@ def _set_triangle(self, rot, skip): self._snap_threshold = 5.0 fs = self.get_fillstyle() - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = self._triangle_path else: mpaths = [self._triangle_path_u, @@ -329,7 +335,7 @@ def _set_square(self): self._transform = Affine2D().translate(-0.5, -0.5) self._snap_threshold = 2.0 fs = self.get_fillstyle() - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = Path.unit_rectangle() else: # build a bottom filled square out of two rectangles, one @@ -349,7 +355,7 @@ def _set_diamond(self): self._transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45) self._snap_threshold = 5.0 fs = self.get_fillstyle() - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = Path.unit_rectangle() else: self._path = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 0.0]]) @@ -374,7 +380,7 @@ def _set_pentagon(self): polypath = Path.unit_regular_polygon(5) fs = self.get_fillstyle() - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = polypath else: verts = polypath.vertices @@ -404,7 +410,7 @@ def _set_star(self): fs = self.get_fillstyle() polypath = Path.unit_regular_star(5, innerCircle=0.381966) - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = polypath else: verts = polypath.vertices @@ -433,7 +439,7 @@ def _set_hexagon1(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(6) - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = polypath else: verts = polypath.vertices @@ -465,7 +471,7 @@ def _set_hexagon2(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(6) - if fs == 'full' or fs == 'none': + if not _half_fill(): self._path = polypath else: verts = polypath.vertices @@ -497,7 +503,7 @@ def _set_octagon(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(8) - if fs == 'full' or fs == 'none': + if not _half_fill(): self._transform.rotate_deg(22.5) self._path = polypath else: From c6e93d3ed5f35a97a94ca3c522173290bdbfbc30 Mon Sep 17 00:00:00 2001 From: Craig M Date: Fri, 9 Dec 2011 20:44:02 -0700 Subject: [PATCH 6/6] Fix missing 'self.'s in call of _half_fill method. --- lib/matplotlib/markers.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index fa2142c9ead7..66c54eca7230 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -247,14 +247,14 @@ def _set_mathtext_path(self): def _half_fill(self): fs = self.get_fillstyle() - result = fs in _half_fillstyles + result = fs in self._half_fillstyles return result def _set_circle(self, reduction = 1.0): self._transform = Affine2D().scale(0.5 * reduction) self._snap_threshold = 3.0 fs = self.get_fillstyle() - if not _half_fill(): + if not self._half_fill(): self._path = Path.unit_circle() else: # build a right-half circle @@ -296,7 +296,7 @@ def _set_triangle(self, rot, skip): self._snap_threshold = 5.0 fs = self.get_fillstyle() - if not _half_fill(): + if not self._half_fill(): self._path = self._triangle_path else: mpaths = [self._triangle_path_u, @@ -335,7 +335,7 @@ def _set_square(self): self._transform = Affine2D().translate(-0.5, -0.5) self._snap_threshold = 2.0 fs = self.get_fillstyle() - if not _half_fill(): + if not self._half_fill(): self._path = Path.unit_rectangle() else: # build a bottom filled square out of two rectangles, one @@ -355,7 +355,7 @@ def _set_diamond(self): self._transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45) self._snap_threshold = 5.0 fs = self.get_fillstyle() - if not _half_fill(): + if not self._half_fill(): self._path = Path.unit_rectangle() else: self._path = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 0.0]]) @@ -380,7 +380,7 @@ def _set_pentagon(self): polypath = Path.unit_regular_polygon(5) fs = self.get_fillstyle() - if not _half_fill(): + if not self._half_fill(): self._path = polypath else: verts = polypath.vertices @@ -410,7 +410,7 @@ def _set_star(self): fs = self.get_fillstyle() polypath = Path.unit_regular_star(5, innerCircle=0.381966) - if not _half_fill(): + if not self._half_fill(): self._path = polypath else: verts = polypath.vertices @@ -439,7 +439,7 @@ def _set_hexagon1(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(6) - if not _half_fill(): + if not self._half_fill(): self._path = polypath else: verts = polypath.vertices @@ -471,7 +471,7 @@ def _set_hexagon2(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(6) - if not _half_fill(): + if not self._half_fill(): self._path = polypath else: verts = polypath.vertices @@ -503,7 +503,7 @@ def _set_octagon(self): fs = self.get_fillstyle() polypath = Path.unit_regular_polygon(8) - if not _half_fill(): + if not self._half_fill(): self._transform.rotate_deg(22.5) self._path = polypath else: