from Is there a way of drawing a caption box in matplotlib
from matplotlib import pyplot as plt
import numpy as np
x = np.arange(0,3,.25)
y = np.sin(x)
txt = '''
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.'''
fig = plt.figure()
ax1 = fig.add_axes((.1,.4,.8,.5))
ax1.bar(x,y,.2)
fig.text(.1,.1,txt) #<-doesn't work interactively
#plt.show()
This code works if I run it as a script. But if I first run everything up to, but not including the fig.text
line, then I input the fig.text
line into the console, the txt
doesn't show up in the figure! Why?