Ask Your Question

showing an external image in sage notbook

asked 2012-09-09 14:21:54 -0500

ebs gravatar image

Is there an easy way to show an image stored in local drive (or a website) in sage notebook?

The only way I know is using matplotlib:

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

img=mpimg.imread('<location of image file')
frame = plt.gca()

but, it is a roundabout way and shows the unecessary black border around the image.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-09 15:34:16 -0500

calc314 gravatar image

updated 2012-09-09 15:40:46 -0500

In a notebook, you can create a text cell by first positioning your mouse just above a cell and then shift-clicking. A palette will appear that includes a button on the right that will let you insert a link to an image.

You can also add some html code in the text cell by clicking on the "html" button in the palette.

If you prefer to work in a command cell, you can type:

html('<img src="">')

to display an image.

Another option is to upload the image using the "data" menu in the notebook. You can then do something like the following.

import Image'filename.png')'example.png')

This uses some python to display the image. You can also do various filters, rotations, etc. to the image using the Image class.

edit flag offensive delete link more


Wow this is really helpful. thanks :)

ebs gravatar imageebs ( 2012-09-09 15:49:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-09-09 14:21:54 -0500

Seen: 1,145 times

Last updated: Sep 09 '12