plot with 3 axes and different shades
On 02/13/2014 02:49 AM, Wei Ding wrote:
Hello, everyone, I have following csv-file(simplified) as instance:
Greetings,
I have following csv-file:
0.29,2,50
0.32,3,10
0.28,4,71
0.27,1,62
0.53,1,33
0.83,5,100
with the first column for x-axis (proportion shared), the second for y-axis
(number of shared segments), the shades for 'number of pairs'.
In the attachment, you can find the figure.
I wonder how to realize that the "number of pairs" are denoted by different
shades as shown in the attachment ? So far, I can plot a histogram by these
codes, but have no idea how to correctly add information of shades to it.
df<-read.csv(file="c-all-prop-test.csv",head=F,sep=",")
require(ggplot2)
qplot(x=df[,1],weight=df[,2],geom="histogram",xlab="proportion
shared",ylab="number of shared segments",colour = I("darkgreen"), fill =
I("blue"))
It seems that d + stat_bin2d() may help. Or maybe heatmap?
Could you give me some suggestions? Best regards
Hi Wei,
You can do something like this with color2D.matplot (plotrix).
x<-matrix(sample(1:100,100),nrow=10)
x[sample(1:10,20,TRUE),sample(1:10,20,TRUE)]<-NA
library(plotrix)
color2D.matplot(x,
cellcolors=color.scale(x,extremes=c("lightgray","blue")))
Jim