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

Charles C. Berry cberry at tajo.ucsd.edu
Mon Oct 15 20:54:20 CEST 2007


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 confi...{{dropped:15}}



More information about the R-help mailing list