【发布时间】:2023-03-15 22:19:01
【问题描述】:
伙计们,
我正在尝试使用 ggplot 在 R 中重现 A. Michael Noll 的著名计算机艺术作品“带有线条的计算机组合”。
我做到了可以创建一个随机的黑色或白色像素圆圈,但我很难创建类似于 Noll 使用的图案。
我可以轻松地创建一个由 1 和 0 组成的矩阵,然后切掉圆外的部分。但是模式(我试过uniform、beta、normal...)肯定和白噪声太相似了,而原作的随机性是有结构的。
library(tidyverse)
# this generates the matrix
genData <- function(N) {
# a N*N matrix of ones and zero according to a rounded beta draw
df <- tibble(x = rep(seq(1,N), N),
y = rep(seq(1,N), each = N),
z = round(rbeta(N*N, 2, 1)))
# centering on zero and cutting away all points outside of a circle
df %>%
mutate(x = x-(N/2 + 1), y = y-(N/2 + 1)) %>%
filter(x^2 + y^2 < (N/2)^2)
}
#this plots the data
plotData <- function(df, color = "black"){
df %>%
ggplot(aes(x,y, fill = as.factor(z)))+
geom_tile()+
scale_fill_manual(values = c(color, "white"))+
coord_equal()+
theme_void()+
theme(legend.position = "none")
}
#executing
genData(100) %>%
plotData()
结果:
我想问题归结为我可以在这里使用哪个随机过程?我没有在网上找到任何线索。
【问题讨论】: