{hrbrthemes}:图片风格还能这么换!?
# 安装并载入R包
install.packages("hrbrthemes")
library(hrbrthemes)
library(ggplot2) # 需提前安装:install.packages("ggplot2")
data(mpg) # 导入数据
summary(mpg) # 查看数据

ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(color = "black") +
theme_ipsum()
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(size= 2, color = "gold") +
theme_ft_rc()
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
theme_modern_rc()



ggplot(mpg, aes(x = class, y = hwy, color = drv)) +
geom_boxplot() +
scale_color_ipsum() + # ipsum 调色盘
scale_y_percent() # 修改y轴刻度标签为百分比

ggplot(mpg, aes(x = class, y = hwy)) +
geom_boxplot() +
theme_ipsum() +
theme(panel.grid.major = element_line(size = 1.2, color = "palegreen"),
panel.background = element_rect(fill = "grey90"),
axis.title = element_text(size = 12))

ggplot(mpg, aes(x = class, y = hwy, fill = drv)) +
geom_boxplot() +
scale_fill_ipsum() + # ipsum 调色盘
theme_ipsum(base_size = 14, # 精修图片主题
base_family = "Calibri",
axis_title_family = "Rage",
axis_title_size = 12,
plot_title_size = 18,
grid_col = "skyblue"
) +
labs(title = "The Fuel Economy Data",
x = "Types of Car",
y = "Highway MPG")


[1]. https://hrbrmstr.github.io/hrbrthemes/index.html
2024-05-11 12:39