# Class 12: Further Visualization Layers

### Learning Objectives

Today we will cover several remaining layer types and examples in the grammar of graphics.

### GapMinder Data

For the final time, we’ll make use the gapminder dataset:

### Facets

A special layer type within the ggplot2 framework, facets allow us to produce many small plots for each value of a character variable. It can be added onto almost any other plot.

Notice that the scales of the axes are all the same. Sometimes this is useful, but in other cases it is useful to allow these to change. We can do this by adding the option scales="free":

There are also options scales="free_x" and scales="free_y" if you would like to only allow one axis to change.

### Scales

Another layer type are scales. These control the exact way that aesthetics are mapped to visual features. For example, we have seen that we can change the color pallet used with the viridis package:

Similarly, we can add scale_x_log10() and/or scale_y_log10() to plot values on the logarithmic scale:

There are a lot of things you can do with the scale functions by changing the default options:

I won’t quiz you on the details of these, but look back to these notes when you find ourself wanting to do something with the scales or range of the plot.

### Practice

For today’s class, we will starting working on the next project, Project B.