使用smoothScatter生成的颜色密度散点图的R图例
我正在使用使用smoothScatter生成的颜色密度散点图的R图例,r,R,我正在使用smoothScatter()函数在R中生成颜色密度散点图 例如: ## A largish data set n <- 10000 x1 <- matrix(rnorm(n), ncol = 2) x2 <- matrix(rnorm(n, mean = 3, sd = 1.5), ncol = 2) x <- rbind(x1, x2) oldpar <- par(mfrow = c(2, 2)) smoothScatter(x, nrpoin
smoothScatter()
函数在R中生成颜色密度散点图
例如:
## A largish data set
n <- 10000
x1 <- matrix(rnorm(n), ncol = 2)
x2 <- matrix(rnorm(n, mean = 3, sd = 1.5), ncol = 2)
x <- rbind(x1, x2)
oldpar <- par(mfrow = c(2, 2))
smoothScatter(x, nrpoints = 0)
##一个更大的数据集
n这里的答案依赖于字段::imageplot
和一些摆弄par(mar)
来获得正确的边距
fudgeit <- function(){
xm <- get('xm', envir = parent.frame(1))
ym <- get('ym', envir = parent.frame(1))
z <- get('dens', envir = parent.frame(1))
colramp <- get('colramp', parent.frame(1))
fields::image.plot(xm,ym,z, col = colramp(256), legend.only = T, add =F)
}
par(mar = c(5,4,4,5) + .1)
smoothScatter(x, nrpoints = 0, postPlotHook = fudgeit)
fudgeit这里有一个答案,它依赖于fields::imageplot
和一些摆弄par(mar)
来获得正确的边距
fudgeit <- function(){
xm <- get('xm', envir = parent.frame(1))
ym <- get('ym', envir = parent.frame(1))
z <- get('dens', envir = parent.frame(1))
colramp <- get('colramp', parent.frame(1))
fields::image.plot(xm,ym,z, col = colramp(256), legend.only = T, add =F)
}
par(mar = c(5,4,4,5) + .1)
smoothScatter(x, nrpoints = 0, postPlotHook = fudgeit)
fudgeit-See@mnel如果需要,我可能会采用这些方法中的一种,尽管理想情况下,我正在寻找一种使用smoothScatter()
的方法。您的解决方案(可能)包括使用postPlotHook
参数。您可以查看fields::image.plot
函数,了解它们是如何创建图例的。我不明白。问题@mnel linked to涉及smoothscatter
。@Dwin mnel linked to的注释并不涉及。请参阅@mnel,如果需要,我可能会采用这些方法之一,尽管理想情况下,我正在寻找一种使用smoothscatter()
的方法。您的解决方案(可能)将涉及使用postlothook
参数。您可以查看fields::image.plot
函数,了解它们是如何创建图例的。我不明白。问题@mnel linked to涉及到smoothscatter
@Dwin,但是mnel linked to的注释没有。问题:条形图中的0.5表示什么?好的。现在,我知道这个值是fudgeit函数中“z”的个数。但z表示什么,我支持这个问题。刻度上的数字是什么意思?在y刻度上做一些挖掘:这是函数中的dens
值,它被指定为fhat
项,“由x1和x2诱导的网格上的密度估计矩阵”。问题:条形刻度中的0.5表示什么?好的。现在,我知道这个值是fudgeit函数中“z”的个数。但z表示什么,我支持这个问题。刻度上的数字是什么意思?在y刻度上做一些挖掘:它是函数中的dens
值,被指定为fhat
项,“由x1和x2诱导的网格上的密度估计矩阵”。