1. Mapping aesthetics to data
e.g. scatterplot: each point has a size, a color, and a shape. these attributes are called aesthetics,
each aesthetic can be mapped to a varibale or set to a constant value.
once we have these mappings we create a new dataset that records this information.
geom: determines the "type" of the plot.
scaling:
convert from data units(litres, mpg, number of cylinders...) to physical unit(e.g. pixels, colors) that the computer can display.
this is called scaling and performed by scales.
scaling occur in 3 parts, transforming, training and mapping.
Components of the layered grammar
data
aesthetic mappings
geometric objects
stats
scales
faceting
position
the layered grammar defines a plot as the combination of:
1) a default dataset and set of mappings from variable to aesthetics
2) one or more layers, each composed of a geometric object, a statistical transformation, and
a position adjustment, and optionally, a dataset and aesthetic mappings.
3) one scale for each aesthetic mapping
4) a coordinate system
5) faceting specification
1) layer: composed of a geometric object, a statistical transformation, and a position adjustment, and optionally, a dataset and aesthetic mappings.
2) scales: control the mapping from data to aesthetic attributes, need a scale for each aesthetic on the plot
a scale is a function, and its inverse function
3) coordinate system: map the position of objects onto the plane of the plot.
4) faceting:
Data structures:
a plot object is a list with: data\mapping\layers\scales\coordinates\facet
function which can use on a plot object:
print()
ggsave(): save a picture(png)
summary(): describe its structure
save(): save a copy to the disk. save a complete copy of plot object
load() : load saved copy