??theme_bw()参数的使用
??theme_bw()
##用法,其他的几个内部参数相同
theme_grey(
base_size = 15,##整体布局字的缩放比例
base_family = "bold",##所有的字体
base_line_size = 1/10,##基本的线的粗细
base_rect_size = 1/2
)
mtcars2 <- within(mtcars, {
vs <- factor(vs, labels = c("V-shaped", "Straight"))
am <- factor(am, labels = c("Automatic", "Manual"))
cyl <- factor(cyl)
gear <- factor(gear)
})
p1 <- ggplot(mtcars2) +
geom_point(aes(x = wt, y = mpg, colour = gear)) +
labs(title = "Fuel economy declines as weight increases",
subtitle = "(1973-74)",
caption = "Data from the 1974 Motor Trend US magazine.",
tag = "Figure 1",
x = "Weight (1000 lbs)",
y = "Fuel economy (mpg)",
colour = "Gears")###关于标题和亚标题及图形字幕的说明
p1 + theme_gray() # the default 见图1
p1 + theme_bw()##背景灰色去掉了 见图2
p1 + theme_linedraw() 见图3
p1 + theme_light()##背景色在白色的基础上减轻 见图4
p1 + theme_dark()##深色背景 见图5
p1 +

本文详细介绍了ggplot2库中的theme_bw()函数,通过展示从图1到图16的多个实例,揭示了该函数如何改变图表背景、字体、轴线等视觉元素,帮助读者理解并掌握ggplot2图形的主题定制。

1354

被折叠的 条评论
为什么被折叠?



