Colored contour plot / heat map

Example: Bivariate normal density (mean=(0,0), var-cov=diag(1,1))

<pre class="src src-R"><span style="color: #ff4500;">##</span><span style="color: #ff4500;">R's heatmap function is NOT what i want </span>

##I want a simple colored contour plot / heat map library(mvtnorm) ##get multivariate normal functions x <- seq(-2,2,.01) X <- cbind(rep(x,each=length(x)), rep(x, length(x))) z <- matrix(dmvnorm(X), nrow=length(x)) filled.contour(x=x,y=x,z=z, nlevels=100) ##take in vector x and y with matrix z of values

##See ?palettes for different color scheme filled.contour(x=x,y=x,z=z, nlevels=100, color.palette=topo.colors) filled.contour(x=x,y=x,z=z, nlevels=100, color.palette=heat.colors) filled.contour(x=x,y=x,z=z, nlevels=100, color.palette=rainbow) filled.contour(x=x,y=x,z=z, nlevels=100, color.palette=terrain.colors) filled.contour(x=x,y=x,z=z, nlevels=100, color.palette=cm.colors) ##default

jpeg(“ColoredContourHeatMap-MVN.jpeg”) filled.contour(x=x,y=x,z=z, nlevels=100, color.palette=terrain.colors) dev.off()

http://blog.nguyenvq.com/wp-content/uploads/2009/05/ColoredContourHeatMap-MVN.jpeg

About Vinh Nguyen

Statistician

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>