Plotting density plots on the negative y axis with

2019-09-04 04:10发布

I'm trying to plot densities on both sides of the x axis - trying to visualize reads mapping to both strands of a genomic region.

I have two problems :

  1. I want to use ggplot2 but

  2. I don't know how to extract the data from the plot object, or invert the plot that has already been made.

Any help greatly appreciated!

标签: r plot ggplot2
1条回答
Anthone
2楼-- · 2019-09-04 04:42

Your question is very unclear, but I found the "densities on both sides of the x axis" potentially interesting. So maybe you're trying to do something like this:

d <- data.frame(x = rnorm(1000),x1 = rnorm(1000,sd = 0.5))

ggplot(data = d,aes(x = x)) + 
    geom_density() + 
    geom_density(aes(x = x1,y = -(..density..)))

enter image description here

查看更多
登录 后发表回答