Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5dfd52d

Browse files
committed
update annotations
1 parent f677f36 commit 5dfd52d

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

lib/matplotlib/tests/test_text.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import matplotlib
99
import matplotlib.pyplot as plt
1010
from matplotlib.testing.decorators import image_comparison
11+
from matplotlib.gridspec import GridSpec
1112

1213

1314
needs_usetex = pytest.mark.skipif(
@@ -499,3 +500,16 @@ def test_text_repr():
499500
plt.plot(['A', 'B'], [1, 2])
500501
txt = plt.text(['A'], 0.5, 'Boo')
501502
print(txt)
503+
504+
505+
def test_annotation():
506+
plt.close('all')
507+
fig, ax = plt.subplots(1, 1)
508+
an = ax.annotate('annotation', xy=(0.5, 0.5))
509+
extent1 = an.get_window_extent(fig.canvas.get_renderer())
510+
fig.tight_layout()
511+
extent2 = an.get_window_extent(fig.canvas.get_renderer())
512+
513+
np.testing.assert_raises(AssertionError, np.testing.assert_allclose,
514+
extent1.get_points(),extent2.get_points(),
515+
rtol=1e-6)

lib/matplotlib/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,6 +2354,7 @@ def get_window_extent(self, renderer=None):
23542354
*dpi* used defaults to self.figure.dpi; the renderer dpi is
23552355
irrelevant.
23562356
'''
2357+
self.update_positions(renderer)
23572358
if not self.get_visible():
23582359
return Bbox.unit()
23592360

setup.cfg.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# set this to True. It will download and build a specific version of
1414
# FreeType, and then use that to build the ft2font extension. This
1515
# ensures that test images are exactly reproducible.
16-
#local_freetype = False
16+
# local_freetype = False
1717

1818
[status]
1919
# To suppress display of the dependencies and their versions

0 commit comments

Comments
 (0)