Regarding the issue that when moving the canvas, text is displayed outside the canvas window

Hello everyone
When using the cross tool to move the canvas, if the annotation text also moves and displays this outside the canvas range, how to solve this problem?

Hi @ZinkinLien I’m not sure I understand the problem. Perhaps you could add one or more screenshots to show what’s going wrong?

My guess as to the question is what using the pan tool, and text are not not clipped to the Axes by default so

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
txt = ax.text(.5, .5, 'hi bob')
plt.show()

will when panned show the text outside the Axes (until it is evetnually clipped by leaving the Figure).

adding

txt.set_clip_on(True)

will clip the text to the Axes edges.