When drawing text in matplotlib
with text()
, and then interactively panning the image, the resulting drawn text is not clipped to the data window. This is counter to how plotting data or drawing text using annotate()
works, and doesn't make intuitive sense as text()
uses data window coordinates.
import matplotlib.pyplot as pltplt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)ax.text(0.5, 0.2, 'text')
ax.annotate('anno', (0.5, 0.3))plt.draw()
Interactively pan the text out of the data window on all sides. The annotate()
drawn 'anno' is clipped when the reference point crosses the data window boundary, while the text()
drawn 'text' is not.
I'm not sure if this behavior a feature or a bug, but sure seems like the latter, as this text interferes with axis labels, etc. Using 1.2.1 with TkAgg backend.
An additional question would be how to properly clip all text from going outside the data window, not just when the reference coordinate does.
Thanks!