spalan
spalan

Reputation: 173

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?

Upvotes: 3

Views: 1741

Answers (2)

loki
loki

Reputation: 10350

If you use this in a larger script, other packages might mask the legend() function. These "other" functions might not contain the seg.len parameter. Thus you have to reference to the basic legend function. You can easily achieve this by adding the package like this:

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

Upvotes: 1

Ekaba Bisong
Ekaba Bisong

Reputation: 2982

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. Download R
  2. If you use RStudio, download and install the most recent version. Download RStudio

enter image description here

Upvotes: 0

Related Questions