Question: Plotting A Highly Correlated Graph
0
7.1 years ago by
k.nirmalraman1.0k
Germany
k.nirmalraman1.0k wrote:

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)
``````

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 • 3.2k views
modified 7.1 years ago by Alex Reynolds30k • written 7.1 years ago by k.nirmalraman1.0k

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

2
7.1 years ago by
Netherlands
Sukhdeep Singh10k wrote:

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

0
7.1 years ago by
David730
David730 wrote:

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.

0
7.1 years ago by
Alex Reynolds30k
Seattle, WA USA
Alex Reynolds30k wrote:

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.