r - 如何在R中制作和填充矩形?
解决方案
这是一个基本的 R 解决方案
rand_rgb <- function(n) rgb(runif(n), runif(n), runif(n))
w <- 10; h <- 8
# We can get a rectangular plot by simply resizing the canvas
png("test.png", width = 600, height = 200)
# set plot margins
par(mar = c(1, 1, 1, 1))
image(
1:w, 1:h, matrix(runif(h * w), w, h), col = rand_rgb(h * w),
xlab = "", ylab = "", axes = FALSE
)
grid(w, h, lty = 1, col = "black")
box()
dev.off()
然后,您将看到一个名为“test.png”的图像出现在您的工作目录中。看起来像这样
推荐阅读
- c# - JsonConvert.DeserializeObject 数组
- .net - 在 AWS X-RAY SDK .NET 中动态创建分段
- enums - 如果我们遵循枚举本地化约定,ABP 可以在哪些情况下自动本地化枚举
- spring-boot - 无法显示会话的自定义消息[SPRING_SECURITY_LAST_EXCEPTION]
- python - 当多个用户连接到应用程序时,Web 服务非常慢
- php - Laravel 错误:在 Excel 导入中从空值创建默认对象
- virtuoso - Virtuoso 安装在第二次尝试时卡在“VAD Sticker vad_dav.xml 创建”上
- wso2esb - 是否可以为 WSO2 ESB 中的排队请求设置最长生命周期?
- java - 在 apache ant 构建中替代 untar?
- amazon-web-services - AWS SES 批量发送问题