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()

On Jan 24, 10:46 am, mhampton <[EMAIL PROTECTED]> wrote:
> I am interested in helping with this, since I'd like to impress my
> statistics colleagues at some point with what sage can do.
>
> As I wrote in another thread, it seems that the graphics output of R
> in sage is set when you first create a plot.  The output is sent to
> Rplots.ps.  After that, further plots are appended to the original
> (which is definitely not desired behavior).  So somehow R has to be
> told to change the output to go to os.curdir.  Within R, it looks like
> these options are controlled by commands within the grDevices package,
> which has commands like
>
> postscript(file = ifelse(onefile, "Rplots.ps", "Rplot%03d.ps"),
> onefile = TRUE, family, title = "R Graphics Output", fonts = NULL,
> encoding, bg, fg, width, height, horizontal, pointsize, paper,
> pagecentre, print.it, command, colormodel)
>
> and
>
> png(filename = "Rplots%03d.png", width = 480, height = 480, units =
> "px", pointsize = 12, bg = "white", res = NA, ...)
>
> I would think we would want to switch to png from postscript.
>
> I'll look into it a bit more today.
>
> -Marshall Hampton
>
> On Jan 24, 9:48 am, "William Stein" <[EMAIL PROTECTED]> wrote:
>
> > On Jan 24, 2008 7:32 AM, Jacob Hicks <[EMAIL PROTECTED]> wrote:
>
> > > After playing with histograms for a while in sage, I have started to delve
> > > into the source and documentation of rpy.  I want to make it work more
> > > seamlessly with sage than it does now.  My first priority, which would be 
> > > of
> > > immediate use to me in the classroom, is to make rpy graphics insert
> > > themselves into the notebook interface in a manner similar to the behavior
> > > matplot has now.  Depending on how that goes, I may also want to clean up
> > > the way rpy interacts with sage in general and work on using R extensions.
>
> > Just a quick remark.  The way that notebook images work is that
> > all png, jpg, etc. images that get output to os.curdir when a cell
> > gets evaluated, will *automatically* appear as images embedded
> > in the notebook.  You don't have to do anything else but that.
>
> > E.g., if you have a command foo such that foo(filename) writes
> > an image to the file with name filename, then
>
> > foo(os.curdir + '/image.png')
>
> > will result in an image being embedded in the notebook.  Simple
> > as that.
>
> > > I have a computer science background, but am a little rusty and have never
> > > worked on a major project in python.  This makes working on sage seem
> > > daunting.  I have looked over the programmer's guide but am still not 
> > > quite
> > > sure how everything works.  Are there any other good places to search for
> > > help about sage's overall structure / getting started in a project like 
> > > this
> > > one?
>
> > You of course need to read the Python tutorial if you haven't already.
> > Also, the Sage programming guide is supposed to be what you want
> > (though whether it is is arguable):
> >    http://sagemath.org/doc/html/prog/index.html
>
> > William
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@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-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to