ggplot2 (version 1.0.0)

aes_string: Generate aesthetic mappings from a string/quoted objects


Aesthetic mappings describe how variables in the data are mapped to visual properties (aesthetics) of geoms. aes uses non-standard evaluation to capture the variable names. These two variants use regular evaluation, which is easier to use inside functions.


aes_string(x = NULL, y = NULL, ...)

aes_q(x = NULL, y = NULL, ...)


List of name value pairs


aes_string and aes_q are particularly useful when writing functions that create plots because you can use strings or quoted names/calls to define the aesthetic mappings, rather than having to use substitute to generate a call to aes().

See Also


Other aesthetic generators: aes


Run this code
# Threee ways of generating the same aesthetics
aes(mpg, wt, col = cyl, fill = NULL)
aes_string("mpg", "wt", col = "cyl", fill = NULL)
aes_q(quote(mpg), quote(wt), col = quote(cyl), fill = NULL)

aes(col = cyl, fill = NULL)
aes_string(col = "cyl", fill = NULL)
aes_q(col = quote(cyl), fill = NULL)

Run the code above in your browser using DataLab