折线图-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 datatg <- ddply(ToothGrowth, c("supp", "dose"), summarise, length = mean(len))# Map supp to colourggplot(tg, aes(x = dose, y = length, colour = supp)) + geom_line()
==============
# save as :
# figure_TSS_5k_methy_level_Male_Adipose.R.pdflibrary(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) #窗口大小尺寸==============