William asked me to post a copy of an off-line discussion to this list. Here it is:
Since I still haven't gotten around to learning SAGE, I am operating from a purely R-centric perspective here. 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? 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?] 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? For example, (just making stuff up :-) 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(locator(1),legend=c("sin","cos"),lty=c(1,2),col=c("blue","red")) r.dev.copy(postscript,os.curdir+'/out.ps') r.dev_off() albyn On Thu, Jan 24, 2008 at 02:40:26PM -0500, David Perkinson wrote: > ----- Forwarded message from William Stein <[EMAIL PROTECTED]> ----- > > Date: Thu, 24 Jan 2008 11:38:40 -0800 > From: William Stein <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED], [EMAIL PROTECTED] > Subject: [sage-newbie] Re: [sage-devel] Re: R and rpy > > > On Jan 24, 2008 9:24 AM, mhampton <[EMAIL PROTECTED]> wrote: > > > > OK I think I have learned a little. The following code seems to flush > > the output properly, and sends it to the current cell. > > > > r.postscript(os.curdir+'/out.ps') > > 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') > > r.dev_off() > > > > Cool. The following slight variant plots perfectly in any cell, etc., > and doesn't > display any funny cruft: > > from rpy import r > r.png(os.curdir+'/sage.png') > r.par(ann=0) > values = [x for x in srange(0,float(pi),.1)] > r.plot(values, [cos(x^2) for x in values], type='l') > _ = r.dev_off() > > Now somebody needs to start on the "nice usage of R from Sage" package for > Sage, which will have a plot wrapper, etc., etc., This would likely go in > *the* > already existing directory > > SAGE_ROOT/devel/sage/sage/stats/ > > In fact, it would be best if like with symbolic calculus we view this > as a general > package for doing statistics, which just happens to built almost entirely on > R. > But we could also provide hooks into some of the very formidable (or > not?) statistics > capabilities of SciPy. > > -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---