简体   繁体   English

更改图例中的线条长度

[英]Changing length of lines in a legend

The following simple example... 以下简单示例......

plot(c(1,2),c(1,2),type="l")
legend(1,1.5,legend="Test",lty=1,seg.len=2)

...produces the error ...产生错误

Error in legend(1, 1.5, legend = "Test", lty = 1, seg.len = 2) : unused argument (seg.len = 2)

How should I use seg.len to get longer lines in legends? 我应该如何使用seg.len在传说中获得更长的线条?

If you use this in a larger script, other packages might mask the legend() function. 如果在较大的脚本中使用它,其他包可能会掩盖legend()函数。 These "other" functions might not contain the seg.len parameter. 这些“其他”函数可能不包含seg.len参数。 Thus you have to reference to the basic legend function. 因此,您必须参考基本legend功能。 You can easily achieve this by adding the package like this: 您可以通过添加如下包来轻松实现此目的:

graphics::legend(1, 1.5, legend = "Test", lty = 1, seg.len = 2)

The code in question works perfectly for me (see image output below). 有问题的代码对我来说非常适合(参见下面的图像输出)。

I suggest you do the following: 我建议你做以下事情:

  1. Download and install the latest R binaries. 下载并安装最新的R二进制文件。 Download R 下载R.
  2. If you use RStudio, download and install the most recent version. 如果您使用RStudio,请下载并安装最新版本。 Download RStudio 下载RStudio

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM