1、參數(shù)alpha越小,越透明,fill=NA,完全透明,只有邊框
2、參數(shù)position:
="identity":不調(diào)整----geom_identity
=“dodge”:平行放置----geom_dodge
=“fill”:總高度一樣高---geom_dodge
散點(diǎn)圖:position="jitter":適用于少量數(shù)據(jù),每個(gè)點(diǎn)增加少量隨機(jī)變化,不會(huì)讓點(diǎn)之間相互覆蓋,如果覆蓋,畫(huà)圖就會(huì)少很多點(diǎn)--geom_jitter
position="stack",一個(gè)圖在另一個(gè)圖上面,geom_stack
geom_jitter與 geom_count的區(qū)別,后者會(huì)根據(jù)覆蓋的點(diǎn)的多少形成不一樣大的散點(diǎn),會(huì)有標(biāo)簽說(shuō)明,如下ggplot(data = mpg, mapping = aes(x = cty, y = hwy))+ geom_count()

3、坐標(biāo)系
默認(rèn)坐標(biāo)系為直角坐標(biāo)系
coord_flip()轉(zhuǎn)化x,y坐標(biāo)系,比如x標(biāo)簽比較長(zhǎng)的時(shí)候可以用
箱線圖,橫坐標(biāo)為分類(lèi)變量,縱坐標(biāo)為數(shù)值變量
ggplot(data = mpg, mapping = aes(x = class, y = hwy)) +
? geom_boxplot()+
? coord_flip()

但是如果直接將分類(lèi)變量放在縱坐標(biāo),箱線圖會(huì)出錯(cuò),因?yàn)闄M坐標(biāo)的數(shù)值是橫向的,沒(méi)有縱向的分布
ggplot(data = mpg, mapping = aes(y = class, x = hwy)) +
? geom_boxplot()

coord_quickmap()會(huì)將圖自動(dòng)設(shè)置為地圖比例(橫縱坐標(biāo)比例相同)(coord_quickmap的計(jì)算量會(huì)比coord_map的少很多
需要的包“maps",數(shù)據(jù)轉(zhuǎn)化函數(shù)map_data()
coord_polar()將條形圖與扇形圖做轉(zhuǎn)換
bar <- ggplot(data = diamonds) +
? geom_bar(
? ? mapping = aes(x = cut, fill = cut),
? ? show.legend = FALSE,
? ? width=1#默認(rèn)width=0.9,相鄰條塊之間有空隙,如果設(shè)置為1,每個(gè)條塊是挨在一起的
? ) +
? theme(aspect.ratio = 1) +#畫(huà)圖面板的長(zhǎng)寬比
? labs(x = NULL, y = NULL)
bar + coord_polar()

4、圖層
ggplot2畫(huà)圖一般由7部分組成:a dataset, a geom, a set of mappings, a stat(stat_count,stat_summary??), a position adjustment, a coordinate system, and a faceting scheme,有時(shí)候有些部分會(huì)缺省,使用默認(rèn)值,比如坐標(biāo)系。