グラフの再現

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 で学ぶカテゴリ型データ

練習しましょう!

tidyverse で学ぶカテゴリ型データ

Preparing Video For Download...