Grammar under the ggplot

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





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值