- plot
- plot(c(1,2,3),c(1,2,4)) # draw 3 points (1,1) (2,2) (3,4)
- plot(c(-3,3),c(-1,5),type="n") # draw a blank canvas, only axis no content
- x<-c(1,2,3)
- y<-c(1,3,8)
- plot(x,y)
- lmout<-lm(y~x) # linear regression
- abline(lmout) # draw line
- lines(c(1.5,2.5),c(3,3)) # draw line with 2 points
- plot(x,y,type="l") # draw broken line
- hist(x)
- x11() # pop a window on linux
- hist(y) # draw y hist on new window
- d1=density(testscores$Exam1,from=0,to=100)
- d2=density(testscores$Exam2,from=0,to=100)
- plot(d1,main="",xlab="")
- lines(d2)
- points(testscores$Exam1,testscores$Exam3,pch="+") # mark point with +
- par(bg="yellow") # yellow background
- text(2.5,4,"abc") # place text on axis(2.5,4)
- hist(c(12,5,13,25,16))
- locator(1) # give the exact axis on hist diagram once
- text(locator(1),"nv=75") # place the text on locator 1's position on diagram
- text(2.5,4,"abc",cex=1.5) # 1.5 times bigger than normal's
- f<-function(x) return(1-exp(-x))
- curve(f,0,2) # draw curve, x starts from 0.2, else from 0 by default
- polygon(c(1.2,1.4,1.4,1.2),c(0,0,f(1.3),f(1.3)),col="gray") # x of 1.2 1.4 1.4 1.2
- plot(testscores)
- lines(lowess(testscores)) # smooth
- curve((x^2+1)^0.5,0.5,add=T) # draw curve on current canvas
- pdf("d12.pdf')
- dev.list() # show devices
- dev.cur()
- pdf 3
- dev.off()
R语言学习笔记11-绘图篇
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...