使用plot.window()函数手动设置绘图窗口范围。
示例代码:
# 生成数据
x <- 1:100
y <- sin(x)
# 绘制图形
plot(x, y, xlim = c(30, 70))
# 获取当前的绘图窗口
current_window <- par()$usr
# 设置绘图窗口范围
plot.window(xlim = current_window[1:2], ylim = current_window[3:4])
# 再次绘制图形
points(x, y)
解释:首先使用plot()函数绘制图形,并使用xlim参数设置x轴坐标范围。然后获取当前的绘图窗口范围,使用plot.window()函数手动设置绘图窗口的范围,最后使用points()函数再次绘制图形。这样就可以在窗口范围之外绘制图形。