[R] Error: X11 cannot allocate additional graphics colours.

Marc Schwartz marc_schwartz at comcast.net
Mon Oct 15 22:40:52 CEST 2007


This is not a X server version issue.

There are Linux system (not R) display settings that will dictate the
number of simultaneous colors that can be displayed. This will be
dependent upon the display resolution defined and the amount of video
RAM on the graphics card. The higher the display resolution the more
video memory it takes since you have more pixels. The more colors you
want to display simultaneously, the more memory per pixel it takes.

Those concepts, BTW, are the same on Windows and OS X.

So if you are running directly on the RHEL system, check the display
setting to be sure that it is set for a sufficient number of colors.
This would be an administrative task requiring root privilege. Ideally,
you want so-called TrueColor or "Millions of Colors" to be set. This
requires a pixel depth of 24 bpp or 32 bpp, depending upon VRAM
available.

On the other hand, if you are connected remotely to the RHEL server,
using ssh and Xvfb on a server that is not running X, then you will need
to adjust (or have the SysAdmin adjust) the -pixdepths setting on the
RHEL server. This controls the 'bpp' available on the server. 

See 'man Xvfb' for more information for the latter scenario.

HTH,

Marc Schwartz

On Mon, 2007-10-15 at 20:53 +0100, michael watson (IAH-C) wrote:
> Thanks for the response...
> 
> My confusion about plot stems from the fact I am plotting 82 points
> with 82 colours, so surely all colours get plotted?
> 
> As for updating X, I recently installed the latest version of XFree86
> for my version of linux, RHEL 4.
> 
> As for Brian's e-mail you quoted, I do try and look at things like
> that, but I don't know what arguments he refers to:
> 
> "Run the X11 device with the arguments stated"
> 
> Which arguments, and how do I run my X11 device with them?
> 
> I've pretty much had this problem with every version of R on linux,
> all the way from SuSe 8.2 to SuSe 9.2, through to RHEL3 and now RHEL4
> - I always have this problem.
> 
> Perhaps you could tell me which version of X you use to generate 1000
> colours without getting the error message?  I'm sorry, but what i
> would really love is someone to say "RHEL4?  Aha , you need to install
> X version foo, available from http://www.foo.com/bar.rpm...)
> 
> -----Original Message-----
> From: Charles C. Berry [mailto:cberry at tajo.ucsd.edu]
> Sent: Mon 15/10/2007 7:54 PM
> To: michael watson (IAH-C)
> Cc: r-help at r-project.org
> Subject: Re: [R] Error: X11 cannot allocate additional graphics colours.
>  
> 
> You knew this?
> 
>  	http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0640.html
> 
> I cannot replicate your error. I use n <- 1000 on R-2.6.0, and it still 
> works.
> 
> 
> Only a guess, but maybe your X setup is out of date. Maybe an update would 
> help?
> 
> As for why axis triggers this, axis uses all the colors, but image only 
> uses (something like) those that fall into the bins shown here:
> 
>  	hist( mat, breaks=n )
> 
> 
> 
> As you see there are usually some empty bins and those colors do not get 
> rendered till axis() does its thing.
> 
> Chuck
> 
> On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:
> 
> > Dear All
> >
> > Another one I have touched on before with a much older OS and version.
> >
> > My sessionInfo() is:
> >> sessionInfo()
> > R version 2.5.1 (2007-06-27)
> > i686-redhat-linux-gnu
> >
> > locale:
> > LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
> > TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
> > 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> > ENTIFICATION=C
> >
> > attached base packages:
> > [1] "stats"     "graphics"  "grDevices" "utils"     "datasets"
> > "methods"
> > [7] "base"
> >
> > other attached packages:
> > DetectiV
> >   "1.1"
> >
> > I'm getting the following error message when plotting a quite complex
> > graph:
> >
> > Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> > NA,  :
> >        Error: X11 cannot allocate additional graphics colours.
> > Consider using X11 with colortype="pseudo.cube" or "gray".
> >
> > The problem is I only get it under certain circumstances.  I have some
> > quite convoluted test code:
> >
> > n <- 82
> > mat <- matrix(rnorm(n*10), ncol=n)
> > fcolors <- terrain.colors(n)
> > image(z=mat, axes=FALSE)
> > oneis <- 1 / ncol(mat)
> > sptl <- oneis / 3
> > max <- 1:n * oneis
> > min <- c(0, max[1:length(max)-1])
> > for (i in 1:n) {
> > 	axis(side=2, at=c(min[i]-sptl,max[i]+sptl), labels=NA, line=0.9,
> > lwd=3, lty=1, tick=TRUE, tck=0, col=fcolors[i],lend=2)
> > }
> >
> > Now, this code works without error on values of n up to and including
> > 81, but produces the error when it is 82:
> >
> > Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> > NA,  :
> >        Error: X11 cannot allocate additional graphics colours.
> > Consider using X11 with colortype="pseudo.cube" or "gray".
> >
> > The issue I have with it is that if I do a normal plot operation, I
> > don't get the error!
> >
> > n <- 82
> > fcolors <- terrain.colors(n)
> > plot(1:n,1:n, col=fcolors)
> >
> > Here the plot works, there are no errors and the colours come out fine.
> > But when I use the axis command, in the more complex code above, I get
> > an error.
> >
> > The real question I want to know is how can I enable R (or my OS) to
> > plot a greater number of colours?  I can plot 820 colours on R under
> > windows, probably more, I just plucked 820 out of the air.  I'm guessing
> > this is because my windows graphics card can produce that many colours,
> > whereas on linux I am limited by what x-windows can produce, but there
> > must be some way of increasing the number of colours I can plot using R
> > under linux...?
> >
> > Many thanks
> > Mick
> >
> > The information contained in this message may be =\ co...{{dropped:20}}
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list