[R-SIG-Mac] "legend" command does nothing
Susan Gruber
sgruber at berkeley.edu
Sat Sep 18 18:28:22 CEST 2010
Hi Adrian,
I just tried out your plot code as written, except for adding the first
three lines below to generate x and Y data, and the legend prints
correctly. So I agree this points to a font problem.
Y <- matrix(1:28, nrow=7)
x <- 1:7
ttext="plot title"
matplot(x,Y,xlab="N(t)",ylab="log{N(t+1)/N(t)}",main=ttext,
type=c("p","l","l","l","l"),pch=21,col=c("black","blue","green","red",
"purple"),lty=1,lwd=2,family="sans")
legend("topright",c("Data","DI model","Ricker","Theta Logistic","Allee"),
pch=c(21,-1,-1,-1),col=c("black","blue","green","red","purple"),
lty=c("blank","solid","solid","solid","solid"),lwd=2,plot=TRUE)
--Susan
> Hello,
>
> I am having problems adding legends to my plots. For example, the command
> at the bottom of this message produces no legend for me. The plot appears
> correctly, but the legend is completely absent. Am I doing something
> incorrectly in the syntax of the legend function?
>
> It is possible that this is related to a problem that I posted previously
> on
> this list: I do not see any text on any graphs unless I explicitly supply
> the "family="sans"" argument to any plotting function.
>
> Any advice is appreciated. Thank you,
> Adrian Down
>
> quartz()
>
> Y=cbind(loglamt,yp)
>
> matplot(x,Y,
>
> xlab="N(t)",ylab="log{N(t+1)/N(t)}",main=ttext,
>
> type=c("p","l","l","l","l"),pch=21,col=c("black","blue","green","red",
> "purple"),lty=1,lwd=2,family="sans")
>
> legend("topright",c("Data","DI model","Ricker","Theta
> Logistic","Allee"),pch
> =c(21,-1,-1,-1),
>
> col=c("black","blue","green","red","purple"),lty=c("blank","solid","solid",
> "solid","solid"),lwd=2,plot=TRUE)
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
More information about the R-SIG-Mac
mailing list