ggplot ggplot2 画图

 

折线图-ggplot2 
http://blog.163.com/yugao1986@126/blog/static/6922850820131161531421/
http://blog.sina.com.cn/s/blog_7cffd1400101f50v.html

《R Graphics Cookbook-By Winston Chang》

#======================
折线图
library(ggplot2)  #作图
library(gcookbook)  #案例数据
library(plyr)  #ddply()、desc()等函数
# In addition to the variables mapped to the x- and y-axes, map another
# (discrete) variable to colour or linetype Load plyr so we can use ddply()
# to create the example data set Summarize the ToothGrowth data
tg <- ddply(ToothGrowth, c("supp", "dose"), summarise, length = mean(len))
# Map supp to colour
ggplot(tg, aes(x = dose, y = length, colour = supp)) + geom_line()

 

==============

# save as :
# figure_TSS_5k_methy_level_Male_Adipose.R.pdf


library(ggplot2)  #作图
setwd("E:\\_data\\")
group<-rep("xxxx",200)
window_index<-rep(1,200)
methy<-rep(0.0001,200)

inputfile_name=paste0("level.average")  
mydata <- read.table(inputfile_name, header=FALSE)
for(ii in 1:100)
{
  group[ii]<-"MAL"
  window_index[ii]<-ii
  methy[ii]<-mydata[1,ii]
}


inputfile_name=paste0(".level.average")  
mydata <- read.table(inputfile_name, header=FALSE)
for(ii in 1:100)
{
  group[ii+100]<-"MAC"
  window_index[ii+100]<-ii
  methy[ii+100]<-mydata[1,ii]
}
   
mydata<-data.frame(group=group,window_index=window_index,methy=methy)

ggplot(mydata, aes(x = window_index, y =methy , colour = group)) + geom_line()

==============
dev.new(width=5, height=4)  #窗口大小尺寸

==============

 http://docs.ggplot2.org/current/

posted @ 2014-10-02 08:30  emanlee  阅读(854)  评论(0编辑  收藏  举报