I finally got everything plotted as I had planned. So, thank you again. Sundars suggestion looks more flexible when it comes to large numbers of categories (i.e. sigmas). In the plot I will be using, there are 3 sigmas... I am keen to learn about that bquote and substitute stuff. I will definitely take a look at your newsletter contribution, uwe. The ';'s were intended to ease the mail2console copy-and-paste, as some mail programs take control of your linebreaks. Mario.
__________________________________________________________________ Mario Maiworm Biological Psychology and Neuropsychology University of Hamburg Von-Melle-Park 11 D-20146 Hamburg Tel.: +49 40 42838 3515 Fax.: +49 40 42838 6591 http://bpn.uni-hamburg.de/Maiworm_e.html http://cinacs.org __________________________________________________________________ >>> -----Ursprüngliche Nachricht----- >>> Von: Sundar Dorai-Raj [mailto:[EMAIL PROTECTED] >>> Gesendet: Freitag, 7. März 2008 17:22 >>> An: Uwe Ligges >>> Cc: Mario Maiworm; r-help@r-project.org >>> Betreff: Re: [R] LaTeX in R >>> >>> Or my personal favorite if the length of mySigma is variable: >>> >>> mySigma <- 2:3 >>> plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l') >>> lines(dnorm(1:10,sd = mySigma[2]),lty = 2) >>> leg <- as.expression(lapply(mySigma, function(x) bquote(sigma == .(x)))) >>> legend(x = "topright", lty = c(1,2),legend = leg) >>> >>> Thanks, >>> >>> --sundar >>> >>> Uwe Ligges said the following on 3/7/2008 8:15 AM: >>> > You might want to read >>> > Ligges, U. (2002): R Help Desk: Automation of Mathematical >>> Annotation >>> > in Plots. R News 2 (3), 32-34. >>> > with an example at the end that meets your requirements: >>> > >>> > (please note that I removed those ugly ";" >>> > >>> > >>> > mySigma[1] <- 2 >>> > mySigma[2] <- 3 >>> > plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l') >>> > lines(dnorm(1:10, sd = mySigma[2]), lty = 2) >>> > legend1 <- substitute(sigma == myS, list(myS = mySigma[1])) >>> > legend2 <- substitute(sigma == myS, list(myS = mySigma[2])) >>> > legend(x = "topright", lty = c(1,2), >>> > legend = do.call(expression, list(legend1, legend2))) >>> > >>> > >>> > Uwe Ligges >>> > >>> > >>> > >>> > Mario Maiworm wrote: >>> >> Finally, this should work for an array of sigmas. I just realized >>> that the >>> >> substitute()-command is not evaluated within a c()-environment :( >>> >> >>> >> mySigma[1] <- 2; mySigma[2] <- 3; >>> >> plot(1:10, dnorm(1:10, sd = mySigma[1]), type = 'l') ; >>> >> lines(dnorm(1:10,sd = mySigma[2]),lty = 2); >>> >> legend(x = "topright", lty = c(1,2),legend = c(substitute(sigma == >>> myS, >>> >> list(myS = mySigma[1])),substitute(sigma == myS, list(myS = >>> mySigma[2])))) >>> >> >>> >> Mario. >>> >> >>> >> >>> >> __________________________________________________________________ >>> >> >>> >> Mario Maiworm >>> >> Biological Psychology and Neuropsychology >>> >> University of Hamburg >>> >> Von-Melle-Park 11 >>> >> D-20146 Hamburg >>> >> >>> >> Tel.: +49 40 42838 3515 >>> >> Fax.: +49 40 42838 6591 >>> >> >>> >> http://bpn.uni-hamburg.de/Maiworm_e.html >>> >> http://cinacs.org >>> >> __________________________________________________________________ >>> >> >>> >>>>> -----Ursprüngliche Nachricht----- >>> >>>>> Von: Uwe Ligges [mailto:[EMAIL PROTECTED] >>> >>>>> Gesendet: Freitag, 7. März 2008 16:30 >>> >>>>> An: Mario Maiworm >>> >>>>> Cc: r-help@r-project.org >>> >>>>> Betreff: Re: AW: [R] LaTeX in R >>> >>>>> >>> >>>>> >>> >>>>> >>> >>>>> Mario Maiworm wrote: >>> >>>>>> Thank you, uwe and jeremy. I was actually looking exactly for >>> that! >>> >>>>> But >>> >>>>>> something still doesn't work: >>> >>>>>> I want to plot a symbol in a legend of a plot, lets say "\sigma = >>> 2". >>> >>>>> 2 >>> >>>>>> should be the value of a variable. So, when I try >>> >>>>>> >>> >>>>>> mySigma=2;plot(1:10,dnorm(1:10,sd=mySigma),type='l') >>> >>>>>> legend(x="topright",legend=paste(expression(sigma)," = >>> >>>>> ",mySigma),lty=1) >>> >>>>>> , the sigma is not plotted as a symbol. This version: >>> >>>>>> >>> >>>>>> mySigma=2;plot(1:10,dnorm(1:10,sd=mySigma),type='l') >>> >>>>>> legend(x="topright",legend=expression(paste(sigma," = >>> >>>>> ",mySigma)),lty=1) >>> >>>>>> gives me a 'real' sigma but the mySigma variable is not >>> evaluated. Any >>> >>>>>> ideas? >>> >>>>> Yes: >>> >>>>> >>> >>>>> >>> >>>>> mySigma <- 2 >>> >>>>> plot(1:10, dnorm(1:10, sd = mySigma), type='l') >>> >>>>> legend(x = "topright", lty = 1, >>> >>>>> legend = substitute(sigma == myS, list(myS = mySigma))) >>> >>>>> >>> >>>>> >>> >>>>> Uwe Ligges >>> >>>>> >>> >>>>> >>> >>>>>> Mario. >>> >>>>>> >>> >>>>>> >>> __________________________________________________________________ >>> >>>>>> >>> >>>>>> Mario Maiworm >>> >>>>>> Biological Psychology and Neuropsychology >>> >>>>>> University of Hamburg >>> >>>>>> Von-Melle-Park 11 >>> >>>>>> D-20146 Hamburg >>> >>>>>> >>> >>>>>> Tel.: +49 40 42838 3515 >>> >>>>>> Fax.: +49 40 42838 6591 >>> >>>>>> >>> >>>>>> http://bpn.uni-hamburg.de/Maiworm_e.html >>> >>>>>> http://cinacs.org >>> >>>>>> >>> __________________________________________________________________ >>> >>>>>> >>> >>>>>>>>> -----Ursprüngliche Nachricht----- >>> >>>>>>>>> Von: Uwe Ligges [mailto:[EMAIL PROTECTED] >>> >>>>>>>>> Gesendet: Freitag, 7. März 2008 15:27 >>> >>>>>>>>> An: Mario Maiworm >>> >>>>>>>>> Cc: r-help@r-project.org >>> >>>>>>>>> Betreff: Re: [R] LaTeX in R >>> >>>>>>>>> >>> >>>>>>>>> >>> >>>>>>>>> >>> >>>>>>>>> Mario Maiworm wrote: >>> >>>>>>>>>> Dear Rers, >>> >>>>>>>>>> I understand that I can include R-code in LaTeX using Sweave. >>> Is >>> >>>>> there >>> >>>>>>>>> a way >>> >>>>>>>>>> to do it the other way round? Particularly, I need some TeX >>> >>>>> symbols in >>> >>>>>>>>> the >>> >>>>>>>>>> legend of an R-plot. This can be done in matlab easily, so I >>> am >>> >>>>>>>>> optimistic >>> >>>>>>>>>> with R. Any suggestions for a command or package? >>> >>>>>>>>> See ?plotmath >>> >>>>>>>>> >>> >>>>>>>>> Uwe Ligges >>> >>>>>>>>> >>> >>>>>>>>> >>> >>>>>>>>> >>> >>>>>>>>> >>> >>>>>>>>>> Best, >>> >>>>>>>>>> Mario. >>> >>>>>>>>>> >>> >>>>>>>>>> >>> >>>>>>>>>> >>> >>>>>>>>>> >>> __________________________________________________________________ >>> >>>>>>>>>> >>> >>>>>>>>>> Mario Maiworm >>> >>>>>>>>>> Biological Psychology and Neuropsychology >>> >>>>>>>>>> University of Hamburg >>> >>>>>>>>>> Von-Melle-Park 11 >>> >>>>>>>>>> D-20146 Hamburg >>> >>>>>>>>>> >>> >>>>>>>>>> Tel.: +49 40 42838 3515 >>> >>>>>>>>>> Fax.: +49 40 42838 6591 >>> >>>>>>>>>> >>> >>>>>>>>>> http://bpn.uni-hamburg.de/Maiworm_e.html >>> >>>>>>>>>> http://cinacs.org >>> >>>>>>>>>> >>> >>>>>>>>>> ______________________________________________ >>> >>>>>>>>>> R-help@r-project.org 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. >>> > >>> > ______________________________________________ >>> > R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.