Ask Your Question
1

Floating plots in notebook?

asked 2015-04-16 17:40:52 -0500

Eugene gravatar image

Is there a way to make plots float? Like in floating divs? Say, I have a two plots:

plot(sin, 0, pi).show()
plot(cos, 0, pi).show()

Right now this code produces two pictures, one on top of the other:

--------
|plot 1|
--------
|plot 2|
--------

But my screen is wide enough to show them alongside like:

----------------
|plot 1| plot 2|
----------------

It would be nice to have an option allowing to produce a few floating divs from pictures.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2015-04-19 06:43:03 -0500

ndomes gravatar image
html.table([[plot(sin,-pi,pi),plot(cos,-pi,pi)]])
edit flag offensive delete link more

Comments

Thanks for the answer too! I have the same question about approach with html, is there a way to use additional parameters, like axis labels to ticks? Again, preferably separately for each plot.

Eugene gravatar imageEugene ( 2015-04-19 10:51:51 -0500 )edit

You can use further options with the plot command, for example:

html.table([[plot(sin,-pi,pi,axes_labels=['X','Y']),plot(cos,-pi,pi,gridlines=True)]])
ndomes gravatar imagendomes ( 2015-04-19 11:43:56 -0500 )edit
1

answered 2015-04-16 18:15:36 -0500

tmonteil gravatar image

Not playing with html, but glueing the plots in a single one, you can use GraphicsArray:

sage: from sage.plot.graphics import GraphicsArray
sage: GraphicsArray([plot(sin, 0, pi), plot(cos, 0, pi)])
Launched png viewer for Graphics Array of size 1 x 2
edit flag offensive delete link more

Comments

Thanks for the answer! But in that case where do I put additional parameters like, for example, axis_labels? It would be nice to be able to control additional parameters separately for each plot. I tried to put them in GraphicsArray.show but that cause an error:

RuntimeError: should never launch viewer in embedded mode

and also affected all plots.

Eugene gravatar imageEugene ( 2015-04-19 10:50:31 -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

1 follower

Stats

Asked: 2015-04-16 17:40:52 -0500

Seen: 140 times

Last updated: Apr 19 '15