在下图中,您可能会发现x-aixs与日期(Jan-01-60至Mar-31-16)之间的距离很大。
无论如何我可以缩小距离吗?
这是我的示例代码:
plot(dates, data, type = "l", lwd = 3, ylab = " ",
xlab = " ", col = "gray35", xaxt='n', ann = FALSE)
axis(side=1, at=dates_ten, labels=format(dates_ten, "%b-%d-%y"), las =
1, cex.axis=0.5, las = 1, font = 2, tcl = -0.2)
非常感谢。
答案 0 :(得分:1)
您可以将padj
参数用于axis
# make a reproducible example
dates <- seq(as.Date("2016/1/1"), as.Date("2016/4/1"), "days")
dates_ten <- seq(as.Date("2016/1/1"), as.Date("2016/4/1"), "10 days")
set.seed(42)
data <- rnorm(seq_along(dates))
根据需要改变padj
:
plot(dates, data, type = "l", lwd = 3, ylab = " ",
xlab = " ", col = "gray35", xaxt='n', ann = FALSE)
axis(side=1, at=dates_ten, labels=format(dates_ten, "%b-%d-%y"), las = 1,
cex.axis=0.5, las = 1, font = 2, tcl = -0.2, padj = -2)