Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83da58e

Browse files
committed
Implement fill style for octagon marker.
1 parent 6fe5fa0 commit 83da58e

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

lib/matplotlib/markers.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,18 +465,29 @@ def _set_hexagon2(self):
465465
self._alt_transform = self._transform
466466

467467
def _set_octagon(self):
468-
self._transform = Affine2D().scale(0.5).rotate_deg(22.5)
468+
self._transform = Affine2D().scale(0.5)
469469
self._snap_threshold = 5.0
470470

471471
fs = self.get_fillstyle()
472472
polypath = Path.unit_regular_polygon(8)
473473

474474
if fs == 'full':
475+
self._transform.rotate_deg(22.5)
475476
self._path = polypath
476477
else:
477-
# TODO: Implement partially-filled octagons
478-
self._path = polypath
479-
478+
x = np.sqrt(2.)/4.
479+
half = Path([[0, -1], [0, 1], [-x, 1], [-1, x],
480+
[-1, -x], [-x, -1], [0, -1]])
481+
482+
if fs=='bottom': rotate = 90.
483+
elif fs=='top': rotate = 270.
484+
elif fs=='right': rotate = 180.
485+
else: rotate = 0.
486+
487+
self._transform.rotate_deg(rotate)
488+
self._path = self._alt_path = half
489+
self._alt_transform = self._transform.frozen().rotate_deg(180.0)
490+
480491
_line_marker_path = Path([[0.0, -1.0], [0.0, 1.0]])
481492
def _set_vline(self):
482493
self._transform = Affine2D().scale(0.5)

0 commit comments

Comments
 (0)