使用对数分箱的散点图要在 R 中安装什么包? [英] What package is to be installed in R for scatter plots with logarithmic binning?
本文介绍了使用对数分箱的散点图要在 R 中安装什么包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试用 R 生成一些高密度散点图.为此应该安装什么包?或者有什么其他的方法可以得到这些图.
I am trying to produce some high density scatter plots with R. What package should be installed for this? Or is there any other way to obtain the plots.
推荐答案
如果您确实想要一个对数缩放散点图,那么这就是在 3 个绘图系统中的每一个中创建它们的方法.
If you really do want a log scaled scatterplot, then this is how to create them in each of the 3 plotting systems.
首先,一些数据:
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 图形中(需要安装该软件包 + 依赖项):
In ggplot2 graphics (will need to install that package + dependencies):
library(ggplot2)
p2 <- ggplot(dfr, aes(x, y)) +
geom_point() +
scale_x_log10() +
scale_y_log10()
p2
这篇关于使用对数分箱的散点图要在 R 中安装什么包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文