Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # --- [2025-03-19 18:25:49] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(42)
- # Generate data for 5000 points
- n <- 5000
- celestial_data <- data.frame(
- x = rnorm(n),
- y = rnorm(n)
- )
- # Add some flowing patterns
- celestial_data <- celestial_data %>%
- dplyr::mutate(
- size = abs(x*y)/5,
- alpha = 1/(1 + exp(-abs(x*y))),
- group = sample(1:20, n, replace = TRUE)
- )
- # Create the plot
- ggplot(celestial_data, aes(x, y, color = size, alpha = alpha, size = size)) +
- geom_point() +
- scale_color_gradient(low = "#3A1C71", high = "#FFAF7B") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "black"),
- plot.background = element_rect(fill = "black")
- ) +
- labs(title = "Celestial Drift")
- # --- [2025-03-19 18:25:59] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(42)
- # Generate data for 2000 points
- n <- 2000
- celestial_data <- data.frame(
- x = rnorm(n),
- y = rnorm(n)
- )
- # Add some flowing patterns
- celestial_data <- celestial_data %>%
- dplyr::mutate(
- size = abs(x*y)/5,
- alpha = 1/(1 + exp(-abs(x*y))),
- group = sample(1:20, n, replace = TRUE)
- )
- # Create the plot
- ggplot(celestial_data, aes(x, y, color = size, alpha = alpha, size = size)) +
- geom_point() +
- scale_color_gradient(low = "#3A1C71", high = "#FFAF7B") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "black"),
- plot.background = element_rect(fill = "black")
- ) +
- coord_fixed() +
- labs(title = "Celestial Drift")
- # --- [2025-03-19 18:26:11] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(42)
- # Generate data for 800 points
- n <- 800
- df <- data.frame(
- x = rnorm(n),
- y = rnorm(n)
- )
- # Add some flowing patterns
- df <- df %>%
- dplyr::mutate(
- size = abs(x*y)/5 + 0.5,
- group = sample(1:10, n, replace = TRUE)
- )
- # Create the plot
- p <- ggplot(df, aes(x, y, color = size, size = size)) +
- geom_point(alpha = 0.7) +
- scale_color_gradient(low = "#3A1C71", high = "#FFAF7B") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "black"),
- plot.background = element_rect(fill = "black")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:26:25] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(123)
- # Generate spiral data
- t <- seq(0, 15, length.out = 2000)
- spiral_data <- data.frame(
- x = t * cos(t),
- y = t * sin(t)
- )
- # Add noise and styling
- spiral_data <- spiral_data %>%
- dplyr::mutate(
- x = x + rnorm(length(x), 0, 0.3 * t),
- y = y + rnorm(length(y), 0, 0.3 * t),
- color_group = t,
- size = 0.8 + rnorm(length(t), 0, 0.2)
- )
- # Create the plot
- ggplot(spiral_data, aes(x, y, color = color_group, size = size)) +
- geom_point(alpha = 0.7) +
- scale_color_gradient2(
- low = "#3A1C71",
- mid = "#D76D77",
- high = "#FFAF7B",
- midpoint = median(spiral_data$color_group)
- ) +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "black"),
- plot.background = element_rect(fill = "black")
- ) +
- coord_fixed(ratio = 1) +
- labs(title = "Celestial Drift - Improved")
- # --- [2025-03-19 18:26:36] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(123)
- # Generate spiral data
- t <- seq(0, 15, length.out = 500)
- spiral_data <- data.frame(
- x = t * cos(t),
- y = t * sin(t)
- )
- # Add noise and styling
- spiral_data <- spiral_data %>%
- dplyr::mutate(
- x = x + rnorm(length(x), 0, 0.3 * t),
- y = y + rnorm(length(y), 0, 0.3 * t),
- color_group = t,
- size = 0.8 + rnorm(length(t), 0, 0.2)
- )
- # Create the plot
- p <- ggplot(spiral_data, aes(x, y, color = color_group, size = size)) +
- geom_point(alpha = 0.7) +
- scale_color_gradient2(
- low = "#3A1C71",
- mid = "#D76D77",
- high = "#FFAF7B",
- midpoint = median(spiral_data$color_group)
- ) +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "black"),
- plot.background = element_rect(fill = "black")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:26:51] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(42)
- # Create triangular grid
- n_triangles <- 200
- triangles <- data.frame()
- for(i in 1:n_triangles) {
- # Create random triangle
- x_center <- runif(1, -10, 10)
- y_center <- runif(1, -10, 10)
- size <- runif(1, 0.5, 2)
- angle <- runif(1, 0, 2*pi)
- # Triangle vertices
- x1 <- x_center + size * cos(angle)
- y1 <- y_center + size * sin(angle)
- x2 <- x_center + size * cos(angle + 2*pi/3)
- y2 <- y_center + size * sin(angle + 2*pi/3)
- x3 <- x_center + size * cos(angle + 4*pi/3)
- y3 <- y_center + size * sin(angle + 4*pi/3)
- # Add triangle to dataframe
- triangle_df <- data.frame(
- id = i,
- x = c(x1, x2, x3),
- y = c(y1, y2, y3),
- group = i,
- size = size
- )
- triangles <- rbind(triangles, triangle_df)
- }
- # Create plot
- p <- ggplot(triangles, aes(x, y, group = group, fill = size)) +
- geom_polygon(color = "white", alpha = 0.6, size = 0.2) +
- scale_fill_viridis_c(option = "D") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#f0f0f0"),
- plot.background = element_rect(fill = "#f0f0f0")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:27:08] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(123)
- # Create a grid of points
- n <- 15
- x <- seq(-10, 10, length.out = n)
- y <- seq(-10, 10, length.out = n)
- grid <- expand.grid(x = x, y = y)
- # Add some noise to the grid
- grid <- grid %>%
- dplyr::mutate(
- x = x + rnorm(n^2, 0, 0.5),
- y = y + rnorm(n^2, 0, 0.5)
- )
- # Calculate distances between points
- connections <- data.frame()
- threshold <- 3 # Only connect points that are close enough
- for(i in 1:(nrow(grid)-1)) {
- for(j in (i+1):nrow(grid)) {
- dist <- sqrt((grid$x[i] - grid$x[j])^2 + (grid$y[i] - grid$y[j])^2)
- if(dist < threshold) {
- connections <- rbind(connections, data.frame(
- x = grid$x[i],
- y = grid$y[i],
- xend = grid$x[j],
- yend = grid$y[j],
- dist = dist
- ))
- }
- }
- }
- # Create plot
- p <- ggplot() +
- # Add connections
- geom_segment(data = connections,
- aes(x = x, y = y, xend = xend, yend = yend, alpha = 1/dist, color = dist),
- size = 0.8) +
- # Add points
- geom_point(data = grid, aes(x, y), color = "white", size = 1.5) +
- # Styling
- scale_color_viridis_c(option = "B", direction = -1) +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#2D3047"),
- plot.background = element_rect(fill = "#2D3047")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:27:21] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(123)
- # Create a grid of points (fewer points)
- n <- 10
- x <- seq(-10, 10, length.out = n)
- y <- seq(-10, 10, length.out = n)
- grid <- expand.grid(x = x, y = y)
- # Add some noise to the grid
- grid <- grid %>%
- dplyr::mutate(
- x = x + rnorm(n^2, 0, 0.5),
- y = y + rnorm(n^2, 0, 0.5)
- )
- # Calculate distances between points (only connect some random pairs)
- connections <- data.frame()
- threshold <- 4 # Only connect points that are close enough
- max_connections <- 100 # Limit the number of connections
- counter <- 0
- set.seed(456) # Different seed for random selection
- random_order <- sample(1:nrow(grid), nrow(grid))
- for(i in random_order) {
- if(counter >= max_connections) break
- for(j in random_order) {
- if(i >= j) next # Skip if i >= j to avoid duplicates
- if(counter >= max_connections) break
- dist <- sqrt((grid$x[i] - grid$x[j])^2 + (grid$y[i] - grid$y[j])^2)
- if(dist < threshold) {
- connections <- rbind(connections, data.frame(
- x = grid$x[i],
- y = grid$y[i],
- xend = grid$x[j],
- yend = grid$y[j],
- dist = dist
- ))
- counter <- counter + 1
- }
- }
- }
- # Create plot
- p <- ggplot() +
- # Add connections
- geom_segment(data = connections,
- aes(x = x, y = y, xend = xend, yend = yend, alpha = 1/dist, color = dist),
- size = 0.7) +
- # Add points
- geom_point(data = grid, aes(x, y), color = "white", size = 1.2) +
- # Styling
- scale_color_viridis_c(option = "B", direction = -1) +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#2D3047"),
- plot.background = element_rect(fill = "#2D3047")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:27:34] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Set seed for reproducibility
- set.seed(123)
- # Generate Voronoi-like structure
- n_points <- 50
- points <- data.frame(
- x = runif(n_points, -10, 10),
- y = runif(n_points, -10, 10),
- size = runif(n_points, 0.5, 2),
- group = sample(1:5, n_points, replace = TRUE)
- )
- # Calculate connections
- connections <- data.frame()
- threshold <- 5
- for(i in 1:(nrow(points)-1)) {
- for(j in (i+1):nrow(points)) {
- dist <- sqrt((points$x[i] - points$x[j])^2 + (points$y[i] - points$y[j])^2)
- if(dist < threshold) {
- connections <- rbind(connections, data.frame(
- x = points$x[i],
- y = points$y[i],
- xend = points$x[j],
- yend = points$y[j],
- dist = dist,
- group = ifelse(points$group[i] == points$group[j],
- points$group[i],
- sample(1:5, 1))
- ))
- }
- }
- }
- # Create color palette
- my_colors <- c("#FF595E", "#FFCA3A", "#8AC926", "#1982C4", "#6A4C93")
- # Create plot
- p <- ggplot() +
- # Add connections with group-based coloring
- geom_segment(data = connections,
- aes(x = x, y = y, xend = xend, yend = yend,
- color = factor(group), alpha = 1/dist),
- size = 0.8) +
- # Add points with group-based coloring
- geom_point(data = points,
- aes(x, y, size = size, color = factor(group)),
- alpha = 0.8) +
- # Styling
- scale_color_manual(values = my_colors) +
- scale_size_continuous(range = c(1, 3)) +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#F5F5F5"),
- plot.background = element_rect(fill = "#F5F5F5")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:27:50] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Function to generate a modified Sierpinski triangle
- generate_sierpinski <- function(depth, initial_points) {
- if(depth == 0) {
- return(initial_points)
- } else {
- # Calculate midpoints
- new_points <- data.frame()
- n_points <- nrow(initial_points)
- for(i in 1:n_points) {
- j <- i %% n_points + 1 # Next point (wrapping around)
- midpoint <- data.frame(
- x = (initial_points$x[i] + initial_points$x[j])/2,
- y = (initial_points$y[i] + initial_points$y[j])/2,
- depth = initial_points$depth[i] + 1
- )
- new_points <- rbind(new_points, midpoint)
- }
- # Add some controlled randomness for artistic effect
- new_points <- new_points %>%
- dplyr::mutate(
- x = x + rnorm(nrow(new_points), 0, 0.02 * (6-depth)),
- y = y + rnorm(nrow(new_points), 0, 0.02 * (6-depth))
- )
- # Combine with existing points
- combined_points <- rbind(initial_points, new_points)
- # Recursive call
- return(generate_sierpinski(depth-1, combined_points))
- }
- }
- # Create initial triangle
- side_length <- 14
- height <- side_length * sqrt(3)/2
- initial_points <- data.frame(
- x = c(-side_length/2, side_length/2, 0),
- y = c(-height/3, -height/3, 2*height/3),
- depth = 1
- )
- # Generate fractal
- set.seed(123)
- max_depth <- 5
- all_points <- generate_sierpinski(max_depth, initial_points)
- # Create the plot
- p <- ggplot(all_points, aes(x, y, color = depth, size = 6-depth)) +
- geom_point(alpha = 0.7) +
- scale_color_viridis_c(option = "A") +
- scale_size_continuous(range = c(0.5, 3)) +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#282828"),
- plot.background = element_rect(fill = "#282828")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:28:09] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Function to generate points for a Koch snowflake
- generate_koch <- function(iterations) {
- # Starting with an equilateral triangle
- angle <- 2*pi/3
- x <- c(0, cos(angle), cos(2*angle))
- y <- c(1, sin(angle), sin(2*angle))
- points <- data.frame(x = x, y = y)
- for(i in 1:iterations) {
- new_points <- data.frame()
- for(j in 1:nrow(points)) {
- x1 <- points$x[j]
- y1 <- points$y[j]
- # Get next point (wrapping around)
- if(j == nrow(points)) {
- x2 <- points$x[1]
- y2 <- points$y[1]
- } else {
- x2 <- points$x[j+1]
- y2 <- points$y[j+1]
- }
- # Calculate 4 new points from the current segment
- dx <- (x2 - x1) / 3
- dy <- (y2 - y1) / 3
- # First point (original)
- p1 <- c(x1, y1)
- # Second point (1/3 along the segment)
- p2 <- c(x1 + dx, y1 + dy)
- # Third point (peak of the new triangle)
- # Rotate the vector (dx, dy) by 60 degrees
- angle <- pi/3
- rot_dx <- dx * cos(angle) - dy * sin(angle)
- rot_dy <- dx * sin(angle) + dy * cos(angle)
- p3 <- c(p2[1] + rot_dx, p2[2] + rot_dy)
- # Fourth point (2/3 along the segment)
- p4 <- c(x1 + 2*dx, y1 + 2*dy)
- # Add points to new dataframe
- new_points <- rbind(new_points,
- data.frame(x = c(p1[1], p2[1], p3[1], p4[1]),
- y = c(p1[2], p2[2], p3[2], p4[2])))
- }
- points <- new_points
- }
- return(points)
- }
- # Generate the Koch snowflake with 4 iterations
- koch_points <- generate_koch(4)
- # Scale the snowflake to fit the plot
- max_dim <- max(abs(koch_points$x), abs(koch_points$y))
- koch_points <- koch_points %>%
- dplyr::mutate(
- x = 10 * x / max_dim,
- y = 10 * y / max_dim
- )
- # Add a color gradient based on position
- koch_points <- koch_points %>%
- dplyr::mutate(
- color_val = atan2(y, x) # Angle from origin
- )
- # Create the plot
- p <- ggplot(koch_points, aes(x, y, color = color_val)) +
- geom_path(size = 1, alpha = 0.7) +
- scale_color_viridis_c(option = "A") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#282828"),
- plot.background = element_rect(fill = "#282828")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:28:29] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Function to generate a single iteration of Koch curve
- koch_iteration <- function(points) {
- n <- nrow(points)
- new_points <- data.frame()
- for (i in 1:(n-1)) {
- p1 <- c(points$x[i], points$y[i])
- p5 <- c(points$x[i+1], points$y[i+1])
- # Calculate intermediate points
- p2 <- p1 + (p5 - p1) / 3
- p4 <- p1 + 2 * (p5 - p1) / 3
- # Calculate the "bump" point p3
- # Rotate (p4 - p2) by 60 degrees and add to p2
- vec <- p4 - p2
- p3 <- p2 + complex(real = vec[1], imaginary = vec[2]) * exp(complex(real = 0, imaginary = pi/3))
- p3 <- c(Re(p3), Im(p3))
- # Add all points
- new_points <- rbind(new_points,
- data.frame(x = c(p1[1], p2[1], p3[1], p4[1]),
- y = c(p1[2], p2[2], p3[2], p4[2])))
- }
- # Add the final point
- new_points <- rbind(new_points, points[n, ])
- return(new_points)
- }
- # Create a complete Koch snowflake
- create_koch_snowflake <- function(iterations, size = 10, center = c(0, 0), rotation = 0, id = 1) {
- # Create initial triangle
- t <- seq(0, 2*pi, length.out = 4)
- points <- data.frame(
- x = center[1] + size * cos(t + rotation),
- y = center[2] + size * sin(t + rotation)
- )
- points <- points[1:3, ] # Just keep the first 3 points for a triangle
- points <- rbind(points, points[1, ]) # Close the triangle
- # Apply iterations
- for(i in 1:iterations) {
- points <- koch_iteration(points)
- }
- # Add identifier
- points$id <- id
- return(points)
- }
- # Create multiple snowflakes
- snowflakes <- data.frame()
- # Main large snowflake
- main_flake <- create_koch_snowflake(
- iterations = 4,
- size = 8,
- center = c(0, 0),
- id = 1
- )
- snowflakes <- rbind(snowflakes, main_flake)
- # Smaller snowflakes around
- for(i in 1:5) {
- angle <- 2*pi * i/5
- center_x <- 12 * cos(angle)
- center_y <- 12 * sin(angle)
- flake <- create_koch_snowflake(
- iterations = 3,
- size = 3,
- center = c(center_x, center_y),
- rotation = angle,
- id = i + 1
- )
- snowflakes <- rbind(snowflakes, flake)
- }
- # Create color palette
- snowflakes <- snowflakes %>%
- dplyr::mutate(
- color_val = id + atan2(y, x)/(2*pi) # Combine ID and angle for coloring
- )
- # Create the plot
- p <- ggplot(snowflakes, aes(x, y, group = interaction(id, color_val), color = color_val)) +
- geom_path(size = 0.5, alpha = 0.8) +
- scale_color_viridis_c(option = "D") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#0E0E18"),
- plot.background = element_rect(fill = "#0E0E18")
- ) +
- coord_fixed(ratio = 1)
- print(p)
- # --- [2025-03-19 18:29:27] ---
- # Code executed by Claude:
- # Ensure plot is displayed in RStudio
- if (!("package:ggplot2" %in% search())) {
- if (requireNamespace("ggplot2", quietly = TRUE)) {
- library(ggplot2)
- }
- }
- # Execute the plot code
- library(ggplot2)
- library(dplyr)
- # Let's try a different approach with a Barnsley fern
- generate_barnsley_fern <- function(n_points = 50000) {
- # Initialize points array
- points <- data.frame(x = numeric(n_points), y = numeric(n_points))
- # Start with (0,0)
- x <- 0
- y <- 0
- # Fill the points
- for(i in 1:n_points) {
- # Store the current point
- points$x[i] <- x
- points$y[i] <- y
- # Choose a random transformation
- r <- runif(1)
- if(r < 0.01) {
- # Transformation 1 (stem)
- x_new <- 0
- y_new <- 0.16 * y
- } else if(r < 0.86) {
- # Transformation 2 (smaller leaflets)
- x_new <- 0.85 * x + 0.04 * y
- y_new <- -0.04 * x + 0.85 * y + 1.6
- } else if(r < 0.93) {
- # Transformation 3 (left leaflet)
- x_new <- 0.20 * x - 0.26 * y
- y_new <- 0.23 * x + 0.22 * y + 1.6
- } else {
- # Transformation 4 (right leaflet)
- x_new <- -0.15 * x + 0.28 * y
- y_new <- 0.26 * x + 0.24 * y + 0.44
- }
- # Update for next iteration
- x <- x_new
- y <- y_new
- }
- # Add a group to color by
- points <- points %>%
- dplyr::mutate(
- group = ceiling(1:n_points / (n_points/7)) # Create 7 groups
- )
- return(points)
- }
- # Generate the fractal
- set.seed(42)
- fern <- generate_barnsley_fern(50000)
- # Plot the fern
- p <- ggplot(fern, aes(x, y, color = factor(group))) +
- geom_point(size = 0.1, alpha = 0.6) +
- scale_color_viridis_d(option = "D") +
- theme_void() +
- theme(
- legend.position = "none",
- panel.background = element_rect(fill = "#0E0E18"),
- plot.background = element_rect(fill = "#0E0E18")
- ) +
- labs(title = "Fractal Dreams") +
- coord_fixed(ratio = 1)
- print(p)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement