R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

install.packages(“ggplot2”)
library(ggplot2)

tinytool for make a flower

make_flower <- function(cx, cy, r_petals = 0.35, n_petals = 8, flower_id = 1) { theta <- seq(0, 2*pi, length.out = n_petals + 1)[- (n_petals + 1)]

petals <- data.frame( x = cx + r_petals * cos(theta), y = cy + r_petals * sin(theta), type = “petal”, flower_id = flower_id )

center <- data.frame( x = cx, y = cy, type = “center”, flower_id = flower_id )

list(petals = petals, center = center) }

library ggplot2 package

library(ggplot2)

create a function for a single flower

flower <- function(cx, cy, r = 0.4) { t <- seq(0, 2pi, length.out = 6)[-6] data.frame( x = cx + r cos(t), y = cy + r * sin(t) ) }

three flowers

f1 <- flower(-1, 1, r = 0.4) f2 <- flower(0, 1.4, r = 0.45) f3 <- flower(1, 1, r = 0.4)

centers

centers <- data.frame( x = c(-1, 0, 1), y = c(1, 1.4, 1) )

stems

stems <- data.frame( x = c(-1, 0, 1), xend = c(-0.2, 0, 0.2), y = c(-1, -1, -1), yend = c(0.6, 0.8, 0.6) )

ribbon

ribbon <- data.frame( x = c(-0.3, 0, 0.3, 0), y = c(0, -0.3, 0, 0.2) )

handle

handle <- data.frame( x = c(-0.2, 0.2, 0.2, -0.2), y = c(-1, -1, -1.7, -1.7) )

the complete flower graph

ggplot() + theme_void() +

# stems geom_segment( data = stems, aes(x, y, xend = xend, yend = yend), linewidth = 4, color = “darkgreen”, lineend = “round” ) +

# handle geom_polygon(data = handle, aes(x, y), fill = “#8B4513”) +

# ribbon geom_polygon(data = ribbon, aes(x, y), fill = “#FF69B4”) +

# flowers geom_polygon(data = f1, aes(x, y), fill = “#FFB6C1”) + geom_polygon(data = f2, aes(x, y), fill = “#FFB6C1”) + geom_polygon(data = f3, aes(x, y), fill = “#FFB6C1”) +

# centers geom_point(data = centers, aes(x, y), size = 10, color = “#FFD700”) +

coord_fixed() + xlim(-2, 2) + ylim(-2.2, 2) + labs( title = “For you 💐”, subtitle = “To my dearest 🖤” )

graph

p

In case we want to save into the picture:

ggsave(“bouquet_for_my_love.png”, p, width = 6, height = 8, dpi = 300)