[R] unexpected (?) behavior of box()

ani jaya g@@@uu| @end|ng |rom gm@||@com
Fri Jan 7 08:25:18 CET 2022


Dear R expert,

I try to box a figure using box(). However it box the default margin,
not the specified margin.

#working as expected
barplot(1:20)
box()

#working as expected, the box follow the margin
par(mar=c(2, 6, 5, 4))
barplot(1:20)
box()

#not working
install.packages("maps")
library(maps)
par(mar=c(2, 6, 5, 4))
m<-map('world', xlim = c(91, 142), ylim = c(25, 40),
       lwd=1.5, col = "grey",border=NA, fill = T,  bg="white")
box()

#the turnaround
par(mar=c(2, 6, 5, 4))
m<-map('world', xlim = c(91, 142), ylim = c(25, 40),
       lwd=1.5, col = "grey",border=NA, fill = T,  bg="white")
par(mar=c(2, 6, 5, 4))
box()

I just curious with this behavior. Is it the problem with the package
"map" or box() function?
Thank you.

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 19043)



Ani



More information about the R-help mailing list