Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,12 @@ def _set_mathtext_path(self):
if len(text.vertices) == 0:
return

xmin, ymin = text.vertices.min(axis=0)
xmax, ymax = text.vertices.max(axis=0)
width = xmax - xmin
height = ymax - ymin
max_dim = max(width, height)
self._transform = Affine2D() \
.translate(-xmin + 0.5 * -width, -ymin + 0.5 * -height) \
.scale(1.0 / max_dim)
bbox = text.get_extents()
max_dim = max(bbox.width, bbox.height)
self._transform = (
Affine2D()
.translate(-bbox.xmin + 0.5 * -bbox.width, -bbox.ymin + 0.5 * -bbox.height)
.scale(1.0 / max_dim))
self._path = text
self._snap = False

Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ def draw_ref_marker(y, style, size):
ax_ref.set(xlim=(-0.5, 1.5), ylim=(-0.5, 1.5))


# The bullet mathtext marker is not quite a circle, so this is not a perfect match, but
# it is close enough to confirm that the text-based marker is centred correctly. But we
# still need a small tolerance to work around that difference.
@check_figures_equal(extensions=['png'], tol=1.86)
def test_text_marker(fig_ref, fig_test):
ax_ref = fig_ref.add_subplot()
ax_test = fig_test.add_subplot()

ax_ref.plot(0, 0, marker=r'o', markersize=100, markeredgewidth=0)
ax_test.plot(0, 0, marker=r'$\bullet$', markersize=100, markeredgewidth=0)


@check_figures_equal()
def test_marker_clipping(fig_ref, fig_test):
# Plotting multiple markers can trigger different optimized paths in
Expand Down