...

/

Aesthetics and Annotation in ggplot2

Aesthetics and Annotation in ggplot2

Understand how to use different annotations in ggplot2 for adding details to plots, both inside and outside the aesthetics.

What’s more in aesthetics?

The aesthetics in ggplot2 are not limited to what we have discussed (color, fill, point shapes, alpha, etc.) in the previous lesson. Let’s look at what else ggplot2 offers for aesthetics.

For example, we can introduce textures in our graphs using a supporting package called ggpattern. These are optional aesthetics that can improve the visual appearance of any data visualization.

Press + to interact
Adding textures to ggplot2
Adding textures to ggplot2

We’ll cover some well-known ggplot2 supporting packages in this lesson. However, it is challenging to cover all such libraries in a single course.

Ultimately, it depends on the project requirements. It is important to understand what data is to be plotted and how we perceive the plot to look.

That being said, the collection of R libraries on CRAN boasts of several packages that you should be able to use on your own to extend the ggplot2 functionality after completing this course.

Recapping the basics of aesthetics

The aes() function in ggplot2 is used along with other grammar of graphics elements to define the required aesthetics. This aes() function can be used either in a nested format, i.e., in a global manner (applies to the entire graph) or in an individual layer. To generate specific graph elements, the aes() function is nested in specific geom functions such as geom_point(), geom_line(), etc. In short, we can remember this by thinking of it as inside and outside the aes() function.

Inside aes()

...