热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

R图例:减少图例列之间的间距-Rplotlegend:Reducespacebetweenlegendcolumns

Iamusingveganlibrarytomakesomeplots,withthiscode:我使用纯素库来制作一些图,使用以下代码:raremax<-min

I am using vegan library to make some plots, with this code:

我使用纯素库来制作一些图,使用以下代码:

raremax <- min(colSums(mydata))
col <- palette()
lty <- c("solid", "dashed", "longdash", "dotdash")
pars <- expand.grid(col = col, lty = lty, stringsAsFactors = FALSE)

out <- with(pars[1:18, ], rarecurve(mydata, step = 100, sample = raremax, 
       cex =0.6, ylab="OTUs", label=F, col=col, lty=lty, lwd=2))

Then I add a legend using this code:

然后我使用以下代码添加图例:

legend("bottomright", names(mydata), col=pars[1:18,1], lty= pars[1:18,2], 
       lwd=2, cex=0.5, xjust=1, ncol=2, x.intersp=0.5, y.intersp=0.5, bg="white")

The resulting graph looks like this: enter image description here

结果图如下所示:

I would like to reduce the space between legend columns, also reducing the size of the legend box, but I can't find a way to do that.

我想减少图例列之间的空间,也减少了图例框的大小,但我找不到办法做到这一点。

Anyone could provide me some help?

有人能给我一些帮助吗?

1 个解决方案

#1


1  

A combination of the legend() parameters "x.intersp" and "text.width" should be helpful.

legend()参数“x.intersp”和“text.width”的组合应该会有所帮助。

Decreasing "x.intersp" (default value = 1, for me 0.25 looked good) should move your the legend labels closer to their respective points. Decreasing "text.width" (default value=NULL, for me 0.045 looked good) moves the columns closer together.

减少“x.intersp”(默认值= 1,对我来说0.25看起来不错)应该使图例标签更接近各自的点。减少“text.width”(默认值= NULL,对我来说0.045看起来不错)将列移得更近。


推荐阅读
author-avatar
迷人的小刀
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有