ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 29 May 2013 17:10:17 -0500Embedding R graphics device in Sage notebookhttps://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/Is it possible to embed an R graphics device (say, X11) in the Sage notebook rather than having it appear in a new window? I'm designing an interactive where this would be useful.Sun, 14 Apr 2013 17:47:57 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/Comment by jaia for <p>Is it possible to embed an R graphics device (say, X11) in the Sage notebook rather than having it appear in a new window? I'm designing an interactive where this would be useful.</p>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17634#post-id-17634That won't help, as what I really want is to have an R graphics device as part of a Sage interactive. Sorry; guess I should have said so in the original question.Mon, 27 May 2013 15:25:21 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17634#post-id-17634Comment by kcrisman for <p>Is it possible to embed an R graphics device (say, X11) in the Sage notebook rather than having it appear in a new window? I'm designing an interactive where this would be useful.</p>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17899#post-id-17899Probably in principle, but it would take a significant amount of work, and would only work locally, presumably? You may find RStudio more congenial for your needs - it's a great product, and Affero GPL!Mon, 15 Apr 2013 02:45:33 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17899#post-id-17899Answer by Jesustc for <p>Is it possible to embed an R graphics device (say, X11) in the Sage notebook rather than having it appear in a new window? I'm designing an interactive where this would be useful.</p>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?answer=14806#post-id-14806### Static plots -- *png* device
The answer seems to be the png device: see the accepted answer of [this question](http://ask.sagemath.org/question/315/how-to-use-r-with-sage).
### Interactive graphics -- *X11* device
Example:
sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinatesThu, 18 Apr 2013 22:38:49 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?answer=14806#post-id-14806Comment by Jesustc for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17626#post-id-17626@kcrisman I added your comment. Thanks!Tue, 28 May 2013 05:24:13 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17626#post-id-17626Comment by kcrisman for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17617#post-id-17617True; there is some work in that direction, though it hasn't seen fruition yet.Wed, 29 May 2013 17:10:17 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17617#post-id-17617Comment by Jesustc for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17629#post-id-17629@jaia: Answer edited. There you have it ;)Tue, 28 May 2013 02:30:21 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17629#post-id-17629Comment by Jesustc for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17851#post-id-17851Kudos to Mike Hansen!Fri, 19 Apr 2013 05:16:41 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17851#post-id-17851Comment by jaia for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17623#post-id-17623That's what I did before posting the question. Guess it's all we've got for now, but it would be nice to either get this not to pop out or get interactive plots some other way. Sage interactives are awesome and would be greatly enhanced by clickable graphics.Tue, 28 May 2013 07:52:29 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17623#post-id-17623Comment by kcrisman for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17853#post-id-17853Great answer - which I should have been totally aware of. I didn't think of this as a device, was thinking of the popup devices...Fri, 19 Apr 2013 02:42:47 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17853#post-id-17853Comment by jaia for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17633#post-id-17633Makes sense, but I want an R graphics device in order to use its clickable functionality (locate the cursor by clicking on the screen).Mon, 27 May 2013 15:26:51 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17633#post-id-17633Comment by kcrisman for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17627#post-id-17627I didn't know this would work - awesome! Just as an FYI to future readers of this... you *do* have to presumably have x11 support compiled in, which we have turned off by default on Mac, so this may not work there; instead, embedding the "quartz" device should work.Tue, 28 May 2013 05:03:10 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17627#post-id-17627Comment by Jesustc for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17624#post-id-17624Well, in the X11 case it doesn't embed either, but does exactly as you say. I guess @jaia will be happy with that :) But yeah, it would be great to have it embedded, and the same for the interactive interface of matplotlib. Unfortunately, my knowledge of the notebook is close to zero. I hope someone gets to do it at some point!Tue, 28 May 2013 06:57:20 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17624#post-id-17624Comment by kcrisman for <h3>Static plots -- <em>png</em> device</h3>
<p>The answer seems to be the png device: see the accepted answer of <a href="http://ask.sagemath.org/question/315/how-to-use-r-with-sage">this question</a>.</p>
<h3>Interactive graphics -- <em>X11</em> device</h3>
<p>Example:</p>
<pre><code>sage: r.X11() # pc-only
sage: r.quartz() # mac-only
sage: r.hist("rnorm(100)") # place your plot here
sage: r.locator(1) # example of interactivity: locate mouse "data" coordinates
</code></pre>
https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17625#post-id-17625Great! Note that I haven't tried this... and in fact it doesn't actually embed, but opens in a separate window. However, clicking on it (once only) does indeed put something in the notebook, which is pretty cool nonetheless. Could be worth exploring more.Tue, 28 May 2013 06:37:31 -0500https://ask.sagemath.org/question/10026/embedding-r-graphics-device-in-sage-notebook/?comment=17625#post-id-17625