Jupyter notebook matplotlib figures show up small until cell is completed

Viewed 1704

I'm trying to make a notebook where the data produced by a long for loop is put in a graph point by point. However, when using %matplotlib notebook and fig.canvas.draw() the graph is tiny up until the cell finishes running. (In fact, I've got many of those graphs and they are even tinyer when using more subplots.)

Here my code reproducing the behaviour in a jupyter notebook, at least on OS X with (latest) jupyter-core 4.3.0 and (latest) matplotlib 2.0.2.

%matplotlib notebook
import time
import matplotlib.pyplot as plt

fig, ax = plt.subplots(1, 1)
for _ in range(5):
    ax.plot([1,2,3], [1,2,3])
    fig.canvas.draw()
    time.sleep(1)

During the cell execution I get this plot

Small image

And when the cell finishes execution (after 5 seconds) I get this

enter image description here

I would like to get the larger image even during cell execution. What am I doing wrong?

1 Answers
Related