시작하기무료로 시작하기

테마 설정하기

여러 그래프에 동일한 테마를 재사용하면 일관된 스타일을 유지할 수 있습니다. 이를 위한 방법은 여러 가지가 있습니다.

  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
___
코드 편집 및 실행