R语言中绘图,将图例设置在绘图区域之外

 

001、 正常绘图

par(mar=c(6, 6, 6, 6), xpd = TRUE)   ## 绘图区域外留白
plot(1:10)
legend('right',inset= 0.3, pch=19,legend='xxx')  ## 绘图,图例在图形内部

 

 

002、图例放在图形正右方

par(mar=c(6, 6, 6, 6), xpd = TRUE)
plot(1:10)
legend('right',inset= -0.3, pch=19,legend='xxx')    ##  图例在正右方

 

 

003、图例在正左方

par(mar=c(6, 6, 6, 6), xpd = TRUE)
plot(1:10)
legend('left',inset= -0.3, pch=19,legend='xxx')  ## 图例在正左方

 

 

004、图例在正上方

par(mar=c(6, 6, 6, 6), xpd = TRUE)
plot(1:10)
legend('top',inset= -0.3, pch=19,legend='xxx')  ## 图例在正上方

 

 

005、精确调整

a、

par(mar=c(6, 6, 6, 6), xpd = TRUE)
plot(1:10)
legend('topleft',inset= c(0.4, 0.1), pch=19,legend='xxx') ## c(0.4, 0.1), 0.4调整横向,0.1调整纵向

 

 

b、

par(mar=c(6, 6, 6, 6), xpd = TRUE)
plot(1:10)
legend('topleft',inset= c(0.4, -0.1), pch=19,legend='xxx')  ## 横向0.4, 纵向-0.1

 

posted @   小鲨鱼2018  阅读(745)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2022-04-04 ubuntu中 putty连接出现 network error. connection refused
2022-04-04 ubuntu中安装gcc c++编译器
2022-04-04 Peer reports incompatible or unsupported protocol version.
2022-04-04 cache.h:40:18: fatal error: zlib.h: No such file or directory
2022-04-04 bash: git: command not found...
2022-04-04 linux 中实现每两列数据合并为一列数据
2022-04-04 多组一列数据的处理
点击右上角即可分享
微信分享提示