Ask Your Question

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

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

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:




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

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

Volker Braun gravatar image

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

image description

edit flag offensive delete link more


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 +0200 )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 +0200 )edit

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

kcrisman gravatar image

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

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, is currently missing this support as well. Maybe this should get fixed... see this sage-devel thread.

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

edit flag offensive delete link more

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

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)

edit flag offensive delete link more

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

mathematicboy gravatar image


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 server. In both cases the result is the same, that is:

The instructions:


work fine.

However, when I write:


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



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 +0200 )edit

You'd probably need to open and close a graphics device. See, especially the part about "This example is due to Andrzej Giniewicz."

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

Thank you! It works now.

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


kcrisman gravatar imagekcrisman ( 2012-02-03 10:43:10 +0200 )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 +0200 )edit

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

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


Great, update us!

kcrisman gravatar imagekcrisman ( 2012-01-26 16:34:14 +0200 )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 +0200 )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


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

Seen: 4,561 times

Last updated: May 25 '12