I am trying to change the plot window extents on an annotated plot to "zoom" into a certain window of interest. My text annotations fall outside of the plot window. If I use clip_on = True then all the text is hidden, but I just want to trim the text outside of the x-axis.
import matplotlib.pyplot as plt
x = [0,2,4,6,8,10]
y = [3,2,5,9,6,7]
plt.plot(x,y)
for i in range(len(x)):
plt.text(x[i],11, '%d' %y[i])
plt.axis([0,5,0,10])
Full data:
Reduced window:
Desired output:


