Double and flipped axes

Intermediate Data Visualization with ggplot2

Rick Scavetta

Founder, Scavetta Academy

Typical axis modifications

  • Aspect ratios (see video 1)
    • Adjust for best perspective
  • Transformation functions (e.g. log, see video 2)
    • Adjust if original scale is inappropriate
  • Double x or y axes
    • Add raw and transformed values
  • Flipped axes
    • Change direction of dependencies
    • Change geometry orientation
Intermediate Data Visualization with ggplot2

Typical axis modifications

  • Aspect ratios (see video 1)
    • Adjust for best perspective
  • Transformation functions (e.g. log, see video 2)
    • Adjust if original scale is inappropriate
  • Double x or y axes
    • Add raw and transformed values
  • Flipped axes
    • Change direction of dependencies
    • Change geometry orientation
1 See chapter 4, video 3 for more discussion on double x and y-axes.
Intermediate Data Visualization with ggplot2

Double axes

scale relabeled

Intermediate Data Visualization with ggplot2

Adding raw and transformed axes

with annotations

Intermediate Data Visualization with ggplot2

Typical axis modifications

  • Aspect ratios (see video 1)
    • Adjust for best perspective
  • Transformation functions (e.g. log, see video 2)
    • Adjust if original scale is inappropriate
  • Double x or y axes
    • Add raw and transformed values
  • Flipped axes
    • Change direction of dependencies
    • Change geometry orientation
Intermediate Data Visualization with ggplot2

Flipping axes

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth(method = "lm", 
              se = FALSE)

Intermediate Data Visualization with ggplot2

coord_flip()

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth(method = "lm", 
              se = FALSE) +
  coord_flip()

Intermediate Data Visualization with ggplot2

Let's practice!

Intermediate Data Visualization with ggplot2

Preparing Video For Download...