[R] Color index in image function
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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Color index in image function
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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
Hi, On Sat, Sep 5, 2009 at 7:06 AM, 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. The answer is in the code: > ### > # 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) Right here: R> terrrain.colors(100) [1] "#00A600FF" "#03A700FF" "#07A800FF" "#0AAA00FF" "#0EAB00FF" ... Is that what you mean? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
Hi, Thank you for your response. I'm looking for the names of the colors denoted by these codes and what do these colors represent for. For instance, if we use topo.colors(5) in the image function, five different colors will be used in which its codes are denoted as: [1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" So, my first question is what type of color do these codes represent for? Are they white, red,...? My second question is, if we use this topo.colors(5) in image function to denote the temperature values for intance, what are these colors represent for? Does the first color, "#4C00" represent the lower/medium/higher temperature? I do hope you could advice me on this matter? Thank you Fir - Original Message From: FMH To: Steve Lianoglou Sent: Sunday, September 6, 2009 3:41:02 PM Subject: Re: [R] Color index in image function Hi, Thank you for your response. I'm looking for the name of the colors denoted by this code and what are these colors representing for. For instance, if we use topo.colors(5) in the image function, five different colors will be used in which its codes are denoted as: [1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" So, my first question is what type of color does these codes represent for? Are they white, red,...? My second question is, if we use this topo.colors(5) in image function to denote the temperature values for intance, what are these colors represent for? Does the first color, "#4C00" represent the lower/medium/higher temperature? I do hope you could advice me on this matter? Thank you Fir - Original Message ---- From: Steve Lianoglou To: FMH Cc: r-help@r-project.org Sent: Sunday, September 6, 2009 3:20:25 PM Subject: Re: [R] Color index in image function Hi, On Sat, Sep 5, 2009 at 7:06 AM, 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. The answer is in the code: > ### > # 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) Right here: R> terrrain.colors(100) [1] "#00A600FF" "#03A700FF" "#07A800FF" "#0AAA00FF" "#0EAB00FF" ... Is that what you mean? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
Try this to see which colors the codes are: Color <- function(color){ z <- matrix(1:length(color), ncol = length(color)) image(y = seq(1, length(color)), z, col = color, axes = FALSE) text(0, y = z, labels = color, pos = 1, offset = 0, cex = 0.7) } Color(topo.colors(5)) Color(terrain.colors(10)) You can use levelplot from lattice package too. On Sun, Sep 6, 2009 at 11:50 AM, FMH wrote: > Hi, > > Thank you for your response. I'm looking for the names of the > colors denoted by these codes and what do these colors represent for. > For instance, if we use topo.colors(5) in the image function, five > different colors will be used in which its codes are denoted as: > > [1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" > > So, my first question is what type of color do these codes represent > for? Are they white, red,...? > > My second question is, if we use this topo.colors(5) in image function to > denote the temperature values for intance, what are these colors represent > for? Does the first color, "#4C00" represent the lower/medium/higher > temperature? > > I do hope you could advice me on this matter? > > Thank you > Fir > > > > > - Original Message > From: FMH > To: Steve Lianoglou > Sent: Sunday, September 6, 2009 3:41:02 PM > Subject: Re: [R] Color index in image function > > Hi, > > Thank you for your response. I'm looking for the name of the colors denoted > by this code and what are these colors representing for. > > For instance, if we use topo.colors(5) in the image function, five > different colors will be used in which its codes are denoted as: > > [1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" > > So, my first question is what type of color does these codes represent > for? Are they white, red,...? > > My second question is, if we use this topo.colors(5) in image function to > denote the temperature values for intance, what are these colors represent > for? Does the first color, "#4C00" represent the lower/medium/higher > temperature? > > I do hope you could advice me on this matter? > > Thank you > Fir > > > > > > > > - Original Message > From: Steve Lianoglou > To: FMH > Cc: r-help@r-project.org > Sent: Sunday, September 6, 2009 3:20:25 PM > Subject: Re: [R] Color index in image function > > Hi, > > On Sat, Sep 5, 2009 at 7:06 AM, 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. > > The answer is in the code: > > > ### > > # 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) > > Right here: > > R> terrrain.colors(100) > > [1] "#00A600FF" "#03A700FF" "#07A800FF" "#0AAA00FF" "#0EAB00FF" ... > > Is that what you mean? > -steve > > -- > Steve Lianoglou > Graduate Student: Computational Systems Biology > | Memorial Sloan-Kettering Cancer Center > | Weill Medical College of Cornell University > Contact Info: > http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact> > > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
By default the z-values are split into equal ranges to match the number of colors. The first color is then for first interval from min(z) etc. Look at the code for image.default for clarity - there seems to be some influence from the "oldstyle" parameter. If you want to be 100% sure about which colors match which range, consider specifying the ranges in "breaks". Schalk Heunis On Sun, Sep 6, 2009 at 4:50 PM, FMH wrote: > Hi, > > Thank you for your response. I'm looking for the names of the colors denoted > by these codes and what do these colors represent for. > For instance, if we use topo.colors(5) in the image function, five different > colors will be used in which its codes are denoted as: > > [1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" > > So, my first question is what type of color do these codes represent for? Are > they white, red,...? > > My second question is, if we use this topo.colors(5) in image function to > denote the temperature values for intance, what are these colors represent > for? Does the first color, "#4C00" represent the lower/medium/higher > temperature? > > I do hope you could advice me on this matter? > > Thank you > Fir > > > > > - Original Message > From: FMH > To: Steve Lianoglou > Sent: Sunday, September 6, 2009 3:41:02 PM > Subject: Re: [R] Color index in image function > > Hi, > > Thank you for your response. I'm looking for the name of the colors denoted > by this code and what are these colors representing for. > > For instance, if we use topo.colors(5) in the image function, five different > colors will be used in which its codes are denoted as: > > [1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" > > So, my first question is what type of color does these codes represent > for? Are they white, red,...? > > My second question is, if we use this topo.colors(5) in image function to > denote the temperature values for intance, what are these colors represent > for? Does the first color, "#4C00" represent the lower/medium/higher > temperature? > > I do hope you could advice me on this matter? > > Thank you > Fir > > > > > > > > - Original Message > From: Steve Lianoglou > To: FMH > Cc: r-help@r-project.org > Sent: Sunday, September 6, 2009 3:20:25 PM > Subject: Re: [R] Color index in image function > > Hi, > > On Sat, Sep 5, 2009 at 7:06 AM, 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. > > The answer is in the code: > >> ### >> # 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) > > Right here: > > R> terrrain.colors(100) > > [1] "#00A600FF" "#03A700FF" "#07A800FF" "#0AAA00FF" "#0EAB00FF" ... > > Is that what you mean? > -steve > > -- > Steve Lianoglou > Graduate Student: Computational Systems Biology > | Memorial Sloan-Kettering Cancer Center > | Weill Medical College of Cornell University > Contact Info: http://cbio.mskcc.org/~lianos/contact > > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
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 To: FMH 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
On Wed, 2009-09-09 at 02:33 -0700, FMH wrote: > Thank you for the hints, but how could i add the grid lines which have > numbers, representing the height of the volcano on the image. > > Thank you > So I think this script is what you need Brazilan.Pallete <- colorRampPalette(c("green","yellow", "blue")) require(fileds) image.plot(volcano, col = Brazilan.Pallete(50), axes = FALSE) contour(volcano, levels = seq(90, 200, by = 5), add = TRUE) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil > > > - Original Message > From: Bernardo Rangel Tura > To: FMH > Sent: Tuesday, September 8, 2009 10:14:07 AM > Subject: Re: [R] Color index in image function > > On Mon, 2009-09-07 at 07:59 -0700, FMH wrote: > > 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 > > > > Hi FHM, > > Well If you desire one color index in a imageplot I don't know solve > your problem. > > But in your scirptyou use image and > > image(x, y, volcano, col = terrain.colors(100), axes = FALSE) > contour(x, y, volcano, levels = seq(90, 200, by = 5), > add = TRUE, col = "peru") > > In this case I suggest you use > > Brazilan.Pallete <- colorRampPalette(c("green","yellow", "blue")) > filled.contour(volcano, color = Brazilan.Pallete) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
On Thu, 2009-09-10 at 05:27 -0700, FMH wrote: > Thank you for the scripts, but the label and the values in the x and y-axis > suddently dissapear even the 'axis' function is used as stated in the command > below. Could you help on this? > > axis(1, at = seq(100, 800, by = 100)) > axis(2, at = seq(100, 600, by = 100)) > > How could i add a tittle on top of color index? > > Thank you > Fir Try this Brazilan.Pallete <- colorRampPalette(c("green","yellow", "blue")) require(fields) image.plot(volcano, col = Brazilan.Pallete(50), legend.lab="Scale") contour(volcano, levels = seq(90, 200, by = 5), add = TRUE) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
Thank you From: Henrique Dallazuanna Cc: r-help@r-project.org Sent: Sunday, September 6, 2009 4:30:14 PM Subject: Re: [R] Color index in image function Try this to see which colors the codes are: Color <- function(color){ z <- matrix(1:length(color), ncol = length(color)) image(y = seq(1, length(color)), z, col = color, axes = FALSE) text(0, y = z, labels = color, pos = 1, offset = 0, cex = 0.7) } Color(topo.colors(5)) Color(terrain.colors(10)) You can use levelplot from lattice package too. Hi, > >Thank you for your response. I'm looking for the names of the colors denoted >by these codes and what do these colors represent for. >For instance, if we use topo.colors(5) in the image function, five different >colors will be used in which its codes are denoted as: > >[1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" > >So, my first question is what type of color do these codes represent for? Are >they white, red,...? > >My second question is, if we use this topo.colors(5) in image function to >denote the temperature values for intance, what are these colors represent >for? Does the first color, "#4C00" represent the lower/medium/higher >temperature? > >I do hope you could advice me on this matter? > >Thank you >Fir > > > > >- Original Message >To: Steve Lianoglou >Sent: Sunday, September 6, 2009 3:41:02 PM >Subject: Re: [R] Color index in image function > >Hi, > >Thank you for your response. I'm looking for the name of the colors denoted by >this code and what are these colors representing for. > >For instance, if we use topo.colors(5) in the image function, five different >colors will be used in which its codes are denoted as: > >[1] "#4C00" "#004C" "#00E5" "#00FF4DFF" "#00FF" > >So, my first question is what type of color does these codes represent >for? Are they white, red,...? > >My second question is, if we use this topo.colors(5) in image function to >denote the temperature values for intance, what are these colors represent >for? Does the first color, "#4C00" represent the lower/medium/higher >temperature? > >I do hope you could advice me on this matter? > >Thank you >Fir > > > > > > > > >- Original Message >From: Steve Lianoglou >Cc: r-help@r-project.org >Sent: Sunday, September 6, 2009 3:20:25 PM >Subject: Re: [R] Color index in image function > >Hi, > >> 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. > >The answer is in the code: > >> ### >> # 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) > >Right here: > >R> terrrain.colors(100) > >[1] "#00A600FF" "#03A700FF" "#07A800FF" "#0AAA00FF" "#0EAB00FF" ... > >Is that what you mean? >-steve > >-- >Steve Lianoglou >Graduate Student: Computational Systems Biology >| Memorial Sloan-Kettering Cancer Center >| Weill Medical College of Cornell University >Contact Info: http://cbio.mskcc.org/%7Elianos/contact > > > > >__ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.