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

ani jaya g@@@uu| @end|ng |rom gm@||@com
Fri Jan 7 09:20:22 CET 2022


Hi Jim,

Thank you for the alternative. Absolutely will try it.
Can you explain a bit about "Maps draws an approximately 2x1 plot"?
Is it the size proportion 2 in x-axis and 1 in y-axis?

On Fri, Jan 7, 2022 at 4:41 PM Jim Lemon <drjimlemon using gmail.com> wrote:
>
> Hi Ani,
> Blame Mercator. Maps draws an approximately 2x1 plot. Maybe this:
>
> mappar<-par("usr")
> rect(mappar[1],mappar[3],mappar[2],mappar[4])
>
> Jim
>
> On Fri, Jan 7, 2022 at 6:25 PM ani jaya <gaaauul using gmail.com> wrote:
> >
> > 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
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list