[R] Color index in image function
FMH
kagba2006 at yahoo.com
Mon Sep 7 16:59:03 CEST 2009
Thank you for the tips. I have manage to run your script, but was still never get the way to include the color index beside the image which could explain the intensity of the color from the lower index(green) to the higher index(blue). This color index might be represented by an increasing of color index in another table beside the image, started from green followed by green-yellow, yellow, yellow-blue and blue?
Could someone please advice on this matter?
Cheers
Fir
----- Original Message ----
From: Bernardo Rangel Tura <tura at centroin.com.br>
To: FMH <kagba2006 at yahoo.com>
Sent: Monday, September 7, 2009 11:13:12 AM
Subject: Re: [R] Color index in image function
On Sat, 2009-09-05 at 04:14 -0700, FMH wrote:
> Dear All,
>
> I was looking for the color index in image function, such as from topo.colors(n) and etc. but still never found it. For instance, from the help menu.
>
>
> ###########################################
> # Volcano data visualized as matrix. Need to transpose and flip
> # matrix horizontally.
> image(t(volcano)[ncol(volcano):1,])
>
> # A prettier display of the volcano
> x <- 10*(1:nrow(volcano))
> y <- 10*(1:ncol(volcano))
> image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
> contour(x, y, volcano, levels = seq(90, 200, by = 5),
> add = TRUE, col = "peru")
> axis(1, at = seq(100, 800, by = 100))
> axis(2, at = seq(100, 600, by = 100))
> box()
> title(main = "Maunga Whau Volcano", font.main = 4)
> #########################################
>
> >From the script above, it yields a beautiful image of volcano with variety of colors but i have to list down the color index that could show the meaning of each color in my thesis.
>
> Could someone please help me to extract this color index?
>
> Thank you
> Fir
If I understand your question you need change the Palette of image plot.
So you need use "colorRampPalette" look my example
Brazilan.Pallete <- colorRampPalette(c("green","yellow", "blue"))
image(x, y, volcano, col = Brazilan.Pallete(50), axes = FALSE)
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil
More information about the R-help
mailing list