复现该图

Tidyverse 中的分类数据

Emily Robinson

Data Scientist

Labs

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)))

同一柱状图,但每个柱顶端的均值 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 中的分类数据

Passons à la pratique !

Tidyverse 中的分类数据

Preparing Video For Download...