matplotlib.artist.Artist.set_snap#

Artist.set_snap(snap)[source]#

Set the snapping behavior.

Snapping aligns positions with the pixel grid, which results inclearer images. For example, if a black line of 1px width wasdefined at a position in between two pixels, the resulting imagewould contain the interpolated value of that line in the pixel grid,which would be a grey value on both adjacent pixel positions. Incontrast, snapping will move the line to the nearest integer pixelvalue, so that the resulting image will really contain a 1px wideblack 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 linesegments, round to the nearest pixel center.

On this page