Skip to content

Fix half-filled markers protrusion #19354

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,13 @@ def _set_square(self):
if not self._half_fill():
self._path = Path.unit_rectangle()
else:
# Build a bottom filled square out of two rectangles, one filled.
self._path = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 0.5],
[0.0, 0.5], [0.0, 0.0]])
self._alt_path = Path([[0.0, 0.5], [1.0, 0.5], [1.0, 1.0],
[0.0, 1.0], [0.0, 0.5]])
self._path = self._alt_path = Path( # Half-square.
[[0.0, 0.0], [1.0, 0.0], [1.0, 0.5], [0.0, 0.5], [0.0, 0.0]],
closed=True)
fs = self.get_fillstyle()
rotate = {'bottom': 0, 'right': 90, 'top': 180, 'left': 270}[fs]
self._transform.rotate_deg(rotate)
self._alt_transform = self._transform
self._alt_transform = self._transform.frozen().rotate_deg(180)

self._joinstyle = JoinStyle.miter

Expand All @@ -537,17 +535,21 @@ def _set_diamond(self):
if not self._half_fill():
self._path = Path.unit_rectangle()
else:
self._path = Path([[0, 0], [1, 0], [1, 1], [0, 0]])
self._alt_path = Path([[0, 0], [0, 1], [1, 1], [0, 0]])
eps = 1e-3 # Don't let the miter joins protrude.
self._path = self._alt_path = Path(
[[eps, eps], [eps, 0], [1, 0], [1, 1-eps], [1-eps, 1-eps],
[eps, eps]], closed=True)
fs = self.get_fillstyle()
rotate = {'right': 0, 'top': 90, 'left': 180, 'bottom': 270}[fs]
rotate = {'bottom': 0, 'right': 90, 'top': 180, 'left': 270}[fs]
self._transform.rotate_deg(rotate)
self._alt_transform = self._transform
self._joinstyle = JoinStyle.miter
self._alt_transform = self._transform.frozen().rotate_deg(180)
self._joinstyle = 'miter'

def _set_thin_diamond(self):
self._set_diamond()
self._transform.scale(0.6, 1.0)
if self._alt_transform:
self._alt_transform.scale(0.6, 1.0)

def _set_pentagon(self):
self._transform = Affine2D().scale(0.5)
Expand Down