MulaiMulai sekarang secara gratis

Preparations

In the following exercises, we'll aim to make the plot shown in the viewer. Here, we'll establish our positions and base layer of the plot.

Establishing these items as independent objects will allow us to recycle them easily in many layers, or plots.

  • position_jitter() adds jittering (e.g. for points).
  • position_dodge() dodges geoms, (e.g. bar, col, boxplot, violin, errorbar, pointrange).
  • position_jitterdodge() jitters and dodges geoms, (e.g. points).

As before, we'll use mtcars, where fcyl and fam are proper factor variables of the original cyl and am variables.

Latihan ini adalah bagian dari kursus

Intermediate Data Visualization with ggplot2

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Define position objects
# 1. Jitter with width 0.2
posn_j <- ___

# 2. Dodge with width 0.1
posn_d <- ___

# 3. Jitter-dodge with jitter.width 0.2 and dodge.width 0.1
posn_jd <- ___
Edit dan Jalankan Kode