Faset çizim alanları

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

Rick Scavetta

Founder, Scavetta Academy

Fasetler ve değişken çizim alanları

Tutarlı çizim alanlarını kullanmamak için nedenler:

Değişken türü Alt kümeler şunları içerir
Sürekli Çok farklı aralıklar
Kategorik Farklı gruplar
ggplot2 ile Orta Düzey Veri Görselleştirme

Çizim alanını ayarlama...

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

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

... ancak sabit ölçeklerle değil

ggplot(msleep2, aes(bodywt_log,
                         brainwt_log)) +
  geom_point(alpha = 0.6, shape = 16) +
  coord_fixed() +
  facet_grid(rows = vars(vore), 
             cols = vars(conservation),
             scales = "free_x")
Error: coord_fixed doesn't support free scales
ggplot2 ile Orta Düzey Veri Görselleştirme

Çizim 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_x") 

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

Çizim 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_y") 

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

Çizim 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

Çizim alanını ayarlama

ggplot(msleep2, aes(x = bodywt_log, 
                    y = name)) +
  geom_point() +
  facet_grid(rows = vars(vore))

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

Çizim alanını ayarlama

ggplot(msleep2, aes(x = bodywt_log, 
                    y = name)) +
  geom_point() +
  # Y ölçeklerini ve alanı serbest bırakın
  facet_grid(rows = vars(vore), 
             scales = "free_y")

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

Çizim alanını ayarlama

ggplot(msleep2, aes(x = bodywt_log, 
                    y = name)) +
  geom_point() +
  # Y ölçeklerini ve alanı serbest bırakın
  facet_grid(rows = vars(vore),
             scales = "free_y", 
             space = "free_y")

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

Son ayarlar

msleep2 <- msleep2 %>% 
  # Ağırlığı yükseğe göre sırala
  arrange(-bodywt_log) %>% 
  # Faktör seviyelerini bu sıraya göre tanımla
  mutate(name = as_factor(name)) 

# Yeni sıra y eksenine yansır
ggplot(msleep2, aes(x = bodywt_log,
                    y = name)) +
  geom_point() +
  # Y ölçeklerini ve alanı serbest bırakın
  facet_grid(rows = vars(vore),
             scales = "free_y", 
             space = "free_y")

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