Double and flipped axes

1. Double and flipped axes

So far we've seen two ways in which we can modify our axes.

2. Typical axis modifications

First we saw that we can change the aspect ratio to obtain the best perspective. In the last video we saw how we can also apply appropriate transformation functions. Here, I want to take a look at two more common modifications.

3. Typical axis modifications

Let's begin with having double x or y axes. Actually, having a double x or y axis is strongly discouraged. I'll discuss when it can go wrong in chapter 4. Here, I want to give show you when double axes can actually work really well.

4. Double axes

We ended the last video with this plot. It displays log10 transformed values. One problem with presenting transformed values is that we are an additional step further removed from the raw data.

5. Adding raw and transformed axes

To make the plot easier to read, we can include the raw and the log10-transformed values on one plot. This is a beautiful use case since the double axis adds more information to an existing variable.

6. Typical axis modifications

Let's take a look at one more typical modification. Flipping axes. This can be useful for changing the direction of dependencies, but also when we need to adjust the geometry's orientation. We'll look at the first case in the video and you'll explore the second in the exercises.

7. Flipping axes

We saw this plot of the iris dataset in the first video of this course. It uses geom smooth to add three linear models to a scatter plot. In this case, both sepal width and length are dependent variables. That is, they are dependent on the species, which is the independent variable. Statistically, it doesn't really matter which is mapped to the x or y. But in some cases it does. Our models are read as "y as a function of x" since we typically map the dependent variable onto the y axis and the independent variable onto the x axis. If we ever decide that our orientation is incorrect, we can either change our code to remap our variables, or

8. coord_flip()

we can use quick and easy coord flip function. In this way, we don't need to manually adjust all our code. You can only use one coord layer function in each plot, so we don't have the possibility to set the aspect ratio anymore.

9. Let's practice!

Alright, we've seen four different ways in which we can modify our axes. Let's practice with some exercises.