Skip to content
Prev 164070 / 398506 Next

legend at fixed distance form the bottom

Sorry, I will be more precise. Here is an example (simplified) of graph 
I want :

---- 8< ----

symboles <- c(3,4,5,6)
dn <- rbind(matrix(rnorm(20),5))
layout(matrix(c(1,1,1,2,2,3),3))

for(i in 1:3)
  matplot(dn,type="b",xlab="+: a  x: b  ???: c  ???: d",pch=symboles)
---- 8< ----

But instead of ???, I want the "triangle" and the "losange".
So I try to use legend in order to get the losange and triangle :

--- 8< ----

for(i in 1:3){
  matplot(dn,type="b",xlab="",pch=symboles)
  legend("top", pch = unique(listSymboles),
        legend = c("a","b","c","d"),
        inset = c(0,1.1), horiz = TRUE, xpd = NA)
}

--- 8< ----

On the first plot, the legend is down, on the second, the legend is on a 
correct position, on the third one, the legend in *on* the graduation.
So my problem is to plot either a legend at a fixed distance from the 
graph or to put some symbol ("triangle", "losange" and all the other 
since I might have more than 4 curves) in the xlab.

Any solution ?

Thanks

Christophe