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)

 

R语言中给图形添加图例

 

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)

R语言中给图形添加图例

 

 

参考:https://www.jianshu.com/p/004f00142d00

 

相关文章:

  • 2021-08-05
  • 2021-06-19
  • 2022-12-23
  • 2021-12-09
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
  • 2021-04-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-16
  • 2021-12-26
  • 2022-01-23
  • 2021-08-15
  • 2021-10-29
相关资源
相似解决方案