Reputation: 11
I am using the code as given below
The problem is there is very long space between legend line and legend text as shown in figure. kindly help how i can reduce this spacing. such as spacing between legend numbers and lines like this
________ 1
-------- 2
legend(x=q-70, y=m, bty = "n",
legend = c("1","2","3", "4","5", "6","7", "8","9", "10","11", "12","13", "14","15", "16","17", "18","19", "20"),
lty = c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,4,4,4,4),
col = c("black", "red","green","blue","cyan","magenta","yellow","gray","black", "red","green","blue","cyan","magenta","yellow","gray","black", "red","green","blue"),
y.intersp=0.7, cex = 0.95,seg.len = 1.3, lwd = 2)
Upvotes: 0
Views: 461
Reputation: 37661
I notice that you have explicitly set y.intersp=0.7
. I wonder if you have somehow set x.intersp
as well. At any rate, if nothing else works for you, you could try various values of x.intersp
until you get a position that you want. Here is a simple example on a blank background to show how x.intersp
adjusts the position.
par(mfrow=c(1,2))
plot(0:2, pch="", xlab="", ylab="", bty="n", xaxt="n", yaxt="n",
main="x.intersp=1")
legend(x=1, y=2, bty = "n",
legend = c("1","2","3", "4","5","6","7","8","9","10",
"11","12","13","14","15","16","17","18","19","20"),
lty = c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,4,4,4,4),
col = c("black", "red","green","blue","cyan","magenta","yellow",
"gray","black", "red","green","blue","cyan","magenta","yellow",
"gray","black", "red","green","blue"),
x.intersp=1, y.intersp=0.7, cex = 0.95,seg.len = 1.3, lwd = 2)
plot(0:2, pch="", xlab="", ylab="", bty="n", xaxt="n", yaxt="n",
main="x.intersp=4")
legend(x=1, y=2, bty = "n",
legend = c("1","2","3", "4","5","6","7","8","9","10",
"11","12","13","14","15","16","17","18","19","20"),
lty = c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,4,4,4,4),
col = c("black", "red","green","blue","cyan","magenta","yellow",
"gray","black", "red","green","blue","cyan","magenta","yellow",
"gray","black", "red","green","blue"),
x.intersp=4, y.intersp=0.7, cex = 0.95,seg.len = 1.3, lwd = 2)
Upvotes: 1