开始使用免费开始使用

设置主题

在多幅图中复用同一主题,有助于保持风格一致。您有几种做法可选:

  1. 将主题赋给一个变量,并把它加到每一幅图上。
  2. 使用 theme_set() 将主题设置为默认值。

一个不错的策略(本练习将采用)是先从内置主题开始,再进行修改。

plt_prop_unemployed_over_time 可用。您之前创建的主题已在示例代码中给出。

本练习是课程的一部分

使用 ggplot2 进行数据可视化入门

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Save the theme as theme_recession
___ <- theme(
  rect = element_rect(fill = "grey92"),
  legend.key = element_rect(color = NA),
  axis.ticks = element_blank(),
  panel.grid = element_blank(),
  panel.grid.major.y = element_line(color = "white", size = 0.5, linetype = "dotted"),
  axis.text = element_text(color = "grey25"),
  plot.title = element_text(face = "italic", size = 16),
  legend.position = c(0.6, 0.1)
)

# Combine the Tufte theme with theme_recession
theme_tufte_recession <- ___

# Add the Tufte recession theme to the plot
___
编辑并运行代码