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()
Jacob
To avoid potential frustration, I just want to note that I tried
this on my OS X laptop and it does _not_ work:
{{{id=141|
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()
///
print "\x01r\x01e327"
Warning message:
In function (filename = "Rplot%03d.png", width = 480, height = 480, :
unable to open connection to X11 display ''
Traceback (most recent call last):
rpy.RPy_RException: Error in X11(paste("png::", filename, sep = ""),
width, height, pointsize, :
unable to start device PNG
}}}
--
Jacob Hicks
Mathematics Teacher
Trinity Collegiate School
Yes, that's true.
> I knew that was true
> for source installs of sage. I haven't ever used the binaries of
> sage, but it seems they could have the potential to support png output
> from R if they were compiled on a machine with the needed libraries.
They are built on fairly minimal machines, so that they will actually work.
Anyway, I hope an R expert such as you will improve matters regarding
R graphics in Sage. Send us patches, etc.!
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
That sounds definitely like something that should be done once we do more
work on a tighter integration between Sage and R.
> 1) Install the sage experimental package 'gd-2.0.34'
Any reason the current gd-2.0.35.p2 doesn't work? We are planning to
update to 2.0.36 anyway, I am just curious.
> install_package('gd-2.0.34')
>
> 2) Install the R package GDD
>
> From the notebook session:
> from rpy import *
> r("install.packages(('GDD'),,'http://www.rosuda.org/R')")
>
> 3) That's it.
> Run the following example:
>
> r.library("GDD")
> r.GDD("demo", type = "png", width=800, height=600)
> r.par(ann=0)
> values = [x for x in srange(0,float(pi),.01)]
> r.plot(values, [cos(x^2) for x in values], type='l')
> r.dev_off()
>
> Here is the link to the GDD package:
> http://cran.r-project.org/doc/packages/GDD.pdf
>
> Shahab
I think we should at least open a wishlist ticket for the above solution.
Depending on how large the GDD package for R is we might even do that per
default.
Cheers,
Michael