Skip to content

allow fillstyle 'none' option #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 31, 2011
22 changes: 12 additions & 10 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,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)

Expand Down Expand Up @@ -572,15 +572,16 @@ def get_linewidth(self): return self._linewidth
def get_marker(self): return self._marker.get_marker()

def get_markeredgecolor(self):
if (is_string_like(self._markeredgecolor) and
self._markeredgecolor == 'auto'):
mec = self._markeredgecolor
if (is_string_like(mec) and mec == 'auto'):
if self._marker.get_marker() in ('.', ','):
return self._color
if self._marker.is_filled():
if self._marker.is_filled() and self.get_fillstyle() != 'none':
return 'k' # Bad hard-wired default...
else:
return self._color
return self._markeredgecolor
else:
return mec

def get_markeredgewidth(self): return self._markeredgewidth

Expand All @@ -590,10 +591,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

Expand Down
26 changes: 16 additions & 10 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ 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')
_half_fillstyles = ('left' , 'right' , 'bottom' , 'top')

# TODO: Is this ever used as a non-constant?
_point_size_reduction = 0.5
Expand Down Expand Up @@ -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 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 fs=='full':
if not self._half_fill():
self._path = Path.unit_circle()
else:
# build a right-half circle
Expand Down Expand Up @@ -290,7 +296,7 @@ def _set_triangle(self, rot, skip):
self._snap_threshold = 5.0
fs = self.get_fillstyle()

if fs=='full':
if not self._half_fill():
self._path = self._triangle_path
else:
mpaths = [self._triangle_path_u,
Expand Down Expand Up @@ -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':
if not self._half_fill():
self._path = Path.unit_rectangle()
else:
# build a bottom filled square out of two rectangles, one
Expand All @@ -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':
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]])
Expand All @@ -374,7 +380,7 @@ def _set_pentagon(self):
polypath = Path.unit_regular_polygon(5)
fs = self.get_fillstyle()

if fs == 'full':
if not self._half_fill():
self._path = polypath
else:
verts = polypath.vertices
Expand Down Expand Up @@ -404,7 +410,7 @@ def _set_star(self):
fs = self.get_fillstyle()
polypath = Path.unit_regular_star(5, innerCircle=0.381966)

if fs == 'full':
if not self._half_fill():
self._path = polypath
else:
verts = polypath.vertices
Expand Down Expand Up @@ -433,7 +439,7 @@ def _set_hexagon1(self):
fs = self.get_fillstyle()
polypath = Path.unit_regular_polygon(6)

if fs == 'full':
if not self._half_fill():
self._path = polypath
else:
verts = polypath.vertices
Expand Down Expand Up @@ -465,7 +471,7 @@ def _set_hexagon2(self):
fs = self.get_fillstyle()
polypath = Path.unit_regular_polygon(6)

if fs == 'full':
if not self._half_fill():
self._path = polypath
else:
verts = polypath.vertices
Expand Down Expand Up @@ -497,7 +503,7 @@ def _set_octagon(self):
fs = self.get_fillstyle()
polypath = Path.unit_regular_polygon(8)

if fs == 'full':
if not self._half_fill():
self._transform.rotate_deg(22.5)
self._path = polypath
else:
Expand Down