1. Aprende
  2. /
  3. Cursos
  4. /
  5. Intermediate Data Visualization with ggplot2

Connected

Ejercicio

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.

Instrucciones 1/3

undefined XP
  • 1
    • Create a side-by-side ("dodged") bar chart of fcyl, filled according to fam.
  • 2
    • To get horizontal bars, add a coord_flip() function.
  • 3
    • Partially overlapping bars are popular with "infoviz" in magazines. Update the position argument to use position_dodge() with a width of 0.5.