gpt4 book ai didi

r - 在图中对齐图例表/矩阵中的文本和线条

转载 作者:行者123 更新时间:2023-12-05 02:27:55 25 4
gpt4 key购买 nike

我正在尝试对齐图例内表格(由矩阵定义)中的线条和文本。

到目前为止我尝试了什么:

plot(1,type="n",col=2)
legend_order <- matrix(1:12,ncol=3,byrow = TRUE)
legend("topright",
ncol=3,
legend=c("","long label 1","long label 2",
"T=1","","",
"T=2","","",
"T=3","","")[legend_order],
lty=c(0,0,0,0,1,1,0,1,1,0,1,1)[legend_order],
col=c(0,0,0,0,2,5,0,3,6,0,4,7)[legend_order])

enter image description here

这里我们可以看到“long label 1”和“long label 2”没有与彩色线条对齐。 “T”的左边也有空隙。

如何将文本与线条对齐?

最佳答案

我们可以使用adj。阅读更多?legend;

plot(1,type="n",col=2)
legend_order <- matrix(1:12,ncol=3,byrow = TRUE)
legend("topleft",
ncol=3,
legend=c("","foo","bar",
"T=1","","",
"T=2","","",
"T=3","","")[legend_order],
lty=c(0,0,0,0,1,1,0,1,1,0,1,1)[legend_order],
col=c(0,0,0,0,2,5,0,3,6,0,4,7)[legend_order],
adj = 2)

关于r - 在图中对齐图例表/矩阵中的文本和线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72816821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com