ggplot2:散点图

1.加载ggplot2包,读取数据及数据格式

library(ggplot2)
fpkm = read.table("all.fpkm",header=T,row.names=1)
head(fpkm,10)

2.绘图

mp = ggplot(fpkm,aes(C1_FPKM,C2_FPKM))
mp + geom_point()

3.取log10后重新作图

mp = ggplot(fpkm,aes(log10(C1_FPKM),log10(C2_FPKM)))
mp + geom_point()

4.添加直线

slope设置斜率,intercept设置截距,color设置线条颜色,size设置线条粗细

mp + geom_abline(slope=1,intercept=0,color="red",size=2) + geom_point()

ggplot2的核心思想就是图层,可以像PS一样一层层的添加图层,以加号连接,更详细参数可参考ggplot2的帮助文档http://docs.ggplot2.org/current/

视频教程:http://www.omicshare.com/class/home/index/singlev?id=34


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *