BaşlayınÜcretsiz Başlayın

Margin plots

Facets are great for seeing subsets in a variable, but sometimes you want to see both those subsets and all values in a variable.

Here, the margins argument to facet_grid() is your friend.

  • FALSE (default): no margins.
  • TRUE: add margins to every variable being faceted by.
  • c("variable1", "variable2"): only add margins to the variables listed.

To make it easier to follow the facets, we've created two factor variables with proper labels — fam for the transmission type, and fvs for the engine type, respectively.

Zoom the graphics window to better view your plots.

Bu egzersiz

Intermediate Data Visualization with ggplot2

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

ggplot(mtcars, aes(x = wt, y = mpg)) + 
  geom_point() +
  # Facet rows by fvs and cols by fam
  ___
Kodu Düzenle ve Çalıştır