When we select the entire data range, we get a plot with a slight margin inside the plot region so that the plot doesn’t touch the bounding box. However when we subset a plot, the margin is gone. Is there a way to add this margin? In the lower figure, I would like the line to go all the way to 5, but no further. I went through the ?par list and can’t come up with something usable.
plot(1:10, 1:10, type = "l")
plot(1:10, 1:10, type = "l", xlim = c(1, 5))

This seems to be a very roundabout way to do it, but here is one possibility with the example you’ve provided: