Skip to content
Prev 28885 / 29559 Next

layout and plot.stars

Coming back to the example which initiated the issue, I have found the 
trick following your hints Edzer, but it makes a strange rational. Here 
we go:

nf <- layout(matrix(c(1,2),2,1,byrow = TRUE), c(3,3), c(3,1), TRUE)
layout.show(nf)

plot(st_geometry(mydept),col="grey",border="grey90")
plot(st_geometry(fzone1),col=mypal(12)[1],border=NA,add=TRUE)
plot(st_geometry(fzone2),col=mypal(12)[2],border=NA,add=TRUE)
plot(st_rasterize(ztot),col=mypal(12),main="",breaks="equal",key.pos=NULL,reset=FALSE,add=TRUE)
plot(st_geometry(mydept),col=NA,border="grey90",add=TRUE)

mybox<-bbox2sf(n=0.5,s=0,w=0,e=10,crs=2154) # crs is just crap here, I 
do not need it thenafter
mypoly<-st_make_grid(mybox,n=c(12,1),what="polygons")
plot(mypoly,col=mypal(12),border=mypal(12))
plot(mybox,add=TRUE)

Makes exactly what I was intending to make. The critical point was to 
explicitely keep reset=FALSE in the 4th plot (actually a plot.stars). If 
not, the 6th plot is plotted in region #1 erasing the previous plots...

Some personal remarks:
- in the first plot, I ommited the argument reset=FALSE, however this 
does not make a problem (maybe because I just plot a geometry ?)
- the 4th plot is definitely strange with reset=FALSE and add=TRUE 
together, isn't it ?

Thanks Roger and Ezder for bailing me out once again... :-)
Patrick



Le 15/03/2022 ? 16:02, Edzer Pebesma a ?crit?: