-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Milestone
Description
Bug summary
Previously, I had been using ax.texts.append(annotation)
to control mouseover interaction (appearance of texts) - that seemed to work in 3.4.3, in 3.5.1 it is broken.
Code for reproduction
import matplotlib
print(matplotlib.__version__)
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
tant = ax.annotate("", xy=(0,0), xytext=(2,2),textcoords="offset points", bbox=dict(boxstyle="round", fc="w"), zorder=10)
print(ax.texts)
ax.texts.append(tant)
print(ax.texts)
Actual outcome
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> print(matplotlib.__version__)
3.5.1
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> tant = ax.annotate("", xy=(0,0), xytext=(2,2),textcoords="offset points", bbox=dict(boxstyle="round", fc="w"), zorder=10)
>>> ax.texts
<Axes.ArtistList of 1 texts>
>>> ax.texts.append(tant)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/_collections_abc.py", line 962, in append
self.insert(len(self), value)
File "~/venv_mpl/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 1392, in insert
getattr(self._axes, self._add_name)(item)
AttributeError: 'AxesSubplot' object has no attribute 'add_text'
Expected outcome
From a jupyter notebook with matplotlib 3.4.1, output is:
3.4.3
[Text(2, 2, '')]
[Text(2, 2, ''), Text(2, 2, '')]
Additional information
No response
Operating system
Ubuntu 20.05
Matplotlib Version
3.5.1
Matplotlib Backend
TkAgg, module://matplotlib_inline.backend_inline
Python version
3.8.10
Jupyter version
No response
Installation
No response
Metadata
Metadata
Assignees
Labels
No labels