MulaiMulai sekarang secara gratis

Bar plots: sequential color palette

In this bar plot, we'll fill each segment according to an ordinal variable. The best way to do that is with a sequential color palette.

Here's an example of using a sequential color palette with the mtcars dataset:

ggplot(mtcars, aes(fcyl, fill = fam)) +
  geom_bar() +
  scale_fill_brewer(palette = "Set1")

In the exercise, you'll use similar code on the the Vocab dataset. Both datasets are ordinal.

Latihan ini adalah bagian dari kursus

Introduction to Data Visualization with ggplot2

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Plot education, filled by vocabulary
___
Edit dan Jalankan Kode