看到一个博主用R语言画国旗,暂存一下代码
library(tidyverse)
library(ggstar)
library(ggthemes)
df <- data.frame(
x = c(0.6, 1.2, 1.5, 1.5, 1.2),
score = c(4.5, 3.4, 4.1, 4.9, 5.4),
mysize = c("big", rep("small", 4)),
group = rep("yellow", 5)
)
ggplot(data = df, aes(x=x, y=score)) +
geom_star(aes(fill=group, color = "yellow", size = mysize,
angle = c(0, 35, 0, 45, 180))) +
scale_starshape_manual(values = "pentagram") +
scale_fill_manual(values = "yellow") +
scale_size_manual(values = c(30, 8)) +
ylim(0.5, 5.56) +
xlim(0.1, 5) +
theme(legend.title = element_blank(),
panel.grid = element_blank(),
axis.ticks = element_blank(),
axis.text = element_blank(),
axis.title = element_blank(),
legend.position = "none",
panel.background = element_rect(fill = "red"))
ggsave(filename = "RedFlag.pdf", width = 9, height = 6, dpi = 600)