Plotting A Highly Correlated Graph
3
0
Entering edit mode
11.0 years ago
k.nirmalraman ★ 1.1k

Dear All,

I am trying the plot a correlation heat matrix to show that the sample preparation method does not have a bias based on some measurements. The correlation is very high among all the samples. Therefore, in order to pick the best correlation visually, I would like to do a heatmap. As the samples are highly correlated (all values above 0.94), I am not able to show the differences in the heatmap.

corr =    1.00    0.99    0.94
          0.99    1.00    0.97
          0.94    0.97    1.00

I am using corrplot

library(corrplot)
corrplot(as.matrix(corr),method="shade",is.corr=T,col=colorRampPalette(brewer.pal(9,"Blues"))(100))

Correlation Plot

I would like to see that 0.99 is different from 0.94 in the graph. Also I think would be great to have the color scale only for positive correlation (0 to 1). Any help would be highly appreciated in deciding a color palette or with alternate methods for this purpose. Thanks!

r correlation plot • 4.3k views
ADD COMMENT
0
Entering edit mode

You might be interested in a correlogram, such as those offered by the corrgram R package

ADD REPLY
2
Entering edit mode
11.0 years ago

You can play with the range in this case

# generate data frame
df=data.frame(a=c(1,0.99,0.94),b=c(0.99,1,0.97),c=c(0.94,0.97,1))

# melt and rescale it
library('reshape')
library('plotrix')

df.m=ddply(melt(df),.(variable),transform,rescale=rescale(value,c(0,0.3))) # play with the rang e inside value here to get the desired range

# plot it using ggplot [you can do this part yourself], see geom_tile

or cast it back cast

Also, see tweaking-scale-heatmap-with-ggplot2

Cheers

ADD COMMENT
0
Entering edit mode
11.0 years ago
David ▴ 740

Sometime heatmap are not the solution. I would do a pairs graph.

Look in the help page ?pairs and you will see how to do something more fancy than the vanilla version. You will have to give the real data not the correlation. Correlation will be computed on the fly.

ADD COMMENT
0
Entering edit mode
11.0 years ago

I asked this Stack Overflow question about using the lattice library's levelplot() function with custom ranges. The answer I came up with (along with another person's answer) worked reasonably well enough that I had a figure I could edit with Adobe Illustrator.

ADD COMMENT

Login before adding your answer.

Traffic: 1345 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6