重現圖表

Tidyverse 的類別資料

Emily Robinson

Data Scientist

標籤

ggplot(mtcars, aes(disp, mpg)) + geom_point() + 
  labs(x = "x axis label", y = "y axis label", title = "My title", 
       subtitle = "and a subtitle", caption = "even a caption!")

一張散佈圖,標題為「My title」,副標題為「and a subtitle」,y 軸標籤為「y axis label」,x 軸標籤為「x axis label」,圖說為「even a caption!」

Tidyverse 的類別資料

長條圖,x 軸為「mean mpg」,y 軸為「carb」。

Tidyverse 的類別資料

Geom_text

initial_plot + geom_text(aes(label = round(mean_mpg)))

相同長條圖,但每個長條頂端有重疊的 mean mpg 數字。

Tidyverse 的類別資料

移動文字

initial_plot + 
  geom_text(aes(label = round(mean_mpg), y = mean_mpg + 2))

與前一張相同,但文字移到每個長條上方。

Tidyverse 的類別資料

主題

initial_plot + 
  geom_text(aes(label = round(mean_mpg), y = mean_mpg + 2)) + 
  theme(axis.text.x = element_blank(), axis.ticks.x = element_blank())

與前一張相同,但移除了 x 軸標籤與刻度。

Tidyverse 的類別資料

一起來練習吧!

Tidyverse 的類別資料

Preparing Video For Download...