1、
opar <- par(no.readonly = T)
par(mfrow=c(2,2))
plot(1:10)
legend("topleft",inset = 0.04,c(paste0("lab", 1:4)),pch = c(15:18),
col = c("red","blue","magenta","cyan"))
plot(1:10)
legend("bottomright",inset = 0.04,c(paste0("lab", 1:4)),pch = c(15:18),
col = c("red","blue","magenta","cyan"),ncol = 2,title = "legend",text.font = 2,
box.lwd = 3)
plot(1:10)
legend("topleft",inset = 0.04,c(paste0("lab", 1:4)),pch = c(15:18),
col = c("red","blue","magenta","cyan"),horiz = T,cex=1.3)
plot(1:10)
locator(1) ## 此处鼠标在图形中确定图例的位置
legend(2.65653,7.3,inset = 0.04,c(paste0("lab", 1:4)),pch = c(15:18),
col = c("red","blue","magenta","cyan"),box.col = "red",
box.lwd = 3,text.font = 2)
par(opar)
2、鼠标确定图例位置
plot(1:10)
legend(locator(1),LETTERS[1:4],pch = 15:18, inset = 0.05,cex = 2,text.font = 2,
col = c("red","blue","green","purple"),ncol = 2, box.lwd = 3)