Customizing a Figure in R

Learn to customize figures in R.

There are a lot of different ways to customize a figure in R. Here’s a non-exhaustive list of important and useful functions for us to know to effectively customize our figures.

Changing colors

While the default colors chosen for us in the ggplot2 package are quite appealing, sometimes we may want to specify other colors. When we change the ways that the data is mapped to the figure, we’re changing a scale. Thus, to customize our colors, we usually use either scale_fill_manual() or scale_color_manual(), depending on whether we’ve filled our object or colored it. For example, in our density plot earlier, we filled based on our predator treatment. Let’s override the colors using scale_fill_manual(). We assign the new colors of our choice with the values= argument, and the new colors have to be concatenated together in a vector.

Get hands-on with 1200+ tech skills courses.