This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to create multiple density plots in one

Hello everyone

I have a table of two columns

Category size mRNA 2000 mRNA 2300 mRNA 15000 siRNA 40 tRNA 120 siRNA 78 siRNA 38 mRNA 800

And I need to make a sensity plot (like here http://www.statmethods.net/graphs/images/density3.png) so that put the size in x and the desnity in Y

Is there a way to do this?

Ps: I used ggplot but I can not color that lines and leave the fill empty

Thank you in advance.

r

btw the link is not opening any image.

if you are using ggplot2

library(ggplot2)
x <- data.frame(v1=rnorm(100),v2=rnorm(100,1,1),v3=rnorm(100,0,2))
library(ggplot2)
library(reshape2)
data<- melt(x)
ggplot(data,aes(x=value, fill=variable)) + geom_density(alpha=0.25)

If you are using just R base

plot (density(x$v1))
lines (density(x$v2))
lines (density(x$v3))

use the paramters for color and fill. if you want to fill.

Just to clarify it is not a bioinformatics question , probably an R plot or stackoverflow.

Terrific answer. The reshape2 package is the key. Thank you!

Indeed it is but sadly the OP did not acknowledge or upvote it. ;)

0 answers

No answers yet.

Log in to answer this question.