# Heat Maps

5 messages
Open this post in threaded view
|

## Heat Maps

 Hello Everyone I am new to R I have drawn indifference curves using the program below (Contour Plot) u <- function(x, y) x^0.5 + y^0.5 x <- seq(0, 1000, by=1) y <- seq(0, 1000, by=1) a <- c(10, 20, 30) contour(x, y, outer(x, y, u),levels=a,col="blue") Now can any body please tell me how to draw Heat maps and that too on the same indifference curve plot (contour)         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Heat Maps

 the "image" function should do it, something like this: image( x, y, outer(x,y,u), col=[some vector of colors] ) You can add a "breaks" parameter but you need one more break than you have colors (include the start and end point).  Or just let it be automatic.I have used colorpanel() from the gplots library to generate graduated color shades.  This is based on actual code I'm using for one of my heatmaps: library(gplots) # for colorpanelz <- outer(x,y,u)image( x, y, z, colorpanel(10,"steelblue","white"), breaks=quantile(z,seq(0,1,by=0.1))  )box() # for appearancespar(new=TRUE)  # you want the lines on top of the colors, so do the contour plot secondcontour(...) It will produce ten colors with steelblue for the highest value and white for the lowest value, and one shade for each decile.  You can omit the "breaks" term.  > I have drawn indifference curves using the program below (Contour Plot) > > > u <- function(x, y) x^0.5 + y^0.5 > x <- seq(0, 1000, by=1) > y <- seq(0, 1000, by=1) > a <- c(10, 20, 30) > contour(x, y, outer(x, y, u),levels=a,col="blue") > > > > > Now can any body please tell me how to draw Heat maps > > and that too on the same indifference curve plot (contour) >                 [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Heat Maps

 Thanks Joseph but see i am not able to get heat maps with this code \ can u please give me the full codes to generate heat map on the same graph where i have drawn contour lines         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.