Skip to content

x11 colortype problems ('gray' is broken?) (PR#512)

2 messages · Thomas J Vogels, Brian Ripley

#
Hi,

  I occasionally run out of color in my X11 terminal.  At this
point, R will issue this error message:
        Error: X11 cannot allocate additional graphics colors.
Consider using colortype="pseudo.cube" or "gray".

An immediate x11(colortype="pseudo.cube") doesn't work as the
colortype seems to be shared among the different x11 plotting windows.
So I have to close all windows first, then I can open an x11 device
with the colortype "pseudo.cube".  (Neither the necessity to close all
windows nor the fact, that colortype is an option to X11 and not to
the plot command, is clear from the help pages or the error message.)

The real problem, however, comes with x11(colortype="gray") as this
brings up just a black screen (and it stays black).  I can't quite see
whether I'm stumbling across some issues with X resources, here.
x11() usually gives a white background.

Thanks,
  -tom


 --
platform = i586-unknown-linux
arch = i586
os = linux
system = i586, linux
status = 
major = 1
minor = 0.0
year = 2000
month = February
day = 29
language = R
#
On Fri, 7 Apr 2000 tov@ece.cmu.edu wrote:

            
There is a single colortype shared by all x11 devices.  That couild eb
clearer!
No. It's a bug.  When you set x11(colortype="gray") it tries to allocate
min(256, 2^depth) colours, that is all the colours on an 8-bit display.
That is clearly going to fail (unless perhaps your window manager is 
in mono).  So it does fail, set PaletteSize = 0, and then maps all
colours to black.  That's what the x11 driver seems to do when colour
allocation fails.  I suspect it should not open at all under those 
circumstances.

Quick fix:

static void SetupGrayScale()
{
    PaletteSize = 0;
    if (depth > 7)
	depth = 7;
    if (GetGrayPalette(display, colormap, 1 << depth) == 0)
	depth = 1;
}

(8 replaced by 7) in devX11.c.  I'll commit a more sophisticated one
to R-release.