1

我正在尝试使用 R 生成一些高密度散点图。应该为此安装什么软件包?或者有没有其他方法来获得地块。

4

3 回答 3

2

如果你真的想要一个对数比例的散点图,那么这就是如何在 3 个绘图系统中的每一个中创建它们。

首先,一些数据:

dfr <- data.frame(x = rlnorm(1e5), y = rlnorm(1e5))

在基础图形中:

with(dfr, plot(x, y, log = "xy"))

在点阵图形中:

library(lattice)
p1 <- xyplot(y ~ x, dfr, scales = list(log = TRUE))
p1

在 ggplot2 图形中(需要安装该包 + 依赖项):

library(ggplot2)
p2 <- ggplot(dfr, aes(x, y)) + 
  geom_point() + 
  scale_x_log10() + 
  scale_y_log10()
p2
于 2011-07-06T15:29:36.440 回答
1

I've just been struggling with trying to plot these recently; and just ended up using the standard hist() function with a custom set of breaks:

x <- your data
nbreaks <- 50 # how many points do you want in your scatter plot
breaks <- exp(seq(log(min(x)), log(max(x)), len=nbreaks))
hh <- hist(x, breaks, plot=FALSE)
plot(hh$mids, hh$density, log="xy")

I.e. create an exponentially distributed set of breaks and generate the histogram, but manually plot the densities giving control over which axes are logged.

于 2012-04-26T09:45:11.890 回答
0

格图2?- 查看geom_point(使用 alpha)或geom_hex的示例

于 2011-07-06T15:10:29.543 回答