R:如何在图中删除这个微小的轴边距
R: how to remove this tiny axis margin in plot
我想去掉 X 和 Y 值上接近于零的小边距(图片上的红线),只绘制红色方块中显示的内容。
我尝试设置 par(mar = rep(0, 4)
和 xlim=c(0, ...)
、ylim=c(0, ...)
,但 R 仍然不断添加这个微小的边距。如何摆脱它?
编辑:
关于我的问题的另一种观点:
在 运行 之后:
require(plotrix)
axisRange <- c(0,500)
plot(NULL, xlim = axisRange, ylim=axisRange)
draw.circle(0, 0, 200, col = "white", border = "red")
我最终得到一个不在 "true" 0,0 点的圆圈:
编辑2:
实际上我想做的是绘制不同半径的圆,并将其保存为图像。这就是为什么我关心边距。
我最终得到了这样的结果(角落上的斑点供参考):
而且应该更像这样:
您可以将 xaxs
和 yaxs
参数设置为 "i" 而不是默认值 "r"。来自 par
帮助页面:
Style "r" (regular) first extends the data range by 4 percent at each
end and then finds an axis with pretty labels that fits within the
extended range.
Style "i" (internal) just finds an axis with pretty labels that fits
within the original data range.
library(plotrix)
axisRange <- c(0,500)
par(mar = rep(0,4))
plot(NULL, xlim = axisRange, ylim=axisRange, xaxs = "i", yaxs = "i")
draw.circle(0, 0, 200, col = "white", border = "red")
给出:
我想去掉 X 和 Y 值上接近于零的小边距(图片上的红线),只绘制红色方块中显示的内容。
我尝试设置 par(mar = rep(0, 4)
和 xlim=c(0, ...)
、ylim=c(0, ...)
,但 R 仍然不断添加这个微小的边距。如何摆脱它?
编辑: 关于我的问题的另一种观点: 在 运行 之后:
require(plotrix)
axisRange <- c(0,500)
plot(NULL, xlim = axisRange, ylim=axisRange)
draw.circle(0, 0, 200, col = "white", border = "red")
我最终得到一个不在 "true" 0,0 点的圆圈:
编辑2: 实际上我想做的是绘制不同半径的圆,并将其保存为图像。这就是为什么我关心边距。 我最终得到了这样的结果(角落上的斑点供参考):
而且应该更像这样:
您可以将 xaxs
和 yaxs
参数设置为 "i" 而不是默认值 "r"。来自 par
帮助页面:
Style "r" (regular) first extends the data range by 4 percent at each end and then finds an axis with pretty labels that fits within the extended range.
Style "i" (internal) just finds an axis with pretty labels that fits within the original data range.
library(plotrix)
axisRange <- c(0,500)
par(mar = rep(0,4))
plot(NULL, xlim = axisRange, ylim=axisRange, xaxs = "i", yaxs = "i")
draw.circle(0, 0, 200, col = "white", border = "red")
给出: