Reputation: 1581
When plotting a raster the box around the plot and the axes are adjusted automatically:
r <- raster(nrows=10, ncols=10)
r <- setValues(r, 1:ncell(r))
plot(r)
Here, the extent is
extent(r)
class : Extent
xmin : -180
xmax : 180
ymin : -90
ymax : 90
Nevertheless, the y-axis runs from -180 to 180 and there is ugly white space on the top and the bottom of the plot. Is there a way to force the box and the y-axis to the extent of the raster layer? I fumbled around with arguments like asp, ylim etc. but could not find any solution. Which way to do that am I missing?
Upvotes: 1
Views: 596
Reputation: 47061
You are not saying what you are plotting to. For some devices, e.g. png you can set the height and width. In other cases, you need to resize the plotting window manually.
Upvotes: 1