First time here? Check out the FAQ!

Ask Your Question
4

In-line graphics for Sage in ipython notebook?

asked 11 years ago

sswatson gravatar image

I am running Sage on a local machine (OS X Mavericks) from an ipython notebook. Everything works fine except that I don't have pretty printing or in-line graphics (2D or 3D) -- the graphics launch in Preview.app. Is it possible to obtain either of these features in the ipython notebook interface?

Preview: (hide)

4 Answers

Sort by » oldest newest most voted
2

answered 9 years ago

eric_g gravatar image

Hi,

With a recent version of Sage (at least 6.6, but 6.7 (released 2 days ago!) is recommended), 2D and 3D inline plots in the IPython notebook work nicely when the notebook is started by the command

sage -n ipython
Preview: (hide)
link

Comments

Fantastic!!!! tested in Sage 6.7, it works like a charm!

jguzman gravatar imagejguzman ( 9 years ago )
1

answered 11 years ago

ppurka gravatar image

I don't have ipython notebook installed either system wide or in sage. Perhaps the instructions in the following website helps?

http://pub.ist.ac.at/~jguzman/doc/pro...

Preview: (hide)
link

Comments

Thanks for the link. I put the suggested lines in my init file, but they only apply to figures generated through matplotlib (not plots generated using the Sage plot command).

sswatson gravatar imagesswatson ( 11 years ago )

You can post this in sage-support. I don't know of any trivial way to do this.

ppurka gravatar imageppurka ( 11 years ago )

I have the same question here. Hope there is a way to solve it.

Han gravatar imageHan ( 10 years ago )
0

answered 9 years ago

jguzman gravatar image

updated 9 years ago

The link points to my website, which I recently updated. The only way I found at the moment to plot inline was to enter this in the IPython notebook:

 %load_ext sage
 from IPython.display import display, Image
 x = var('x')
 plot(sin(x), 0, 2*pi, figsize=4).save('/tmp/foo.png')
 display(Image('/tmp/foo.png')
Preview: (hide)
link

Comments

tested with Sage 6.7

jguzman gravatar imagejguzman ( 9 years ago )
0

answered 0 years ago

you can try this

x = var('x')

p1 = plot(sin(x**Integer(2)), (x, Integer(0), Integer(6)), axes_labels=[r'θ', r'sin(θ2)'], fontsize=Integer(16))

p2 = plot(x**Integer(3), (x, Integer(1), Integer(100)), axes_labels=[r'x', r'y'], scale='semilogy', frame=True, gridlines='minor')

ga = graphics_array([p1, p2])

ga.matplotlib(figsize=(8., 5.))

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 11 years ago

Seen: 1,611 times

Last updated: Nov 30 '24