Skip to content

Commit 53b41f8

Browse files
committed
Snap markers to subpixels instead of whole ones
We cache the marker for performance, but this causes it to look very pixel-grid aligned, especially if there are multiple in a regular pattern, or they are animated. Apply the same algorithm as mplcairo noted by @anntzer in matplotlib#7233, specifically, render and cache the marker in *n_subdiv* levels in each direction, and pick the closest one for each marker. Fixes matplotlib#7233
1 parent 05dd034 commit 53b41f8

12 files changed

Lines changed: 107 additions & 61 deletions

‎lib/matplotlib/backends/backend_agg.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from matplotlib.dviread import Dvi
3535
from matplotlib.font_manager import fontManager as _fontManager, get_font
3636
from matplotlib.ft2font import LoadFlags, RenderMode
37+
from matplotlib.markers import MarkerStyle
3738
from matplotlib.mathtext import MathTextParser
3839
from matplotlib.path import Path
3940
from matplotlib.transforms import Bbox, BboxBase
@@ -87,11 +88,17 @@ def __setstate__(self, state):
8788
def _update_methods(self):
8889
self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles
8990
self.draw_image = self._renderer.draw_image
90-
self.draw_markers = self._renderer.draw_markers
9191
self.draw_path_collection = self._renderer.draw_path_collection
9292
self.draw_quad_mesh = self._renderer.draw_quad_mesh
9393
self.copy_from_bbox = self._renderer.copy_from_bbox
9494

95+
def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):
96+
pixel = MarkerStyle(',')
97+
is_pixel = (marker_path == pixel.get_path() and
98+
marker_trans == pixel.get_transform())
99+
self._renderer.draw_markers(gc, marker_path, marker_trans, path, trans,
100+
face=rgbFace, is_pixel_marker=is_pixel)
101+
95102
def draw_path(self, gc, path, transform, rgbFace=None):
96103
# docstring inherited
97104
nmax = mpl.rcParams['agg.path.chunksize'] # here at least for testing
-10.9 KB
Loading
-1 Bytes
Loading
-1 Bytes
Loading
-10.3 KB
Loading
-7.47 KB
Loading
-3.2 KB
Loading
-9.2 KB
Loading
-33.2 KB
Loading
-2.49 KB
Loading

0 commit comments

Comments
 (0)