Estetikleri Değiştirme

ggplot2 ile Veri Görselleştirmeye Giriş

Rick Scavetta

Founder, Scavetta Academy

Konumlar

Çakışma için ayarlama

  • identity
  • dodge
  • stack
  • fill
  • jitter
  • jitterdodge
  • nudge
ggplot2 ile Veri Görselleştirmeye Giriş

position = "identity" (öntanımlı)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point()

ggplot2 ile Veri Görselleştirmeye Giriş

position = "identity" (öntanımlı)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "identity")

ggplot2 ile Veri Görselleştirmeye Giriş

position = "jitter"

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "jitter")

ggplot2 ile Veri Görselleştirmeye Giriş

position_jitter()

posn_j <- position_jitter(0.1)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 col = Species)) +
  geom_point(position = posn_j)

ggplot2 ile Veri Görselleştirmeye Giriş

position_jitter()

posn_j <- position_jitter(0.1, 
                          seed = 136)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = posn_j)
  • Konum bağımsız değişkenlerini ayarlayın
  • Grafikler ve katmanlar arasında tutarlılık

ggplot2 ile Veri Görselleştirmeye Giriş

Ölçek işlevleri

  • scale_x_*()
  • scale_y_*()
  • scale_color_*()
    • scale_colour_*() da var
  • scale_fill_*()
  • scale_shape_*()
  • scale_linetype_*()
  • scale_size_*()
ggplot2 ile Veri Görselleştirmeye Giriş

Ölçek işlevleri

  • scale_x_continuous()
  • scale_y_*()
  • scale_color_discrete()
    • Alternatif: scale_colour_*()
  • scale_fill_*()
  • scale_shape_*()
  • scale_linetype_*()
  • scale_size_*()
ggplot2 ile Veri Görselleştirmeye Giriş

scale_*_*()

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "jitter") +
  scale_x_continuous("Sepal Length") +
  scale_color_discrete("Species")

ggplot2 ile Veri Görselleştirmeye Giriş

limits bağımsız değişkeni

ggplot(iris, aes(x = Sepal.Length, 
                  y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "jitter") +
  scale_x_continuous("Sepal Length", 
                     limits = c(2,8)) +
  scale_color_discrete("Species")

ggplot2 ile Veri Görselleştirmeye Giriş

breaks bağımsız değişkeni

ggplot(iris, aes(x = Sepal.Length, 
                  y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "jitter") +
  scale_x_continuous("Sepal Length", 
                     limits = c(2, 8), 
                     breaks = seq(2, 8, 3)) +
  scale_color_discrete("Species")

ggplot2 ile Veri Görselleştirmeye Giriş

expand bağımsız değişkeni

ggplot(iris, aes(x = Sepal.Length, 
                  y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "jitter") +
  scale_x_continuous("Sepal Length", 
                     limits = c(2, 8), 
                     breaks = seq(2, 8, 3),
                     expand = c(0, 0)) +
  scale_color_discrete("Species")

ggplot2 ile Veri Görselleştirmeye Giriş

labels bağımsız değişkeni

ggplot(iris, aes(x = Sepal.Length, 
                  y = Sepal.Width, 
                 color = Species)) + 
  geom_point(position = "jitter") +
  scale_x_continuous("Sepal Length", 
                     limits = c(2, 8), 
                     breaks = seq(2, 8, 3),
                     expand = c(0, 0), 
                     labels = c("Setosa", 
                               "Versicolor", 
                               "Virginica")) +
  scale_color_discrete("Species")

ggplot2 ile Veri Görselleştirmeye Giriş

labs()

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) +
  geom_point(position = "jitter") +
  labs(x = "Sepal Length", 
       y = "Sepal Width", 
       color = "Species")

ggplot2 ile Veri Görselleştirmeye Giriş

Hadi deneyelim!

ggplot2 ile Veri Görselleştirmeye Giriş

Preparing Video For Download...