Ask Your Question
1

using 'R' in sage: can not plot. errors of X11 and PNG

asked 2012-01-26 07:15:47 +0100

mathematicboy gravatar image

Hi! We are going to use SAGE this semester in a course which has a piece of statistics. For this part we planned to compile Sage worksheets with the option 'R'. But we have the following errors. If we write the instruction:

x<-c(12,2,4)

y<-x

plot(x,y)

the instruction works in a mac which has a local sage (packages are on the hard disk). However, the pupils will use the sage server of our university (v4.6), wich gives the error message:

Error in png() : X11 is not available

The same error is obtained with a local installation on windows 7 (v4.7.2, with VM virtual box).

Besides, if we try at sage server on sagenb.org (v4.7.2), we obtain a different error:

Error in X11(paste("png::", filename, sep = ""), width, height, pointsize, : unable to start device PNG In addition: Warning message: In png() : no png support in this version of R

Please, does anybody know how to fix it?

Thank you.

edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted
2

answered 2012-01-26 11:48:24 +0100

Volker Braun gravatar image

Plotting with r does indeed work in the virtual machine now:

image description

edit flag offensive delete link more

Comments

That's what I thought, though you could have just commented that they should download the 4.8 ova file ;-) Interesting that one can post screenshots, I hadn't thought of that before, but it would be very natural in this context.

kcrisman gravatar imagekcrisman ( 2012-01-26 11:56:40 +0100 )edit

Yes I mainly posted the screenshot because I wanted to try out this feature ;-)

Volker Braun gravatar imageVolker Braun ( 2012-01-26 14:54:10 +0100 )edit
2

answered 2012-01-26 08:09:07 +0100

kcrisman gravatar image

updated 2012-01-26 20:22:00 +0100

If you look at the list of "related questions" on the right of this question, you'll see several things which should answer this for you. The most useful one should be Compiling R with PNG support (see in particular Jason Grout's answer).

Basically, you need to have certain other libraries installed and somehow made known to Sage for this to work on a Linux server. The 4.8 VirtualBox solution should now have this enabled (right, Volker?). Unfortunately, sagenb.org is currently missing this support as well. Maybe this should get fixed... see this sage-devel thread.

Edit: This now works on sagenb.org! Thanks to William for installing them.

edit flag offensive delete link more
0

answered 2012-05-25 11:13:50 +0100

Two setup to do so: command:sage -f r it will rebuilt the R in sage to enable plotting support. and then: png() x<-c(12,2,4) y<-x plot(x,y) dev.off()

edit flag offensive delete link more
0

answered 2012-02-01 08:24:27 +0100

mathematicboy gravatar image

Hi!

I've been trying to apply your advices and this is the result:

First I tried the just downloaded 4.8 ova file and the sagenb.org server. In both cases the result is the same, that is:

The instructions:

x=r([1,2,3,4,5])
y=r([1,2,3,2,1])
r.plot(x,y)

work fine.

However, when I write:

x<-c(1,2,3,4,5)
y<-c(1,2,3,2,1)
plot(x,y)

and try to compile with 'R', I don't obtain any error message, but the graphic is not shown. That is, I obtain an empty output.

Finally I tried with my ubuntu 10.4. and sage 4.8. I installed packages libpango1.0-dev and libcairo-dev with xorg-dev previously installed. I got an error that says 'Unable to start r' So I guess this is a matter of my lack of competence in linux and not a general problem.

edit flag offensive delete link more

Comments

1

In R, the plot command will write an Rplots.pdf to the current directory and not print anything on screen. Yes, using R thorugh sage is a bit more user-friendly. Arguably this is what Sage is about, making it easier to use scientific software.

Volker Braun gravatar imageVolker Braun ( 2012-02-01 15:40:48 +0100 )edit
1

You'd probably need to open and close a graphics device. See http://user2010.org/slides/Crisman.pdf, especially the part about "This example is due to Andrzej Giniewicz."

kcrisman gravatar imagekcrisman ( 2012-02-01 21:18:06 +0100 )edit
1

Thank you! It works now.

mathematicboy gravatar imagemathematicboy ( 2012-02-03 09:26:11 +0100 )edit

Sweet!

kcrisman gravatar imagekcrisman ( 2012-02-03 10:43:10 +0100 )edit

(I have to point out that it is unfortunate that I had to use four space characters just in order to do that last comment.)

kcrisman gravatar imagekcrisman ( 2012-02-03 10:43:51 +0100 )edit
0

answered 2012-01-26 14:42:44 +0100

mathematicboy gravatar image

Thank you for your quick and accurate answers. I'm sorry I did not know the questions on the right part of the screen. I tried to do a search and only found some threads and finally got lost. I'm not an expert.

I will try installing the 4.8 ova file but I have to wait, because the current version in the servers I have checked is 4.7.2.

But mainly I'm interested in fixing the sage server of my university. So I will show your answers to the administrator of that server to see what is more suitable.

I will tell you the end of the story. Thank you so much!!!

edit flag offensive delete link more

Comments

Great, update us!

kcrisman gravatar imagekcrisman ( 2012-01-26 16:34:14 +0100 )edit

As the questions on the side, I just wanted to point out that this, somewhat surprisingly, often turns out to be quite helpful. Of course, they wouldn't show up until you've asked the question, so you could hardly have known.

kcrisman gravatar imagekcrisman ( 2012-01-26 16:34:49 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-01-26 07:15:47 +0100

Seen: 4,615 times

Last updated: May 25 '12