Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There's no good way to put them in the "correct order". Due to the way the notebook works, all of the plots are shown after all of the text output. I don't believe the notebook takes into account the file creation times when choosing what order to display the images -- it's just alphabetical.

Your best bet is to put the first two commands in one cell, and the second two in a different cells.

There's no good way to put them in the "correct order". Due to the way the notebook works, all of the plots are shown after all of the text output. I don't believe the notebook takes into account the file creation times when choosing what order to display the images -- it's just alphabetical.

Your best bet is to put the first two commands in one cell, and the second two in a different cells.cells.

A slightly more complicated solution is to save the plots to the data directory in a cell like:

plot(sin(x)).save(DATA+"/p1.png")
plot(cos(x)).save(DATA+"/p2.png")

Then, you can reference those in another cell like:

print "sin(x)"
print html('<img src="data/p1.png"/>')
print "cos(x)"
print html('<img src="data/p2.png"/>')
click to hide/show revision 3
Fixed to address comment.

There's no good way to put them in the "correct order". Due to the way the notebook works, all of the plots are shown after all of the text output. I don't believe the notebook takes into account the file creation times when choosing what order to display the images -- it's just alphabetical.

Your best bet is to put the first two commands in one cell, and the second two in a different cells.

A slightly more complicated solution is to save the plots to the data directory in a cell like:

plot(sin(x)).save(DATA+"/p1.png")
plot(cos(x)).save(DATA+"/p2.png")

We'll use a little helper function to fix issues with reloading. (The timestamp after the image filename keeps the browser from caching it).:

def data_image(filename):
    import time
    return html('<img src="data/%s?%s"/>'%(filename, time.time()))

Then, you can reference those in another cell like:

print "sin(x)"
print html('<img src="data/p1.png"/>')
data_image('p1.png')
print "cos(x)"
print html('<img src="data/p2.png"/>')
data_image('p2.png')