将新的主题函数应用到图形上
创建好您自己的 theme_ilo() 函数后,就可以把它应用到图形对象上了。您在视频中看到,theme() 调用是可以链式连接的。接下来您将利用这一点,再添加一次 theme() 调用,以调整分面图的一些细节。
本练习是课程的一部分
在 Tidyverse 中用数据进行沟通
练习说明
- 从现在起,您可以把
theme_ilo()直接添加到任意图形对象上。试一试吧!重写变量ilo_plot,让theme_ilo()得到永久应用。 - 将您的自定义主题函数与更多的
theme()调用结合使用,以灵活调整高级图形的设置。- 为此,请在
theme_ilo()调用之后再添加一次theme()调用。 - 使用
strip.background参数,把分面标签背景的fill改为"gray60",其color改为"gray95"。 - 将分面标签文本的
color改为"white"。
- 为此,请在
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Apply your theme function (dont't forget to call it with parentheses!)
ilo_plot <- ilo_plot +
___
# Examine ilo_plot
ilo_plot
ilo_plot +
# Add another theme call
___(
# Change the background fill and color
strip.background = element_rect(___, ___),
# Change the color of the text
strip.text = element_text(___)
)