Coordonate vs. scale-uri

Vizualizare intermediară a datelor cu ggplot2

Rick Scavetta

Founder, Scavetta Academy

Reprezentarea datelor brute

ggplot(msleep, aes(bodywt, y = 1)) +
  geom_jitter() +
  scale_x_continuous(limits = c(0, 7000), 
                     breaks = seq(0, 7000, 1000))

Date asimetrice

Vizualizare intermediară a datelor cu ggplot2

Transformarea datelor brute

ggplot(msleep, aes(log10(bodywt), y = 1)) +
  geom_jitter() +
  scale_x_continuous(limits = c(-3, 4),
                     breaks = -3:4)

Transformarea valorilor brute

Vizualizare intermediară a datelor cu ggplot2

Adăugarea adnotării logtick

ggplot(msleep, aes(log10(bodywt), y = 1)) +
  geom_jitter() +
  scale_x_continuous(limits = c(-3, 4),
                     breaks = -3:4) +
  annotation_logticks(sides = "b")

Valori brute transformate, cu marcaje logaritmice

Vizualizare intermediară a datelor cu ggplot2

Utilizarea scale_*_log10()

ggplot(msleep, aes(bodywt, y = 1)) +
  geom_jitter() +
  scale_x_log10(limits = c(1e-03, 1e+04))

transformare scale

Vizualizare intermediară a datelor cu ggplot2

Compararea transformării directe și a rezultatelor scale_*_log10()

Transformarea valorilor brute

transformare scale

Vizualizare intermediară a datelor cu ggplot2

Utilizarea coord_trans()

ggplot(msleep, aes(bodywt, y = 1)) +
  geom_jitter() +
  coord_trans(x = "log10") 

transformare coord

Vizualizare intermediară a datelor cu ggplot2

Compararea rezultatelor scale_*_log10() și coord_trans()

transformare coord

transformare scale

Vizualizare intermediară a datelor cu ggplot2

Ajustarea etichetelor

coord redenumit

scale redenumit

Vizualizare intermediară a datelor cu ggplot2

Exerciții

Vizualizare intermediară a datelor cu ggplot2

Preparing Video For Download...