install.packages("ggfun")
install.packages("gcookbook")
library(ggplot2)
library(ggfun)
library(gcookbook)
heightweight <- gcookbook::heightweight
head(heightweight)
这段代码使用了gcookbook包中的heightweight数据集,并展示了该数据集的前几行。
ggplot(heightweight, aes(heightIn, weightLb)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~sex) +
theme_bw(base_size = 15)
ggplot(heightweight, aes(heightIn, weightLb)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~sex) +
theme_bw(base_size = 16) +
facet_set(label = c("f" = "Female", "m" = "Male"))
ggplot(heightweight, aes(heightIn, weightLb)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~sex) +
theme_bw(base_size = 16) +
facet_set(label = c("f" = "Female", "m" = "Male")) +
theme(strip.background = element_roundrect(fill = "pink", color = "black", r = 0.15))