MulaiMulai sekarang secara gratis

Flipping axes I

Flipping axes means to reverse the variables mapped onto the x and y aesthetics. We can just change the mappings in aes(), but we can also use the coord_flip() layer function.

There are two reasons to use this function:

  • We want a vertical geom to be horizontal, or
  • We've completed a long series of plotting functions and want to flip it without having to rewrite all our commands.

Latihan ini adalah bagian dari kursus

Intermediate Data Visualization with ggplot2

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Plot fcyl bars, filled by fam
ggplot(mtcars, aes(___, fill = ___)) +
  # Place bars side by side
  geom_bar(position = ___)
Edit dan Jalankan Kode