facet_wrap ve kenar özetleri

ggplot2 ile Orta Düzey Veri Görselleştirme

Rick Scavetta

Founder, Scavetta Academy

Grafik alanını ayarlama

ggplot(msleep2, aes(bodywt_log, 
                    brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  facet_grid(rows = vars(vore), 
             cols = vars(conservation),
             scales = "free") 

ggplot2 ile Orta Düzey Veri Görselleştirme

facet_wrap() kullanımı

Kullanım durumları:

  1. Her tekil grafikte hem x hem y eksenlerinin serbest olmasını istediğinizde
    • yani facet_grid()'deki gibi sadece satır veya sütuna göre değil
ggplot2 ile Orta Düzey Veri Görselleştirme

facet_wrap() kullanımı - Senaryo 1

ggplot(msleep2, aes(bodywt_log, 
                    brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  facet_wrap(vars(vore, conservation),
             scales = "free") 

ggplot2 ile Orta Düzey Veri Görselleştirme

facet_wrap() kullanımı

Kullanım durumları:

  1. Her tekil grafikte hem x hem y eksenlerinin serbest olmasını istediğinizde
    • yani facet_grid()'deki gibi sadece satır veya sütuna göre değil
  2. Kategorik (faktör) değişkeninizin çok grubu (düzeyi) olduğunda
    • yani sütun ya da satır kırılımıyla çok fazla alt grafik çıktığında
    • Daha tipik bir senaryo
ggplot2 ile Orta Düzey Veri Görselleştirme

facet_wrap() kullanımı - Senaryo 2

ggplot(msleep2, aes(bodywt_log, 
                    brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  facet_wrap(vars(order))

ggplot2 ile Orta Düzey Veri Görselleştirme

Kenar (margin) grafikleri kullanma

ggplot(msleep2, aes(bodywt_log, 
                    brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  facet_grid(rows = vars(vore), 
             cols = vars(conservation),
             scales = "free") 

ggplot2 ile Orta Düzey Veri Görselleştirme

Kenar (margin) grafikleri kullanma

ggplot(msleep2, aes(bodywt_log, 
                    brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  facet_grid(rows = vars(vore), 
             cols = vars(conservation),
             scales = "free",
             margins = TRUE) 

ggplot2 ile Orta Düzey Veri Görselleştirme

Kenar (margin) grafikleri kullanma

ggplot(msleep2, aes(bodywt_log, 
                    brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  facet_grid(rows = vars(vore), 
             cols = vars(conservation),
             scales = "free",
             margins = "conservation")

ggplot2 ile Orta Düzey Veri Görselleştirme

Hadi pratik yapalım!

ggplot2 ile Orta Düzey Veri Görselleştirme

Preparing Video For Download...