Skip to content

Commit d661a48

Browse files
committed
Comment why the offset of the pixel rectangle is surprising.
1 parent 9495a50 commit d661a48

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/matplotlib/markers.py

+9
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ def _set_circle(self, reduction = 1.0):
280280

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

0 commit comments

Comments
 (0)