Created
February 15, 2019 06:05
-
-
Save perlatex/15342e0892111f20113a6f8f02f8a9b4 to your computer and use it in GitHub Desktop.
Valentine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# learn from https://rpubs.com/dgrtwo/valentine | |
library(ggplot2) | |
library(dplyr) | |
library(gganimate) | |
heartdf <- tibble( | |
t = seq(0, 2 * pi, pi / 60), | |
x = 16 * sin(t)^3, | |
y = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t) | |
) | |
ggplot(data = heartdf, aes(x, y)) + | |
geom_path() + | |
transition_reveal(t) | |
textdf <- heartdf %>% | |
select(-t) %>% | |
tidyr::crossing(t = max(heartdf$t) + 1:15) | |
ggplot(data = heartdf, aes(x, y)) + | |
geom_path() + | |
geom_polygon(data = textdf, fill = "red") + | |
geom_text(aes(x = 0, y = 0, label = "情人节快乐!!!"), | |
data = textdf, size = 12, colour = "white" ) + | |
transition_reveal(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment