Any of those help In R base graphs, there is an option in par to use "pretty" margins. This default option extends the data range on the axis values by 4% for pretty labels. This has the side effect of ignoring xlim and ylim sometimes. One thing to try is to switch this option to use exactly the data range. The options are xaxs="i" and yaxs="i" for X and Y axes, respectively.
To fix this issue Look at the parameters xaxs and yaxs (under ?par). By default the axis contains the data range plus 4% on either side. If you override the parameter, then you can get an axis exactly equal to the data range. Cf:
> curve(x^2, xaxs="i", yaxs="i")
Trouble with margins & plot sizes in multiple figure plot in pdf
I hope this helps you . My general recommendations would be to (1) stick to only one unit of measurement, inches or lines, and (2) do some arithmetic to determine how big your device size needs to be to fit what you're plotting. You're mixing mar and pin which use lines and inches. I certainly don't know how tall 1 inch plus 1 line is going to be off the top of my head (although I'm sure we could hack something together to calculate it).
Hope that helps I sometimes get this error as well and I maximize my X11 plotting window and it goes away (I don't use RStudio often though). The code you provided works fine for me even in the default size viewer. This code produces 3 plots though. You could make them on the same plot by using the parameter new in par