Hi, i created a graph with heatmap(sma) function: heatmap(dataHeat(x)) and I wish to change the gradation of colors from blue to red, how could i do? Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors without gradation. Ty so much Andrea
Le 03.10.2005 14:24, Andrea Zangrando a ??crit :>Hi, >i created a graph with heatmap(sma) function: > >heatmap(dataHeat(x)) > >and I wish to change the gradation of colors from blue to red, how could >i do? >Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors >without gradation. > >Ty so much >Andrea > >Hello, Check bluered() in the gplots package. Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~ Romain FRANCOIS - http://addictedtor.free.fr ~~~~~~ ~~~~ Etudiant ISUP - CS3 - Industrie et Services ~~~~ ~~ http://www.isup.cicrp.jussieu.fr/ ~~ ~~~~ Stagiaire INRIA Futurs - Equipe SELECT ~~~~ ~~~~~~ http://www.inria.fr/recherche/equipes/select.fr.html ~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
Andrea Zangrando a ??crit :> ... and I wish to change the gradation of colors > from blue to red, how could i do?Hello, here's how I build such a palette. a = 15; palwhiteblue = rgb(a:0, a:0, a, max=a); palredwhite = rgb(a, 0:a, 0:a, max=a); palwhite = rep(rgb(1,1,1), 8); palRWB = c(palredwhite, palwhite, palwhiteblue); of course, to adapt to your own uses. hih Vincent
On Mon, 3 Oct 2005, Romain Francois wrote:> Le 03.10.2005 14:24, Andrea Zangrando a ??crit : > > >Hi, > >i created a graph with heatmap(sma) function: > > > >heatmap(dataHeat(x)) > > > >and I wish to change the gradation of colors from blue to red, how could > >i do? > >Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors > >without gradation. > > > >Ty so much > >Andrea > > > > > Hello, > > Check bluered() in the gplots package.Or roll your own in base:> myBlRd <- colorRampPalette(c("blue", "red")) > myBlRdfunction (n) { x <- ramp(seq(0, 1, length = n)) rgb(x[, 1], x[, 2], x[, 3], max = 255) } <environment: 0x9a5792c>> myBlRd(15)[1] "#0000FF" "#1200EC" "#2400DA" "#3600C8" "#4800B6" "#5B00A3" "#6D0091" [8] "#7F007F" "#91006D" "#A3005B" "#B60048" "#C80036" "#DA0024" "#EC0012" [15] "#FF0000"> > Romain > >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
On Tue, 4 Oct 2005, Jim Lemon wrote:> Andrea Zangrando wrote: > > Hi, > > i created a graph with heatmap(sma) function: > > > > heatmap(dataHeat(x)) > > > > and I wish to change the gradation of colors from blue to red, how could > > i do? > > Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors > > without gradation. > > > The color.gradient function in the plotrix package returns a sequence of > interpolated colors between any two starting colors or incomplete > sequences of primaries. > > I noticed that a function named ramp (in the base package?) was > mentioned, but I could not find it. If there is a function equivalent to > color.gradient, I would like to know about it, as I try to avoid > duplicating functions.see ?colorRamp and look at:> colorRampPalettefunction (colors, ...) { ramp <- colorRamp(colors, ...) function(n) { x <- ramp(seq(0, 1, length = n)) rgb(x[, 1], x[, 2], x[, 3], max = 255) } } to see where it comes from. The colorRamp/colorRampPalette combination is quite remarkable and lots of fun ... Roger> > Jim > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
Andrea Zangrando wrote: > Hi, > i created a graph with heatmap(sma) function: > > heatmap(dataHeat(x)) > > and I wish to change the gradation of colors from blue to red, how could > i do? > Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors > without gradation. > The color.gradient function in the plotrix package returns a sequence of interpolated colors between any two starting colors or incomplete sequences of primaries. I noticed that a function named ramp (in the base package?) was mentioned, but I could not find it. If there is a function equivalent to color.gradient, I would like to know about it, as I try to avoid duplicating functions. Jim