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

Skip to content

Commit b05aa16

Browse files
committed
Comment why the offset of the pixel rectangle is surprising.
1 parent 92e3b63 commit b05aa16

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/matplotlib/markers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,15 @@ def _set_circle(self, reduction = 1.0):
274274

275275
def _set_pixel(self):
276276
self._path = Path.unit_rectangle()
277+
# Ideally, you'd want -0.5, -0.5 here, but then the snapping
278+
# algorithm in the Agg backend will round this to a 2x2
279+
# rectangle from (-1, -1) to (1, 1). By offsetting it
280+
# slightly, we can force it to be (0, -1) to (1, 0), which
281+
# both makes it only be a single pixel and places it correctly
282+
# with 1-width stroking (i.e. the ticks). This hack is the
283+
# best of a number of bad alternatives, mainly because the
284+
# backends are not aware of what marker is actually being used
285+
# beyond just its path data.
277286
self._transform = Affine2D().translate(-0.49999, -0.50001)
278287
self._snap_threshold = None
279288

0 commit comments

Comments
 (0)