I am kind of newbie on both sage and R, but since I have been playing
with both of these all week, here is my take.
> In particular I haven't a clue how R interfaces with SAGE. For
> example, setting plot parameters via "par(ann=0)" would be persistent
> in an R session, ie you wouldn't have to repeat this with every
> subsequent plot. When calling R from SAGE is there an R session that
> persists until it is killed explicitly or by exiting SAGE?
>
It calls R from a shared library (R compiled with --enable-R-shlib)
through open source interface between python and R called rpy.
> In R I usually make the plot first, then copy to ps,png,or pdf with
> dev.copy. I infer from the duscussion below that one doesn't see the
> plot directly in an R graphics window, but it is copied into the SAGE
> cell, whatever that is. [I assume the "os.curdir+'/out.ps'" is
> directing it to the SAGE cell?]
>
There are two ways (maybe more) to run sage. The issue being
discussed is when working on the sage notebook interface, which is
through a web browser. Images (png, jpeg) written to os.curdir are
grabbed by the notebook and displayed on the appropriate cell in the
web browser.
> Would it be helpful to have the R graphics window, allowing use of
> interactive graphical functions like locator() and identify(),
> plus the ability to construct a graph in steps and make additions
> before copying?
It is not entirely true that you cannot see the output in an R
graphics window. Running the console interface to sage on a computer
with an X server, you can do anything that works in native R or more
specifically anything you can do in rpy. The code you wrote works
exactly as expected with only a couple minor changes in console sage.
> import r from rpy
> r.X11()
> r.par(ann=0)
> values = [x for x in srange(0,float(pi),.1)]
> r.plot(values, [sin(x) for x in values], type='lines',lty=1, col="blue")
> r.lines(values, [cos(x) for x in values],col="red",lty=2)
> r.legend(r.locator(1),legend=r.c("sin","cos"),lty=r.c(1,2),col=r.c("blue","red"))
> r.dev_copy(r.postscript,os.curdir+'/out.ps')
> r.dev_off()
When I run that code in the sage notebook interface from a browser on
the same computer as the server it works just like the console version
by popping up a window. However, a user accessing the server from
another machine doesn't have that option (It seems just calling
r.X11() caused an infinite loop in this case). This eliminates access
to all the locator and identify interactive features and complicates
seeing the intermediate forms of a plot while building it (though I
can probably make that work with dev_copy).
In conclusion, having these same features available in the notebook
interface that the R graphics window allows in the console interface
would be helpful to me.
Jacob
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---