R璇█鐢诲睍ggplot2绡?鎬昏
Posted 鍠勬€濊€?/a> R璇█
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了R璇█鐢诲睍ggplot2绡?鎬昏相关的知识,希望对你有一定的参考价值。
馃憜 鐐瑰嚮钃濆瓧灏卞彲浠ュ叧娉?span>"鍠勬€濊€?鍝~
锛?/span>鍡▇~浠婂ぉ鎴戜滑浠嬬粛R璇█鐨勫ぇ绁炵骇鍒玆鍖呪€斺€斺€済gplot2鈥濓紒
ggplot2鐨勫ぇ鍚嶅彲璋撴槸濡傞浄璐€筹紝鏈変竴閮ㄥ垎浜烘槸閫氳繃ggplot2鎵嶇煡閬揜璇█銆?/span>
Hadley Wickham
杩欎釜钁楀悕鐨勪綔鍥惧寘鐢卞ぇ绁濰adley Wickham浜?005骞村紑鍙戯紝鑷充粖宸叉湁15骞寸殑鍘嗗彶銆?/span>
鐩告瘮杈冧簬R鑷甫鐨勪綔鍥剧郴缁熶笌鍏朵粬浣滃浘鍖咃紝ggplot2鏇寸伒娲伙紝骞朵笖灏嗕綔鍥剧殑杩囩▼璇硶鍖栥€佸眰娆″寲锛屽缓绔嬭捣浜嗕竴濂楃ǔ瀹氭垚鐔熺殑浣滃浘浣撶郴銆?/span>
鍙鐗㈣ggplot2鍑犱釜璇硶瑕佺礌锛屽氨鍙互鐢诲嚭浠讳綍浣犳兂瑕佺殑鍥剧墖銆?/span>
ggplot2鏄潪甯稿€煎緱鎶曞叆鏃堕棿瀛︿範鐨勶紝鍥犱负闀挎湡鍥炴姤闈炲父鍙銆?/span>
鍦ㄨ繖绡囨€昏閲岋紝鎴戜滑浼氫粙缁峠gplot2鐨勫熀鏈綔鍥捐绱犮€?/span>
鍦ㄦ湭鏉ョ殑绔犺妭閲岋紝浼氭繁鍏ヤ粙缁嶅叿浣撶殑浣滃浘鏂规硶銆?/span>
鍦╣gplot2鐨勪笘鐣岄噷锛屾墍鏈夊浘鐗囩敱6涓绱犵粍鎴愶細
1. 鏁版嵁锛圖ata锛?/span>銆?/span>
2. 灞傛锛圠ayers锛?/strong>锛屽寘鍚袱绉嶅厓绱狅細鍑犱綍鍏冪礌锛圙eometrics锛変笌缁熻杞崲锛圫tatistical transformations锛夈€?/span>
鍑犱綍鍏冪礌鎸囩殑鏄綘鎯崇敾鐨勫浘褰紝濡傜偣锛岀嚎锛屾垨澶氳竟褰㈢瓑銆?/span>
缁熻杞崲鎸囩殑鏄綘鎯崇敾鐨勭粺璁℃弿杩帮紝濡傚潎鏁帮紝鏍囧噯宸垨鍙俊鍖洪棿绛夈€?/span>
3. 鍒诲害锛圫cales锛?/strong>, 閫氬父鎸囧嚑浣曞厓绱狅紙濡傜偣鎴栬€呯嚎锛夌殑澶у皬锛岄鑹插拰褰㈢姸绛夈€?/span>
4. 鍧愭爣绯荤粺锛圓 coordinate system锛?/strong>, 閫氬父鎸囩殑鏄痻杞翠笌y杞淬€?/span>
5. 澶氶潰鍖栵紙Faceting锛?/strong>锛岀畝鍗曠殑璇达紝灏辨槸鍙互灏嗕竴涓浘鐗囧垎鎴愬涓皬鐨勪簹鍥剧墖銆?/span>
6. 涓婚 锛圱heme锛?/strong>锛屾瑕佺礌鍙互鎺у埗闈炴暟鎹笌闈炵粺璁¢儴鍒嗙殑鍐呭锛屽鑳屾櫙棰滆壊锛屽瓧浣撳ぇ灏忕瓑銆?/span>
灏忓杽鍦ㄨ繖閲屽缓璁ぇ瀹跺皢涓婅堪鐨勫叚鐐圭墷璁板湪蹇冿紝鏈€濂借兘鑳屽嚭鏉ャ€傚湪鏈潵鐨勪綔鍥句腑锛屾墍鏈夊浘鐗囬兘閫冧笉鍑轰互涓婂叚鐐广€?/span>
鎺ヤ笅鏉ヤ妇涓€涓畝鍗曠殑渚嬪瓙锛屽皢涓婅堪鍏鐐逛互涓€涓矞娲荤殑渚嬪瓙鍛堢幇鍑烘潵锛屼互鍔╀簬澶у鐞嗚В锛?/span>
锛?鍚庨潰璺熼殢鐨勮〃绀烘敞閲婏紝R涓嶄細杩愯浠栦滑锛?/span>
#瀹夎ggplot2锛屽苟涓旇浇鍏?/span>
install.packages("ggplot2")
library(ggplot2)
#浣跨敤mtcars鏁版嵁鍋氫竴涓暎鐐瑰浘
ggplot(data = mtcars, # 瑕佺礌1锛氭暟鎹?/span>
aes(x = wt, y = mpg,
colour = factor(cyl))) + # 瑕佺礌2锛氬埢搴?/span>
geom_point() + # 瑕佺礌3锛氬嚑浣曞厓绱狅紙鐐癸級
coord_cartesian() + # 瑕佺礌4锛氬潗鏍囪酱
facet_wrap(~ cyl) + # 瑕佺礌5锛氬垎闈㈠寲
theme_bw() # 瑕佺礌6锛氫富棰?/span>
閫氳繃涓婅堪鐨勪唬鐮佷互鍙婃敞閲婏紝澶у瀵逛簬ggplot2鐨勫叚鐐硅绱犲簲璇ユ湁浜嗗熀鏈殑姒傚康銆?br class="mq-126">
涓婅堪鐨勫嚑琛屼唬鐮侀渶鐗㈣銆?/span>
鍦ㄦ湭鏉ョ殑浣滃浘涓紝鎵€鏈変綔鍥鹃兘浼氬洿缁曚互涓婂叚鐐癸紝閫氳繃瀵逛互涓婂叚鐐圭殑澧炲鍑忓噺锛屽氨鍙互婕斿彉鍑烘棤鏁扮編涓界殑鍥剧墖锛?/span>
浠婂ぉ鍒版涓烘锛屾暚璇锋湡寰呮洿澶氱簿褰╁唴瀹广€?br>
甯屾湜鍠滄锛岃鐐硅禐杞彂鍏虫敞鍝︺€?/span>
- End -
鎵弿浜岀淮鐮佹洿绮惧僵
鈥滃杽鎬濊€?/span>鈥斺€?nbsp;璁╀复搴婄鐮斾笌缁熻鍙樺緱绠€鍗曪紒鈥?/span>
寰€鏈熺簿褰╁洖椤?/p>
鐐瑰嚮鈥滃湪鐪嬧€濓紝澶氭牴澶村彂锛?/span>
以上是关于R璇█鐢诲睍ggplot2绡?鎬昏的主要内容,如果未能解决你的问题,请参考以下文章