我有以下
xaxis <- seq(0,1,by=0.01)
aij <- sqrt(1 - (1-xaxis)**1.02)
bij <- 1 - (1 - xaxis)**1.50
cij<-aij-bij
pdf("MyPdf.pdf",family="Times New Roman")
par(mfrow=c(1, 1), mar=c(5, 5, 4, 10))
plot(xaxis,aij,type="l", col="black",lty=1, xlab="Size ratio", ylab="Value of function")
lines(xaxis,bij,type="l",col="black",lty=2)
par(new=TRUE)
plot(xaxis,cij,,type="l",col="black",lty=4,xaxt="n",yaxt="n",xlab="",ylab="")
grid(nx = 10, ny = 10)
axis(4)
mtext("Difference", side=4,line=3)
legend(x='bottomright',col=c("black","black"), lty=c(1,2,3), legend=c("aij","bij","Difference"),inset=c(-0.25,0))
dev.off()
我无法理解以下内容:
bottomright
我希望有一个个人选择的位置) - 坐标系的单位是什么?它的方向是什么? 答案 0 :(得分:0)
这说明了如何使用&#34; user-coordinates&#34;将图例移动到绘图坐标系中的特定位置。请参阅?par
了解如何为“text.font”提供正确的价值。在?legend
函数中。我的pdf设备只有一个&#34; Times&#34;字体,所以我无法告诉你如何使用你描述的命名字体。您可以使用以下命令查看当前可用的pdf字体的有效名称:
names(pdfFonts())
pdf("MyPdf.pdf", family="Times")
par(mfrow=c(1, 1), mar=c(5, 5, 4, 10))
plot(xaxis,aij,type="l", col="black",lty=1, xlab="Size ratio", ylab="Value of function")
lines(xaxis,bij,type="l",col="black",lty=2)
par(new=TRUE)
plot(xaxis,cij,,type="l",col="black",lty=4,xaxt="n",yaxt="n",xlab="",ylab="")
grid(nx = 10, ny = 10)
axis(4)
mtext("Difference", side=4,line=3)
legend(x=0.2,y=0.02, col=c("black","black"), lty=c(1,2,3), legend=c("aij","bij","Difference"), text.font=2 )
dev.off()