Skip to content

Commit 7bb13b5

Browse files
committed
Merge pull request #4422 from tacaswell/fix_circle_marker_snap
FIX : turn path snapping off on 'o' marker path
2 parents 860ef93 + 1702786 commit 7bb13b5

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Changed snap threshold for circle markers to inf
2+
````````````````````````````````````````````````
3+
4+
When drawing circle markers above some marker size (previously 6.0)
5+
the path used to generate the marker was snapped to pixel centers. However,
6+
this ends up distorting the marker away from a circle. By setting the
7+
snap threshold to inf snapping is never done on circles.
8+
9+
This change broke several tests, but is an improvement.

lib/matplotlib/markers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def _half_fill(self):
346346

347347
def _set_circle(self, reduction=1.0):
348348
self._transform = Affine2D().scale(0.5 * reduction)
349-
self._snap_threshold = 6.0
349+
self._snap_threshold = np.inf
350350
fs = self.get_fillstyle()
351351
if not self._half_fill():
352352
self._path = Path.unit_circle()

lib/matplotlib/tests/test_axes.py

+12
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,18 @@ def test_set_get_ticklabels():
35863586
ax[1].set_yticklabels(ax[0].get_yticklabels() )
35873587

35883588

3589+
@image_comparison(baseline_images=['o_marker_path_snap'], extensions=['png'],
3590+
savefig_kwarg={'dpi': 72})
3591+
def test_o_marker_path_snap():
3592+
fig, ax = plt.subplots()
3593+
ax.margins(.1)
3594+
for ms in range(1, 15):
3595+
ax.plot([1, 2, ], np.ones(2) + ms, 'o', ms=ms)
3596+
3597+
for ms in np.linspace(1, 10, 25):
3598+
ax.plot([3, 4, ], np.ones(2) + ms, 'o', ms=ms)
3599+
3600+
35893601
@cleanup
35903602
def test_margins():
35913603
# test all ways margins can be called

0 commit comments

Comments
 (0)