I would like to have the output of print statements interlaced with plots, in the order in which they were printed and plotted in the Ipython notebook cell. For example, consider the following code:
(launching ipython with ipython notebook --no-browser --no-mathjax
)
%matplotlib inline
import matplotlib.pyplot as plt
i = 0
for data in manydata:
fig, ax = plt.subplots()
print "data number i =", i
ax.hist(data)
i = i + 1
Ideally the output would look like:
data number i = 0
(histogram plot)
data number i = 1
(histogram plot)
...
However, the actual output in Ipython will look like:
data number i = 0
data number i = 1
...
(histogram plot)
(histogram plot)
...
Is there a direct solution in Ipython, or a workaround or alternate solution to get the interlaced output?
%matplotlib inline
, you can callfig.show()
when you want the plot to display, I think.%matplotlib inline
. Additionally callingfig.show()
afterax.hist(data)
did not change the result.plt.show()
?plt.show()
did the trick