R語言中給圖形添加圖例


 

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)

 

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM