Ggplot2

How to define aesthetic mappings of ggplot2 within another function

ggplot2 is great for visualization, but sometimes we need to include ggplot2 functions within another function. ggplot() uses aes() to define aesthetic mappings of different variables. The question is: how to define aesthetic mappings when writing functions using ggplot()? In this post I will present several approaches. First of all, let’s load the required packages and some test data. library(ggplot2) library(dplyr) data("mtcars") Using aes_string() There are two standard ways to define aesthetic mappings in ggplot2,
2020-03-28
1 min read