ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 19 Apr 2015 18:43:56 +0200Floating plots in notebook?https://ask.sagemath.org/question/26575/floating-plots-in-notebook/ 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.Fri, 17 Apr 2015 00:40:52 +0200https://ask.sagemath.org/question/26575/floating-plots-in-notebook/Answer by ndomes for <p>Is there a way to make plots float? Like in floating divs? Say, I have a two plots:</p>
<pre><code>plot(sin, 0, pi).show()
plot(cos, 0, pi).show()
</code></pre>
<p>Right now this code produces two pictures, one on top of the other:</p>
<pre><code>--------
|plot 1|
--------
|plot 2|
--------
</code></pre>
<p>But my screen is wide enough to show them alongside like:</p>
<pre><code>----------------
|plot 1| plot 2|
----------------
</code></pre>
<p>It would be nice to have an option allowing to produce a few floating divs from pictures.</p>
https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?answer=26594#post-id-26594
html.table([[plot(sin,-pi,pi),plot(cos,-pi,pi)]]) Sun, 19 Apr 2015 13:43:03 +0200https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?answer=26594#post-id-26594Comment by Eugene for <pre><code>html.table([[plot(sin,-pi,pi),plot(cos,-pi,pi)]])
</code></pre>
https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?comment=26596#post-id-26596Thanks 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.Sun, 19 Apr 2015 17:51:51 +0200https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?comment=26596#post-id-26596Comment by ndomes for <pre><code>html.table([[plot(sin,-pi,pi),plot(cos,-pi,pi)]])
</code></pre>
https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?comment=26599#post-id-26599You 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)]])Sun, 19 Apr 2015 18:43:56 +0200https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?comment=26599#post-id-26599Answer by tmonteil for <p>Is there a way to make plots float? Like in floating divs? Say, I have a two plots:</p>
<pre><code>plot(sin, 0, pi).show()
plot(cos, 0, pi).show()
</code></pre>
<p>Right now this code produces two pictures, one on top of the other:</p>
<pre><code>--------
|plot 1|
--------
|plot 2|
--------
</code></pre>
<p>But my screen is wide enough to show them alongside like:</p>
<pre><code>----------------
|plot 1| plot 2|
----------------
</code></pre>
<p>It would be nice to have an option allowing to produce a few floating divs from pictures.</p>
https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?answer=26576#post-id-26576Not playing with html, but glueing the plots in a single one, you can use [GraphicsArray](http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html#sage.plot.graphics.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
Fri, 17 Apr 2015 01:15:36 +0200https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?answer=26576#post-id-26576Comment by Eugene for <p>Not playing with html, but glueing the plots in a single one, you can use <a href="http://www.sagemath.org/doc/reference/plotting/sage/plot/graphics.html#sage.plot.graphics.GraphicsArray">GraphicsArray</a>:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?comment=26595#post-id-26595Thanks 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.Sun, 19 Apr 2015 17:50:31 +0200https://ask.sagemath.org/question/26575/floating-plots-in-notebook/?comment=26595#post-id-26595