屏幕图效果很好,但pdf版本丢失了'mtext' "incidence (%)"
# data
hgf <- c(394,441,592,559,455,542,583,548,636,709)
incfor <- c(11.2,13.0,13.5,12.0,7.8,8.0,8.4,8.4,8.8,9.5)
par(mar=c(5,4,4,5)+.1)
index <- 1:10
period <- c("9801","9902","0003","0104","0205", "0306",
"0407","0508","0609","0710")
屏幕图
bp <- barplot(hgf, ylim=c(0,800),cex.axis=1.0,yaxt="n")
axis(2, at=seq(0,800,200))
axis(1, at=bp,labels=period,cex.axis=1.0,las=2 )
par(new=TRUE)
plot(bp,incfor,type="l",col="blue",
cex.axis=1.0,cex.lab=1.0,
xaxt="n",yaxt="n",xlab="period",ylab="",ylim=c(0,16),lwd=2)
par(cex.axis=1.0)
axis(4, at=seq(0,16,2))
mtext("incidence % (line, rhs)",side=4,line=2,cex=1.0)
mtext("number (bar, lhs)",side=2,line=2,cex=1.0)
grid(nx=NULL,col="black")
pdf版
par(mar=c(5,4,4,5)+.1)
pdf(file="fig_hgf_for.pdf",
useDingbats=F)
bp <- barplot(hgf, ylim=c(0,800),cex.axis=1.0,yaxt="n")
axis(2, at=seq(0,800,200))
axis(1, at=bp,labels=period,cex.axis=1.0,las=2 )
par(new=TRUE)
plot(bp,incfor,type="l",col="blue",
cex.axis=1.0,cex.lab=1.0,
xaxt="n",yaxt="n",xlab="period",ylab="",ylim=c(0,16),lwd=2)
par(cex.axis=1.0)
axis(4, at=seq(0,16,2))
mtext("incidence % (line, rhs)",
side=4,line=2,cex=1)
mtext("number (bar, lhs)",side=2,line=2,cex=1)
grid(nx=NULL,col="black")
dev.off()
答案 0 :(得分:2)
pdf()
会设置默认par
设置的新设备,从而取消之前的par(mar=...)
电话。
底线:在par(mar=...)
之后运行pdf(...)
,看起来不错。