Si no te entiendo mal puedes usar la función colorPaletteRamp del siguiente
modo. repito el gráfico para que observes el cambio en los valores (si no
quieres usar blanco puedes interpolar a partir de otro color rosa hasta un
rojo más intenso)
image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat,
col = rev(colorRampPalette(c("white", "red"))( 2 )))
############################AQUI PARA CAMBIAR Y PONER TONOS ROJIZOS MAS
FUERTES xlab = "experience", ylab = "log(wage)")
box()
image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat,
col = rev(colorRampPalette(c("white", "red"))( 20 )))
############################AQUI PARA CAMBIAR Y PONER TONOS ROJIZOS MAS
FUERTES xlab = "experience", ylab = "log(wage)")
box()
image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat,
col = rev(colorRampPalette(c("white", "red"))( 120 )))
############################AQUI PARA CAMBIAR Y PONER TONOS ROJIZOS MAS
FUERTES xlab = "experience", ylab = "log(wage)")
box()
Espero te sirva,
Daniel Merino
El 22 de septiembre de 2013 14:17, Dr. José A. Betancourt B. <
jbetancourt@iscmc.cmw.sld.cu> escribió:
> Por favor ver comentario con las las letras mayúsculas****
>
> ** **
>
> ** **
>
> data("CPS1985", package = "AER")****
>
> cps <- CPS1985****
>
> ** **
>
> cps [1:10,]****
>
> dim( cps) ****
>
> ** **
>
> names( cps) ****
>
> ** **
>
> library("quantreg")****
>
> ** **
>
> ** **
>
> #regresion usual****
>
> cps_lm <- lm(log(wage) ~ experience + I(experience^2) +****
>
> + education, data = cps) ****
>
> ** **
>
> #regresion por quantiles, tau son los cuantiles seleccionados****
>
> cps_rq <- rq(log(wage) ~ experience + I(experience^2) +****
>
> + education, data = cps, tau = seq(0.2, 0.8, by = 0.15))
> ****
>
> ** **
>
> ** **
>
> #we compute predictions from both models for a new data set cps2, where
> education is held constant at its mean and experience varies over the range
> of the original variable:****
>
> ** **
>
> ** **
>
> cps2 <- data.frame(education = mean(cps$education),****
>
> experience = min(cps$experience):max(cps$experience))***
> *
>
> cps2 <- cbind(cps2, predict(cps_lm, newdata = cps2,****
>
> interval = "prediction"))****
>
> cps2 <- cbind(cps2,****
>
> predict(cps_rq, newdata = cps2, type = ""))****
>
> ** **
>
> ** **
>
> plot(log(wage) ~ experience, data = cps)****
>
> ** **
>
> plot(summary(cps_rq))****
>
> for(i in 6:10) lines(cps2[,i] ~ experience,****
>
> data = cps2, col = "red")****
>
> ** **
>
> ** **
>
> library("KernSmooth")****
>
> cps_bkde <- bkde2D(cbind(cps$experience, log(cps$wage)),****
>
> bandwidth = c(3.5, 0.5), gridsize = c(200, 200))****
>
> ** **
>
> ** **
>
> #con este plot de densidad se expresa mejor la idea a expresar****
>
> ** **
>
> image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat,****
>
> col = rev(gray.colors(10, gamma = 1)),
> ############################AQUI PARA CAMBIAR Y PONER TONOS ROJIZOS MAS
> FUERTES xlab = "experience", ylab =
"log(wage)")****
>
> box()****
>
> ** **
>
> ** **
>
> lines(fit ~ experience, data = cps2)****
>
> lines(lwr ~ experience, data = cps2, lty = 2)****
>
> lines(upr ~ experience, data = cps2, lty = 2)****
>
> ** **
>
> ** **
>
> ** **
>
> image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat,****
>
> col = rev(terrain.colors(10, alpha = 1)),****
>
> xlab = "experience", ylab = "log(wage)")****
>
> box()****
>
> ** **
>
> ** **
>
> lines(fit ~ experience, data = cps2)****
>
> lines(lwr ~ experience, data = cps2, lty = 2)****
>
> lines(upr ~ experience, data = cps2, lty = 2)****
>
> ** **
>
> ** **
>
> image(cps_bkde$x1, cps_bkde$x2, cps_bkde$fhat,****
>
> col = rev(heat.colors(10, alpha = 1)),****
>
> xlab = "experience", ylab = "log(wage)")****
>
> box()****
>
> ** **
>
> ** **
>
> lines(fit ~ experience, data = cps2)****
>
> lines(lwr ~ experience, data = cps2, lty = 2)****
>
> lines(upr ~ experience, data = cps2, lty = 2)****
>
> ** **
>
> ** **
>
> *De:* daniel [mailto:daniel319@gmail.com]
> *Enviado el:* Sunday, September 22, 2013 11:09 AM
> *Para:* pepeceb
> *CC:* jbetancourt@iscmc.cmw.sld.cu; r-help-es@r-project.org
> *Asunto:* Re: [R-es] colores****
>
> ** **
>
> Como usas la función image puedes consultar la ayuda ?image o help(image)
> y encontrarás el siguiente ejemplo donde se usa un diferente color Palette
> (mencionada por pepeceb en su respuesta). ****
>
> x <- 10*(1:nrow(volcano))****
>
> y <- 10*(1:ncol(volcano))****
>
> image(x, y, volcano, col = terrain.colors(100), axes = FALSE)****
>
> # O puedes usar directamente el número para indicar el color****
>
> image(x, y, volcano, col = seq(1:10), axes = FALSE)****
>
> # O puedes usar su nombre****
>
> colors()[1:5]****
>
> image(x, y, volcano, col = colors()[401:500], axes = FALSE)****
>
> ** **
>
> # Consulté el help de image porque no pusistes los datos para hacer
> fácilmente reproducible la pregunta.****
>
> # Si te ayuda, para agregar datos puedes usar la funcion ?dput o crear
> datos sin sentido de la forma****
>
> ** **
>
> mat <- matrix(rnorm(100), ncol=2, dimnames=list( NULL,
c('x','y')))****
>
> x <- 10*(1:nrow(mat))****
>
> y <- 10*(1:ncol(mat))****
>
> image(x, y, mat, col = rainbow(100), axes = FALSE)****
>
> ** **
>
> Espero te sirva,****
>
> ** **
>
> Daniel Merino****
>
> ** **
>
> 2013/9/22 pepeceb <pepeceb@yahoo.es>****
>
> Por ejemplo:<br/><br/>col=rainbow.colors(10)<br/>O
> también<br/><br/>col=topo.colors
(10)<br/><br/>O<br/><br/>col> terrain.colors
(10)<br/><br/
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es****
>
>
>
> ****
>
> ** **
>
> --
> Daniel ****
>
--
Daniel
[[alternative HTML version deleted]]