[R] yaxis of density plot as counts/bandwidth
Ido M. Tamir
tamir at imp.univie.ac.at
Mon Nov 20 09:25:48 CET 2006
Dear all,
I would like to change the scale of a density plot
to something that represents counts/bandwidth.
What I am actually plotting is density of genomic
data along the chromosome, and I need a simple
representation of e.g. genes/50000 bases.
pos <- c(123423,124313,124790,,....)
den <- density(pos,bw=50000)
plot(den, yaxt="n", ylab="features/50kb")
etc...
Is the following correct?
library("MASS")
par(mfrow=c(2,2))
hist(geyser$duration)
den <- density(geyser$duration)
plot(den)
hist(geyser$duration,breaks=20)
plot(den,yaxt="n", ylab="")
fm <- den$bw * max(den$y) * den$n
at <- pretty(c(0,max(den$y)), n=5)
lab <- pretty(c(0,fm), n=5)
axis(2,at=at[1:6],lab=lab[1:6])
thank you very much
ido
More information about the R-help
mailing list