CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Intermediate Data Visualization with ggplot2

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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 <- ___
Modifier et exécuter le code