library(ggplot2)
<- function(n = 100){ fun.plot <- x <- seq(-4 * pi, 4 * pi, len = n) y <- sin( cos(outer(x^2, y^2, "+")) ^ 2 ) r <- data.frame( df x = rep( x , each = n) , y = rep( y , times = n ), val = c(r)) ggplot(df, aes(x, y, fill = val))+ # create a heatmap geom_raster() + # annotate with n annotate(geom = "text", x = 0, y = 0, label = paste("n =", n), fontface = "bold", size = 8) + scale_fill_distiller(palette = "Spectral") + theme_void() + theme(legend.position = "none") }
# Combine six plots together library(patchwork)
fun.plot(n = 10) | fun.plot(n = 25) | fun.plot(n = 50) ) / (fun.plot(n = 100) | fun.plot(n = 200) | fun.plot(n = 500)) (
Create Interesting Patterns with Math Functions in ggplot2

This fun visualization is inspired from a post in stack overflow, and illustrates the use of mathematical functions to create interesting patterns.
Continue Exploring — 🚀 one level up!
In addition to using self-defined math formulas to create beautiful patterns, the aRtsy package is another amazing approach to create engaging artworks using pre-defined algorithms.
In addition to abstract artworks created by randomization algorithms, heatmaps are another powerful tool that not only offers unique aesthetic appeal, but also provides valuable insights into data patterns – check out the following amazing heatmap visualizing the population distribution in Africa.
And check out these beautiful heatmaps highlighting the power of vaccines in disease control throughout the U.S. history.
Last but not the least, check out this awesome 2D histogram with a world map overlay that visualizes the hurricane activities in North Atlantic Ocean.