ggplot2 II 图层 ·数据 data 一组图形属性映射 mapping ·几何对象 geom ·统计变换 ● stat 位置调整 position 数据必须是数据框 aes() 默认参数 参数设定 layer()
• හഝ • Ӟᕟࢶં୵ฉ ֜پ • • ᕹᦇݒഘ • ֖ᗝ᧣ෆ ggplot2 II 图层 ἕᦊ݇හ ݇හᦡਧ • data • mapping • geom • stat • position හഝᶳฎහഝ aes() layer()
ggplot2Ⅱ ggplot() ggplot(data NULL, mapping aes(, layer() 自己查帮助 environment parent.frame() p<-ggplot(diamondas, aes(carat, 15000 price, cut colour cut), 。Fair ●Good 10000 p ●Very Good ●Premium ●Ideal p <-p layer(geom ="point", 5000 stat "identity", position ="identity" 2 carat p
ggplot(data = NULL, mapping = aes(), …, environment = parent.frame()) p <- ggplot(diamondas, aes(carat, price, colour = cut), ) p p <- p + layer(geom = “point", stat = "identity", position = "identity" ) p layer() ᛔ૩ັଆۗ ggplot2 II ggplot()
ggplot2 II geom_xxx() geom(mapping NULL, geom_point() data NULL, geom_line() stat=“identity” geom_path() position=“identity'” geom_bar() geom_histogram() 。。· na.rm FALSE. geom_smooth() show.legend NA, geom_density() inherit.aes TRUE geom_jitter() geom_text() geom_hline() geom_vline() geom_blank() 见教材ggplot2的58页 geom_area() geom_abline()
geom(mapping = NULL, data = NULL, stat = “identity” position = “identity” …, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) geom_point() geom_line() geom_path() geom_bar() geom_histogram() geom_smooth() geom_density() geom_jitter() geom_text() geom_hline() geom_vline() geom_blank() geom_area() geom_abline() … ᥠරggplot2ጱ58ᶭ ggplot2 II geom_xxx()
ggplot2 II stat_xxx() stat(mapping NULL, stat_identity() data NULL, stat_smooth() geom/stat =543 stat_function() position=“identity” stat_boxplot() stat_density() na.rm FALSE. stat_quantile() show.legend NA, stat_sum() inherit.aes TRUE stat_summary() stat_unique() stat_bin() stat_bindot() 见教材ggplot22的60页
stat(mapping = NULL, data = NULL, geom/stat = “” position = “identity” …, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) stat_identity() stat_smooth() stat_function() stat_boxplot() stat_density() stat_quantile() stat_sum() stat_summary() stat_unique() stat_bin() stat_bindot() … ᥠරggplot2ጱ60ᶭ ggplot2 II stat_xxx()
ggplot.21Ⅱ layer()和geom-xxx() p <-ggplot(diamonds,aes(x carat)) p <-ggplot(diamonds, p<-p+layer( aes(x carat)) geom "bar", p<-p geom_histogram(bins =30, stat "bin", fill "steelblue") position "identity", p params list(fill ="steelblue") p 15000 10000 5000 carat
p <- ggplot(diamonds, aes(x = carat)) p <- p + layer( geom = "bar", stat = "bin", position = "identity", params = list(fill = "steelblue") ) p p <- ggplot(diamonds, aes(x = carat)) p <- p + geom_histogram(bins = 30, fill = "steelblue") p ggplot2 II layer()和geom_xxx()