I am new to ggplot2 and have been trying to find a comprehensive list of aesthetics. I think I understand their purpose but it is hard to know which can be used in various situations (mostly geoms?). Hadley's website occasionally lists available aesthetics on pages for individual geoms and the R doc's occasionally (though more rarely) do the same. I even found a geom for which the two do not quite match.
I searched through the comments here for an answer and even bought the book! Alas, no help.
I think it would be fantastic to have a table with all the aesthetics listed in one dimension and all the geoms (and other objects?) listed in another.
Does anyone know of such a thing?
Is there a simple way (command) in R to list all the aesthetics that can be applied to an object?
Here's how a table might start:
List x y fill size colour linetype . . . geom_point Yes Yes Yes Yes Yes No geom_abline Yes Yes No Yes Yes Yes . . .
A catalog of aesthetic definitions/parameters would be a very helpful reference as well.
In ggplot2 , aesthetic means “something you can see”. Each aesthetic is a mapping between a visual cue and a variable. Examples include: position (i.e., on the x and y axes) color (“outside” color)
Aesthetic mappings “map” variables from the bound data frame to visual properties in the plot. These mappings are provided in two ways using the aes() mapping function: At the canvas level: All subsequent layers on the canvas will inherit the aesthetic mappings defined when the ggplot object was created with ggplot() .
In R, the aes() function is often used within other graphing elements to specify the desired aesthetics. The aes() function can be used in a global manner (applying to all of the graph's elements) by nesting within ggplot() .
Below is the default_aes
for each geom,
colour size linetype alpha fill weight shape width height angle hjust vjust family fontface lineheight abline black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- area yes 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- -- bar yes 0.5 1 yes grey20 1 -- -- -- -- -- -- -- -- -- bin2d yes 0.5 1 yes grey60 1 -- -- -- -- -- -- -- -- -- boxplot grey20 0.5 solid yes white 1 16 -- -- -- -- -- -- -- -- contour #3366FF 0.5 1 yes -- 1 -- -- -- -- -- -- -- -- -- crossbar black 0.5 1 yes yes -- -- -- -- -- -- -- -- -- -- density black 0.5 1 yes yes 1 -- -- -- -- -- -- -- -- -- density2d #3366FF 0.5 1 yes -- 1 -- -- -- -- -- -- -- -- -- errorbar black 0.5 1 yes -- -- -- 0.5 -- -- -- -- -- -- -- errorbarh black 0.5 1 yes -- -- -- -- 0.5 -- -- -- -- -- -- freqpoly black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- hex yes 0.5 -- yes grey50 -- -- -- -- -- -- -- -- -- -- hline black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- linerange black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- path black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- point black 2 -- yes yes -- 16 -- -- -- -- -- -- -- -- pointrange black 0.5 1 yes yes -- 16 -- -- -- -- -- -- -- -- polygon NA 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- -- quantile #3366FF 0.5 1 yes -- 1 -- -- -- -- -- -- -- -- -- raster -- -- -- yes grey20 -- -- -- -- -- -- -- -- -- -- rect yes 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- -- ribbon yes 0.5 1 yes grey20 -- -- -- -- -- -- -- -- -- -- rug black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- segment black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- smooth #3366FF 0.5 1 0.4 grey60 1 -- -- -- -- -- -- -- -- -- step black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- -- text black 5 -- yes -- -- -- -- -- 0 0.5 0.5 1 1.2 tile yes 0.1 1 yes grey20 -- -- -- -- -- -- -- -- -- -- violin grey20 0.5 solid yes white 1 -- -- -- -- -- -- -- -- -- vline black 0.5 1 yes -- -- -- -- -- -- -- -- -- -- --
and the ugly code I used to hack this,
find_aes <- function(geom="point"){ tryCatch({ Geom <- getFromNamespace(paste("Geom", ggplot2:::firstUpper(geom), sep=""), "ggplot2") tmp <- unclass(Geom$default_aes) tmp[is.na(tmp)] <- "yes" data.frame(tmp, stringsAsFactors=FALSE) }, error = function(e) {}) } funs <- grep("^geom_", ls("package:ggplot2"),val=T) geoms <- gsub("^geom_", "", funs) all <- lapply(geoms, find_aes) names(all) <- geoms relevant <- sapply(all, function(x) !is.null(x) && nrow(x) > 0) library(plyr) results = do.call("rbind.fill",all) rownames(results) <- names(relevant[relevant]) results[is.na(results)] <- "--" options(width=9999) capture.output(print(results), file="aes.txt")
Have a look to Aesthetic specifications's vignette, by Hadley Wickham:
This vignette summarises the various formats that grid drawing functions take. Most of this information is available scattered throughout the R documentation. This appendix brings it all together in one place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With