r - R ggplot2 hexbin 绘图图形错误?
问题描述
我总是在我在 R 环境中使用 ggplot2 创建的每个 hexbin 密度图上发现一些奇怪的白色水平虚线,它们似乎出现在垂直相邻六边形之间的边界上。他们当然不属于那里...这种行为(错误)可以在具有不同 MS Windows 版本和不同图形驱动程序的不同计算机上的多个 R 安装上重现。我不知道如何摆脱这些虚线。下面是一个显示问题的图,以及产生该图的代码。这是一个已知问题吗?有什么提示可以克服这个吗?非常感谢您的帮助!
## Load libraries
library(ggplot2)
library(hexbin)
## Create some data
set.seed(222)
myx <- data.frame(x = 0.4 + rnorm(10000, mean = 0, sd = 0.1))
myy <- data.frame(y = 0.5 + rnorm(10000, mean = 0, sd = 0.1))
MyData <- data.frame(xvariable=myx$x*100, yvariable=myy$y*100)
## Prepare the plot window
dev.off(2)
windows.options(width=6, height=6)
op <- par(mfrow = c(1,1))
op <- par(oma = c(0,0,0,0) + 0.1,
mar = c(5.1, 5.1, 4.1, 2.1))
## Creaate the plot
ggplot(MyData, aes(x=xvariable, y=yvariable) ) +
geom_hex(bins=66) +
xlim(0, 100) +
ylim(0, 100) +
ggtitle("My plot") +
scale_fill_continuous(type = "viridis") +
theme_bw() +
theme(plot.title = element_text(color="black", size=17, face="bold"),
axis.title.x = element_text(color="black", size=17, face="bold"),
axis.title.y = element_text(color="black", size=17, face="bold"),
axis.text=element_text(color="black", size=15, face="bold"),
legend.title = element_text(color = "black", size = 15),
legend.text = element_text(color = "black", size=12),
legend.position = c(0.9,0.2), legend.direction = "vertical")
解决方案
推荐阅读
- python - PYTHON:xPath 不会定位和输入字段。使用 selenium、Webdriver 等
- jquery - 如何让 jquery 脚本在下拉菜单事件中触发?
- android - 吸引项目 RecyclerView 的粘性项目装饰
- javascript - 为什么这个简单的 JavaScript 程序只获取 1 个结果而不是我请求的指定 25?
- ruby-on-rails - raise ActiveRecord::Rollback in after_save 不会回滚保存
- php - 如何从 Laravel 中的数组中获取值
- azure - 使用 Rest-API 在 ADLS Gen2 中更新文件的问题
- javascript - 获取画布中的行和列
- php - 使用 Twilio 发送 SMS 后获取 SMS 的费用
- r - 将 .dat 文件读入 R