R绘图系统11.docx
- 文档编号:6187605
- 上传时间:2023-01-04
- 格式:DOCX
- 页数:8
- 大小:61.45KB
R绘图系统11.docx
《R绘图系统11.docx》由会员分享,可在线阅读,更多相关《R绘图系统11.docx(8页珍藏版)》请在冰豆网上搜索。
R绘图系统11
11.1
library(gplots)
par(mar=rep(1,4))
par(mfrow=c(1,2))
plot(faithful)
textplot(capture.output(summary(faithful)))
11.2
library(plotrix)
par(mar=rep(1,4))
plot(pressure)
addtable2plot(0,300,pressure[13:
19,])
11.3
library(gridExtra)
grid.table(pressure[13:
19,],show.box=TRUE,
separator="black")
11.4
library(plotrix)
library(Hmisc)
par(mar=rep(1,4))
x<-rnorm(20)
y<-rnorm(20)
plot(x,y,pch=16,col="gray")
xy<-emptyspace(x,y)
text(xy,label="largest\nempty\nregion")
xy2<-largest.empty(x,y,1,1)
rect(xy2$x-.5,xy2$y-.5,
xy2$x+.5,xy2$y+.5)
11.5
x<-runif(10)
y<-rnorm(10)
library(plotrix)
library(TeachingDemos)
library(maptools)
library(Hmisc)
par(mar=c(1,1,2,1))
plot(x,y,pch=21,bg="gray",ylim=c(-3,3),asp=1)
spread.labels(x,y,labels=1:
10)
mtext("spread.labels",side=3,line=0)
par(mar=c(1,1,2,1))
plot(x,y,pch=21,bg="gray",
ylim=c(-2,3),xlim=c(-.5,1.5))
thigmophobe.labels(x,y,labels=1:
10)
mtext("thigmophobe.labels",side=3,line=0)
par(mar=c(1,1,2,1))
plot(x,y,pch=21,bg="gray",ylim=c(-3,3),asp=1)
adjy<-spread.labs(y,strheight("10",cex=1.5))
text(-0.5,adjy,labels=1:
10,pos=2)
segments(-0.5,adjy,x,y)
mtext("spread.labs",side=3,line=0)
par(mar=c(1,1,2,1))
plot(x,y,pch=16,col="gray",ylim=c(-2,3),xlim=c(-.5,1.5))
pointLabel(x,y,labels=as.character(1:
10))
mtext("pointLabel",side=3,line=0)
par(mar=c(1,1,2,1))
sx<-sort(x)
sy<-sort(y)
lines<-list(A=list(x=sx,y=y,lty=1),
B=list(x=sx,y=sy,lty=2),
C=list(x=sx,y=rev(y),lty=3),
D=list(x=sx,y=rev(sy),lty=4))
plot(x,y,type="n",ylim=c(-3,3))
lapply(lines,function(l)do.call("lines",l))
labcurve(lines)
mtext("labcurve",side=3,line=0)
11.6
library(plotrix)
library(TeachingDemos)
par(mar=rep(0,4))
plot.new()
plot.window(0:
1,c(.1,1))
draw.circle(.1,.9,radius=1:
5/100)
draw.arc(.3,.9,radius=1:
5/100,
deg1=45,deg2=seq(360,160,-50))
arctext("arctext",center=c(.5,.85),radius=.05,
stretch=1.2)
text(.1,.8,"draw.circle")
text(.3,.8,"draw.arc")
boxed.labels(.7,.85,"boxed.labels",bg="gray90")
textbox(c(.85,1),.9,"thisisatextbox.")
gradient.rect(.05,.5,.15,.7,col=gray(0:
20/21))
cylindrect(.25,.5,.35,.7,"black")
rectFill(.45,.5,.55,.7,pch=16)
text(.1,.45,"gradient.rect")
text(.3,.45,"cylindrect")
text(.5,.45,"rectFill")
x<-c(.65,.65,.75,.75)
y<-c(.5,.7,.7,.5)
polygon.shadow(x,y,offset=c(2/100,-2/100))
polygon(x,y,col="white")
text(.7,.45,"polygon.shadow")
shadowtext(.9,.6,"shadowtext")
my.symbols(seq(.3,.7,.2),.3,
ms.male,inches=.2)
my.symbols(c(.4,.6),.3,
ms.female,inches=.2)
text(.5,.2,"my.symbols")
box(col="gray")
11.7
library(gridExtra)
grid.ellipse(x=1:
6/7,y=rep(.8,6),size=.1,
default.units="npc",size.unit="npc",
ar=1:
6,angle=1:
6*15/180*pi)
grid.text("grid.ellipse",y=.7)
grid.pattern(x=1:
6/7,y=.5,width=unit(.1,"npc"),
height=unit(.1,"npc"),pattern=1:
6,
motif.cex=.7,gp=gpar(fill="gray80"))
grid.text("grid.pattern",y=.4)
grid.barbed(1:
6/7,y=rep(c(.15,.25),3),
size=unit(.05,"snpc"),
pch=21,gp=gpar(fill="gray"))
grid.text("grid.barbed",y=.1)
grid.rect(gp=gpar(col="gray",fill=NA))
11.8
library(gplots)
plotmeans(mpg~cyl,mtcars,
barcol="black",n.label=FALSE,connect=FALSE)
11.9
library(colorspace)
grid.rect(1:
10/11,.75,width=1/15,height=1/3,
gp=gpar(col=NA,
fill=sequential_hcl(10,0,0,c(20,90))))
grid.rect(1:
10/11,.25,width=1/15,height=1/3,
gp=gpar(col=NA,
fill=diverge_hcl(10,0,0,c(20,90))))
grid.rect(gp=gpar(col="gray",fill=NA))
11.10
library(gplots)
par(mar=rep(1,4))
plot(rnorm(100),rnorm(100),pch=16,col="gray",
ann=FALSE,axes=FALSE)
box()
corner.label("top-left",x=-1,y=1)
smartlegend(x="right",y="top",
legend="top-right",pch=16,
col="gray",bg="white")
text(grconvertX(1,"npc"),grconvertY(0,"npc"),
adj=c(1,0),labels="bottom-right")
11.11
library(TeachingDemos)
plot(window(Nile,1920,1940))
subplot({plot(Nile,axes=FALSE,ann=FALSE)
rect(1920,0,1940,2000,border=NA,col="gray")
box()
lines(Nile)},
x=1920,y=1000,size=c(1.5,.75),hadj=0)
11.12
kelvin<-pressure$temperature+273.15
library(plotrix)
with(pressure,
{
plot(temperature,pressure,axes=FALSE)
axis
(2)
box()
staxlab(1,at=temperature,cex=.7)
})
with(pressure,
{
plot(kelvin,pressure,xlim=c(250,650))
axis.break
(1)
})
11.13
kelvin<-pressure$temperature+273.15
library(plotrix)
library(TeachingDemos)
with(pressure,
revaxis(temperature,pressure))
plot(kelvin,pressure$pressure)
updateusr(c(0,1),0:
1,c(-273.15,-272.15),0:
1)
abline(v=100)
text(x=100,y=700,"waterboils",adj=0)
pdf("Figures/extra-zoomplot-%d.pdf",onefile=FALSE,
width=4,height=4)
dev.control("enable")
plot(pressure)
zoomplot(c(0,150),c(0,3))
dev.off()
png("Web/extra-zoomplot%d.png",width=320,height=320)
dev.control("enable")
plot(pressure)
zoomplot(c(0,150),c(0,3))
dev.off()
system("cpWeb/extra-zoomplot2.pngWeb/extra-axisscale3.png")
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 绘图 系统 11
![提示](https://static.bdocx.com/images/bang_tan.gif)