matplotlib.artist.Artist.set_snap

Artist.set_snap(self, snap)[source]

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results in clearer images. For example, if a black line of 1px width was defined at a position in between two pixels, the resulting image would contain the interpolated value of that line in the pixel grid, which would be a grey value on both adjacent pixel positions. In contrast, snapping will move the line to the nearest integer pixel value, so that the resulting image will really contain a 1px wide black line.

Snapping is currently only supported by the Agg and MacOSX backends.

Parameters:
snapbool or None

Possible values:

  • True: Snap vertices to the nearest pixel center.
  • False: Do not modify vertex positions.
  • None: (auto) If the path contains only rectilinear line segments, round to the nearest pixel center.