用ggplot2,R在负y轴上绘制密度图 [英] Plotting density plots on the negative y axis with ggplot2, R

查看:127
本文介绍了用ggplot2,R在负y轴上绘制密度图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在x轴的两侧绘制密度-试图可视化映射到基因组区域的两条链的读段.

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.

我有两个问题:

  1. 我想使用ggplot2

我不知道如何从绘图对象中提取数据,或者反转已经制作的绘图.

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!

推荐答案

您的问题还不清楚,但是我发现"x轴两侧的密度"可能很有趣.因此,也许您正在尝试执行以下操作:

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

这篇关于用ggplot2,R在负y轴上绘制密度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆