Skip to content

2d plotting and colours

3 messages · Earl F. Glynn, Paul Murrell, Gregoire Thomas

#
"Mulholland, Tom" <Tom.Mulholland at dpi.wa.gov.au> wrote in message
news:33F91FB3FDF42E4180428AC66A5CF30B02D3BAB0 at afhex01.dpi.wa.gov.au...
problem I was just showing the possibilities.
Using Windows with R 2.0.1 this looks fine at first.

But when I resize the graphic, copy the graphic to a metafile and paste it
into Word, or go to an earlier graphic and come back using "History", the
colors ae all messed up.  It's as if only the last palette is being used for
all four plots in the figure.  Oddly, if I copy the graphic as a bitmap, the
colors are preseved in the bitmap.  Is this a quirk of my machine or does
this happen for others?

Is it possible that the Windows palette manager is being used (which is such
about obsolete) and that true color graphics are not being used (which is
the easist way to avoid headaches from the Windows palette manager)?

efg
5 days later
#
Hi
Earl F. Glynn wrote:
I think this is happening because the setting of the R graphics palette 
is not being recorded on the R graphics display list.  Any window 
refresh will produce the effect.

Even worse, the R graphics palette is global to the R session, not 
per-device, so simply recording the setting of the palette on the 
(per-device) display list would only create a more subtle undesirable 
effect.

A possible solution is to make a per-device palette (and record the 
setting of the palette on the display list), but this is probably too 
big a change to get done for 2.1.0.

A workaround is simply to avoid using the palette.  For example,

n <- 5
par(mfrow = c(2,2))
palette("default")
barplot(1:25,col = 1:25)
barplot(1:25,col = rainbow(n))
cols <- rgb((0:15)/15, g=0,b=0, names=paste("red",0:15,sep="."))
barplot(1:25,col = cols)

Paul
#
And does this work?

n <- 5
par(mfrow = c(2,2))
palette("default")
barplot(1:25,col = 1:25)
pal <- rainbow(n)
barplot(1:25,col = pal[(1:25-1)%%n+1])
pal <- rgb((0:15)/15, g=0,b=0, names=paste("red",0:15,sep="."))
barplot(1:25,col = pal[(1:25-1)%%n+1])
Earl F. Glynn wrote: