Insert a plot as a vignette in another plot
Let show how to use par(fig=c(x0, x1, y0, y1))
library(maps)
par(fig=c(0, 1, 0, 1))
par(mar=c(4, 4, 1, 2))
map("world", region=c("Sao Tome and Principe:Ilha da Sao Tome",
"Sao Tome and Principe:Ilha do Principe"),
xlim=c(6, 8), ylim=c(0,2),
asp=1)
library(sp)
degAxis(side=1, cex.axis=0.8) # in package sp
degAxis(side= 2, las=1, cex.axis=0.8)
par(fig=c(0.5, 0.9, 0.1, 0.5))
par(new=TRUE)
par(mar=c(0, 0, 0, 0))
plot(x=c(-180,180), y=c(-90,90), type="n", axes=FALSE, xlab="n", ylab="n")
polygon(x=c(-180, -180, 180, 180), y=c(-90, 90, 90, -90))
par(new=TRUE)
map("world", asp=1, add=TRUE, fill=TRUE, col="grey", border=NA)
polygon(x=c(6, 6, 8, 8), y=c(0, 2, 2, 0))
library(maps)
par(fig=c(0, 1, 0, 1))
par(mar=c(4, 4, 1, 2))
map("world", region=c("Sao Tome and Principe:Ilha da Sao Tome",
"Sao Tome and Principe:Ilha do Principe"),
xlim=c(6, 8), ylim=c(0,2),
asp=1)
library(sp)
degAxis(side=1, cex.axis=0.8) # in package sp
degAxis(side= 2, las=1, cex.axis=0.8)
par(fig=c(0.5, 0.9, 0.1, 0.5))
par(new=TRUE)
par(mar=c(0, 0, 0, 0))
plot(x=c(-30,50), y=c(-40,35), type="n", axes=FALSE, xlab="n", ylab="n")
# polygon(x=c(-30, -30, 50, 50), y=c(-40, 35, 35, -40))
par(new=TRUE)
pxpynames <- map('world', plot = FALSE, xlim=c(-20, 45),
ylim=c(-30, 35))$names
map("world", asp=1, add=TRUE, region=pxpynames, fill=TRUE, col="grey", border=NA)
polygon(x=c(6, 6, 8, 8), y=c(0, 2, 2, 0))
library(maps)
par(fig=c(0, 1, 0, 1))
par(mar=c(4, 4, 1, 2))
map("world", region=c("Sao Tome and Principe:Ilha da Sao Tome",
"Sao Tome and Principe:Ilha do Principe"),
xlim=c(6, 8), ylim=c(0,2),
asp=1)
library(sp)
degAxis(side=1, cex.axis=0.8) # in package sp
degAxis(side= 2, las=1, cex.axis=0.8)
par(fig=c(0.5, 0.9, 0.1, 0.5))
par(new=TRUE)
par(mar=c(0, 0, 0, 0))
plot(x=c(-180,180), y=c(-90,90), type="n", axes=FALSE, xlab="n", ylab="n")
polygon(x=c(-180, -180, 180, 180), y=c(-90, 90, 90, -90))
par(new=TRUE)
map("world", asp=1, add=TRUE, fill=TRUE, col="grey", border=NA)
polygon(x=c(6, 6, 8, 8), y=c(0, 2, 2, 0))
library(maps)
par(fig=c(0, 1, 0, 1))
par(mar=c(4, 4, 1, 2))
map("world", region=c("Sao Tome and Principe:Ilha da Sao Tome",
"Sao Tome and Principe:Ilha do Principe"),
xlim=c(6, 8), ylim=c(0,2),
asp=1)
library(sp)
degAxis(side=1, cex.axis=0.8) # in package sp
degAxis(side= 2, las=1, cex.axis=0.8)
par(fig=c(0.5, 0.9, 0.1, 0.5))
par(new=TRUE)
par(mar=c(0, 0, 0, 0))
plot(x=c(-30,50), y=c(-40,35), type="n", axes=FALSE, xlab="n", ylab="n")
# polygon(x=c(-30, -30, 50, 50), y=c(-40, 35, 35, -40))
par(new=TRUE)
pxpynames <- map('world', plot = FALSE, xlim=c(-20, 45),
ylim=c(-30, 35))$names
map("world", asp=1, add=TRUE, region=pxpynames, fill=TRUE, col="grey", border=NA)
polygon(x=c(6, 6, 8, 8), y=c(0, 2, 2, 0))
Commentaires
Enregistrer un commentaire