Skip to content

Commit 6f01dc4

Browse files
committed
Fix for older matplotlib, but warn
1 parent f1a772e commit 6f01dc4

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

adjustText/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,15 @@ def adjust_text(
410410
return
411411
if ax is None:
412412
ax = plt.gca()
413-
ax.figure.draw_without_rendering()
413+
try:
414+
ax.figure.draw_without_rendering()
415+
except AttributeError:
416+
logging.warn(
417+
"""Looks like you are using an old matplotlib version.
418+
In some cases adjust_text might fail, if possible update
419+
matplotlib to version >=3.5.0"""
420+
)
421+
ax.figure.canvas.draw()
414422
try:
415423
transform = texts[0].get_transform()
416424
except IndexError:

0 commit comments

Comments
 (0)