Skip to content

background colors in image()

5 messages · Brian Ripley, Romain Francois, array chip

#
Hi, I am using image() function to plot a matrix which
has some missing valuies (NA). It looks like, by
default, missing values were drawn in white color, How
can I change that into a different color, say a gray
color? I tried to use bg='gray' argument with no luck.
Anyone has a suggestion?

Thanks
#
On Wed, 10 Aug 2005, someone needing to conceal his real name wrote:

            
They are not drawn in white: in fact they are not drawn at all, so the 
current background (or if transparent, the canvas) is what you see.
works, for example.
#
Thanks for the suggestion! It works in a way that the
entire graph window is in the background color, is
there a way to only have the plotting area (i.e. the
area within the axis box in the background color, but
leave the area outside the axes to be unchanged
(white)?

Thanks!
--- Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:

            
#
Le 11.08.2005 00:59, array chip a ??crit :
You need to learn how to use par('usr') and argument add in image.
demo('graphics') is one way to learn or look at graph 8 on r graph gallery

R> image(matrix(c(1,2,NA, 1),2, 2))
R> usr <- par('usr')
R> rect(usr[1], usr[3], usr[2], usr[4], col="cornsilk")
R> image(matrix(c(1,2,NA, 1),2, 2),add=TRUE)

Romain

  
    
#
Romain,

Thanks for the code. It worked perfectly!
--- Romain Francois <francoisromain at free.fr> wrote:

            
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~