2
votes

When I want to get a quick look at a graph in RStudio, I typically use just plot(r) or perhaps add a title with plot(r, main = title). When I'm doing a plot of a global raster data set, the xy min and max values in the Plots pane vary depending on the pane size. I'd like to do some plots where the plot size and dimensions are fixed; in particular, to xmin = - 150, xmax = 150, ymin = -90, ymax = 90. It seems like the par("usr") option would be what to use.

Here's a simple example that shows what my problem is

b <- brick(system.file("external/rlogo.grd", package="raster"))
plot(b$red)
par("usr")
par(usr = c(-180, 180, -60, 90))
par("usr")
plot(b$green)
par("usr")

Every time I do a plot, the par usr value reverts to something else

Setting xlim and ylim as suggested acts a bit as clipping, but I'd also like to fix the usr values and get plot to accept them.

1
par will let you change physical size but what you are asking for is what the xlim and ylim parameters to plot are used for.IRTFM

1 Answers

1
votes

par("usr") returns the coordinates of the current plot. These change as you resize the plot; you cannot set them with par

Perhaps you can use

dev.new(width=5, height=4, noRStudioGD = TRUE)

See this: Creating a Plot Window of a Particular Size.