【发布时间】:2016-10-22 17:03:49
【问题描述】:
我想知道是否有一种方法可以在 R 中将两个分箱散点图相减。我有两个具有相同轴的分布,想将一个叠加在另一个上并减去它们,从而产生差异散点图.
这是我的两个情节:
还有我的剧情脚本:
library(hexbin)
library(RColorBrewer)
setwd("/Users/home/")
df <- read.table("data1.txt")
x <-df$c2
y <-df$c3
bin <-hexbin(x,y,xbins=2000)
my_colors=colorRampPalette(rev(brewer.pal(11,'Spectral')))
d <- plot(bin, main="" , colramp=my_colors, legend=F)
任何有关如何解决此问题的建议都会非常有帮助。
编辑 找到了另一种方法:
xbnds <- range(x1,x2)
ybnds <- range(y1,y2)
bin1 <- hexbin(x1,y1,xbins= 200, xbnds=xbnds,ybnds=ybnds)
bin2 <- hexbin(x2,y2,xbins= 200, xbnds=xbnds,ybnds=ybnds)
erodebin1 <- erode.hexbin(smooth.hexbin(bin1))
erodebin2 <- erode.hexbin(smooth.hexbin(bin2))
hdiffplot(erodebin1, erodebin2)
【问题讨论】:
-
您只创建了一个情节。阅读构建模拟数据的示例并将代码添加到您的问题主体中,以生成两个与您正在使用的数据集相似的数据集。