[R] R graphics with Linux (libpng)
tagett at ipsogen.com
Fri Jan 12 14:07:30 CET 2007
Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes:
> On Thu, 11 Jan 2007, Rebecca Tagett wrote:
> > Hello,
> > I'm trying to adapt some R code that works on Windows so that it will work
> > on a Linux machine.
> > The command :
> > png("myFile.png", width=600, height=600)
> > fails claiming that it is impossible to establish a connection with X11.
> > (Error messages are in French, so I'm not pasting them here!)
> > I have libpng installed:
> >> rpm -qa libpng*
> > libpng-1.0.12-2
> > libpng-devel-1.0.12-2
> > So I don't understand why R thinks I'm trying to connect to X11. I haven't
> > been able to find many examples of R graphics code specifically for Linux,
> > but I have the impression that if libpng is installed, the graphics
> > are identical. The libpng manual is not useful, because it does not mention
> > use of libpng commands in an R environment.
> ?png says
> R can be compiled without support for either or both of these
> devices: this will be reported if you attempt to use them on a
> system where they are not supported. They may not be usable
> unless the X11 display is available to the owner of the R process.
> These are based on the 'X11' device, so the additional arguments
> to that device work, but are rarely appropriate. The colour
> handling will be that of the 'X11' device in use.
> 'bitmap' provides an alternative way to generate PNG and JPEG
> plots that does not depend on accessing the X11 display but does
> depend on having GhostScript installed. (Device 'GDD' in CRAN
> package 'GDD' is another alternative using several other
> additional pieces of software.)
> so the help page seems quite specific about the connection to X11.
I was referring to the libpng manual (see above), and not the R help page.
The 'Devices' help page is the one that threw me off course. It states that
X11 is the graphics driver for the X11 Window system, which I took to mean "MS
Windows" as opposed to "X window", thus I was surprised that Linux should go
looking for such a thing. I'm now wading through "R installation and
administration", which is very useful. Our systems manager is away, so your
patience is appreciated.
> > I'm using R 2.4.1, which I recently installed. Do I have to install a more
> > recent libpng ? If so, do I have to reconfigure and remake R ?
> The libpng is very old, but even more likely is that libz is too old.
> There were messages when you configured: did you read them at all? If
> not, plese do rebuild R and read them this time. Without the exact
> error message I cannot be sure, but I don't think this is the problem.
There were no errors on installation. However, I see that libz came with the R
package (it is in .../R-2.4.1/src/extra/zlib/libz.a), so it would have been
correctly installed along with the rest. Evidently libpng does not come with
the package. I'll download the recent version, install it, rebuild R, and try
to find out why my Linux doesn't recognize X11. Or perhaps I'll use bitmap()
with ghostscript, as Benilton Carvalho suggested.
> > I've also read that no graphics devices are available under R CMD BATCH.
> > Does that really mean that I can't create graphics from some R code that I
> > launch in noninteractive mode?
> Your source is incorrect: please advise the author(s) to correct it.
The source is the 'Devices' help page :
The following devices will be available if R was compiled to use
them and started with the appropriate '--gui' argument:
* 'X11' The graphics driver for the X11 Window system
* 'png' PNG bitmap device
* 'jpeg' JPEG bitmap device
None of these are available under 'R CMD BATCH'.
(no authors listed)
> Did you also read that you are asked not to send HTML mail? (That is from
> a reliable source.)
I knew that. I didn't do it on purpose... so very sorry.
More information about the R-help