Skip to content

Commit 9ac0f3d

Browse files
committed
Use local function to check for half-filled markers.
1 parent 392fe5d commit 9ac0f3d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

lib/matplotlib/markers.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class MarkerStyle:
102102
'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd')
103103

104104
fillstyles = ('full', 'left' , 'right' , 'bottom' , 'top', 'none')
105+
_half_fillstyles = ('left' , 'right' , 'bottom' , 'top')
105106

106107
# TODO: Is this ever used as a non-constant?
107108
_point_size_reduction = 0.5
@@ -244,11 +245,16 @@ def _set_mathtext_path(self):
244245
self._path = text
245246
self._snap = False
246247

248+
def _half_fill(self):
249+
fs = self.get_fillstyle()
250+
result = fs in _half_fillstyles
251+
return result
252+
247253
def _set_circle(self, reduction = 1.0):
248254
self._transform = Affine2D().scale(0.5 * reduction)
249255
self._snap_threshold = 3.0
250256
fs = self.get_fillstyle()
251-
if fs == 'full' or fs == 'none':
257+
if not _half_fill():
252258
self._path = Path.unit_circle()
253259
else:
254260
# build a right-half circle
@@ -290,7 +296,7 @@ def _set_triangle(self, rot, skip):
290296
self._snap_threshold = 5.0
291297
fs = self.get_fillstyle()
292298

293-
if fs == 'full' or fs == 'none':
299+
if not _half_fill():
294300
self._path = self._triangle_path
295301
else:
296302
mpaths = [self._triangle_path_u,
@@ -329,7 +335,7 @@ def _set_square(self):
329335
self._transform = Affine2D().translate(-0.5, -0.5)
330336
self._snap_threshold = 2.0
331337
fs = self.get_fillstyle()
332-
if fs == 'full' or fs == 'none':
338+
if not _half_fill():
333339
self._path = Path.unit_rectangle()
334340
else:
335341
# build a bottom filled square out of two rectangles, one
@@ -349,7 +355,7 @@ def _set_diamond(self):
349355
self._transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45)
350356
self._snap_threshold = 5.0
351357
fs = self.get_fillstyle()
352-
if fs == 'full' or fs == 'none':
358+
if not _half_fill():
353359
self._path = Path.unit_rectangle()
354360
else:
355361
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):
374380
polypath = Path.unit_regular_polygon(5)
375381
fs = self.get_fillstyle()
376382

377-
if fs == 'full' or fs == 'none':
383+
if not _half_fill():
378384
self._path = polypath
379385
else:
380386
verts = polypath.vertices
@@ -404,7 +410,7 @@ def _set_star(self):
404410
fs = self.get_fillstyle()
405411
polypath = Path.unit_regular_star(5, innerCircle=0.381966)
406412

407-
if fs == 'full' or fs == 'none':
413+
if not _half_fill():
408414
self._path = polypath
409415
else:
410416
verts = polypath.vertices
@@ -433,7 +439,7 @@ def _set_hexagon1(self):
433439
fs = self.get_fillstyle()
434440
polypath = Path.unit_regular_polygon(6)
435441

436-
if fs == 'full' or fs == 'none':
442+
if not _half_fill():
437443
self._path = polypath
438444
else:
439445
verts = polypath.vertices
@@ -465,7 +471,7 @@ def _set_hexagon2(self):
465471
fs = self.get_fillstyle()
466472
polypath = Path.unit_regular_polygon(6)
467473

468-
if fs == 'full' or fs == 'none':
474+
if not _half_fill():
469475
self._path = polypath
470476
else:
471477
verts = polypath.vertices
@@ -497,7 +503,7 @@ def _set_octagon(self):
497503
fs = self.get_fillstyle()
498504
polypath = Path.unit_regular_polygon(8)
499505

500-
if fs == 'full' or fs == 'none':
506+
if not _half_fill():
501507
self._transform.rotate_deg(22.5)
502508
self._path = polypath
503509
else:

0 commit comments

Comments
 (0)