Hello,
Recently, I have asked for a help with building graphs, and I got few
great advices. Now, my appetite is growing :) and I wander how to add
legend for two (or more) lines in following example:
matplot(DAT[, c(3,4)], type="b", ylim=c(0,8), xaxt="n",
yaxt="n",
+ pch=c(21,22), col="black",
lty=c("dashed","solid"), xlab="",
ylab="")
title(ylab="% correct", xlab="Trial", cex.lab=1.5)
axis(1, at=1:4, labels=as.character(DAT$Trial), cex.axis=1.5)
axis(2, cex.axis=1.5)
Sincerely,
Petar
Petar Milin wrote:> Hello, > Recently, I have asked for a help with building graphs, and I got few > great advices. Now, my appetite is growing :) and I wander how to add > legend for two (or more) lines in following example: > > matplot(DAT[, c(3,4)], type="b", ylim=c(0,8), xaxt="n", yaxt="n", > + pch=c(21,22), col="black", lty=c("dashed","solid"), xlab="", ylab="") > title(ylab="% correct", xlab="Trial", cex.lab=1.5) > axis(1, at=1:4, labels=as.character(DAT$Trial), cex.axis=1.5) > axis(2, cex.axis=1.5) >We do not have DAT, why don't you make it easier for us to help by specifying a very tiny data.frame that fits to your code? Best, Uwe Ligges> > Sincerely, > Petar > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi
you can put quite sophisticated legend using legend command e.g.
legend(locator(1), legend=c("first", "second"),
pch=c(21,22), lty =
c(2,1))
Regards
Petr
On 21 Mar 2007 at 8:38, Petar Milin wrote:
From: Petar Milin <pmilin at ff.ns.ac.yu>
To: r-help <r-help at stat.math.ethz.ch>
Organization: Department of Psychology, University of Novi Sad, Serbia
Date sent: Wed, 21 Mar 2007 08:38:25 +0100
Subject: [R] Detailed legend in mathplot ...
> Hello,
> Recently, I have asked for a help with building graphs, and I got few
> great advices. Now, my appetite is growing :) and I wander how to add
> legend for two (or more) lines in following example:
>
> matplot(DAT[, c(3,4)], type="b", ylim=c(0,8), xaxt="n",
yaxt="n",
> + pch=c(21,22), col="black",
lty=c("dashed","solid"), xlab="",
> ylab="")
> title(ylab="% correct", xlab="Trial", cex.lab=1.5)
> axis(1, at=1:4, labels=as.character(DAT$Trial), cex.axis=1.5)
> axis(2, cex.axis=1.5)
>
>
> Sincerely,
> Petar
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.
Petr Pikal
petr.pikal at precheza.cz