首页 > 代码库 > par函数的adj 参数- 控制文字的对齐方式

par函数的adj 参数- 控制文字的对齐方式

adj 用来控制文字的对齐方式,取值范围为0到1,控制图片中x轴和y轴标签,标题,以及通过text 添加的文字的对齐方式

0表示左对齐,代码示例:

par(adj = 0)
plot(1:5, 1:5, type = "n", main = "title", xlab = "x", ylab = "y")
abline(h = 3, lty = 2)
abline(v = 3, lty = 2)
text(x = 3, y= 3, label = "text", cex = 2)

效果图如下:

技术分享

0.5为默认值,表示居中对齐,代码示例:

par(adj = 0.5)
plot(1:5, 1:5, type = "n", main = "title", xlab = "x", ylab = "y")
abline(h = 3, lty = 2)
abline(v = 3, lty = 2)
text(x = 3, y= 3, label = "text", cex = 2)

效果图如下:

技术分享

1代表右对齐,代码示例:

par(adj = 1)
plot(1:5, 1:5, type = "n", main = "title", xlab = "x", ylab = "y")
abline(h = 3, lty = 2)
abline(v = 3, lty = 2)
text(x = 3, y= 3, label = "text", cex = 2)

效果图如下:

技术分享

 

par函数的adj 参数- 控制文字的对齐方式