PhilG
PhilG

Reputation: 381

R plot remove right margin

I have a function that return a plot:

NDVI_Result = function(x,y){
output = raster::overlay(raster::raster(base::normalizePath(x)), 
raster::raster(base::normalizePath(y)), fun = NDVI)
graphics::par(bg=NA,mar=c(0,0,0,0),oma=c(0,0,0,0))
raster::plot(output,axes=FALSE,box=TRUE,legend=FALSE, frame=FALSE)

After exporting this as png, I get this result:

Result of exported PNG

How can I remove the right margin of the result to be able to work with the image which then contains only the box?

Upvotes: 2

Views: 1216

Answers (2)

BrunoSC
BrunoSC

Reputation: 36

You can use plot(...,legend.mar = 0).

Upvotes: 1

Robert Hijmans
Robert Hijmans

Reputation: 47071

You can use image instead of plot

library(raster)
r <- raster(system.file("external/test.grd", package="raster"))
par(bg=NA,mar=c(0,0,0,0),oma=c(0,0,0,0))
image(r, axes=FALSE)

Upvotes: 2

Related Questions