Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Define aesthetic mappings programmatically

Source:R/aes.R
aes_.Rd

[Deprecated]

Aesthetic mappings describe how variables in the data are mapped to visualproperties (aesthetics) of geoms.aes() uses non-standardevaluation to capture the variable names.aes_() andaes_string()require you to explicitly quote the inputs either with"" foraes_string(), or withquote or~ foraes_().(aes_q() is an alias toaes_()). This makesaes_() andaes_string() easy to program with.

aes_string() andaes_() are particularly useful when writingfunctions that create plots because you can use strings or quotednames/calls to define the aesthetic mappings, rather than having to usesubstitute() to generate a call toaes().

I recommend usingaes_(), because creating the equivalents ofaes(colour = "my colour") oraes(x = `X$1`)withaes_string() is quite clunky.

Usage

aes_(x,y,...)aes_string(x,y,...)aes_q(x,y,...)

Arguments

x, y, ...

List of name value pairs. Elements must be eitherquoted calls, strings, one-sided formulas or constants.

Life cycle

All these functions are deprecated. Please use tidy evaluation idiomsinstead. Regardingaes_string(), you can replace it with.data pronoun.For example, the following code can achieve the same mapping asaes_string(x_var, y_var).

x_var<-"foo"y_var<-"bar"aes(.data[[x_var]],.data[[y_var]])

For more details, please seevignette("ggplot2-in-packages").

See also

aes()


[8]ページ先頭

©2009-2026 Movatter.jp