Dear All, I am producing a figure with many curves on it. How do I make the legends for all those curves smaller so that it can fit the figure itself? The commands I used for ploting are: plot(x1,y1,col=1,lty=1) lines(x2,y2,col=2,lty=2) ... legend(0.3,0.4,c("name1","name2",...),col=1:20,lty=1:20) Any tips for making the legend fit the figure will very welcome! Thanks! Best, Baoqiang Cao
cex=0.8 (or whatever you like) as in legend(0.3,0.4,c("name1","name2",...),col=1:20,lty=1:20, cex=0.8) Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Baoqiang Cao Sent: Tuesday, April 18, 2006 9:38 AM To: r-help at stat.math.ethz.ch Subject: [R] how to change legend size in a figure Dear All, I am producing a figure with many curves on it. How do I make the legends for all those curves smaller so that it can fit the figure itself? The commands I used for ploting are: plot(x1,y1,col=1,lty=1) lines(x2,y2,col=2,lty=2) ... legend(0.3,0.4,c("name1","name2",...),col=1:20,lty=1:20) Any tips for making the legend fit the figure will very welcome! Thanks! Best, Baoqiang Cao ______________________________________________ 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
Use a smaller cex within legend (e.g. cex=0.75) to adjust the size of the printed text. This controls the size of the legend. Also, you can play with xjust and yjust for finer control of how the legend box is justified at the specified position. -Christos -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Baoqiang Cao Sent: Tuesday, April 18, 2006 9:38 AM To: r-help at stat.math.ethz.ch Subject: [R] how to change legend size in a figure Dear All, I am producing a figure with many curves on it. How do I make the legends for all those curves smaller so that it can fit the figure itself? The commands I used for ploting are: plot(x1,y1,col=1,lty=1) lines(x2,y2,col=2,lty=2) ... legend(0.3,0.4,c("name1","name2",...),col=1:20,lty=1:20) Any tips for making the legend fit the figure will very welcome! Thanks! Best, Baoqiang Cao ______________________________________________ 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
probably the 'cex' and 'ncol' arguments of legend() will be useful here. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Baoqiang Cao" <caobg at email.uc.edu> To: <r-help at stat.math.ethz.ch> Sent: Tuesday, April 18, 2006 3:38 PM Subject: [R] how to change legend size in a figure> Dear All, > > I am producing a figure with many curves on it. How do I make the > legends for all those curves smaller so that it can fit the figure > itself? The commands I used for ploting are: > > plot(x1,y1,col=1,lty=1) > lines(x2,y2,col=2,lty=2) > ... > legend(0.3,0.4,c("name1","name2",...),col=1:20,lty=1:20) > > Any tips for making the legend fit the figure will very welcome! > Thanks! > > Best, > Baoqiang Cao > > ______________________________________________ > 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 >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Thanks Dimitris and Charles! I think it is working. Best, Baoqiang Cao probably the 'cex' and 'ncol' arguments of legend() will be useful here. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Baoqiang Cao" <caobg at email.uc.edu > To: <r-help at stat.math.ethz.ch > Sent: Tuesday, April 18, 2006 3:38 PM Subject: [R] how to change legend size in a figure> Dear All, > > I am producing a figure with many curves on it. How do I make the > legends for all those curves smaller so that it can fit the figure > itself? The commands I used for ploting are: > > plot(x1,y1,col=1,lty=1) > lines(x2,y2,col=2,lty=2) > ... > legend(0.3,0.4,c("name1","name2",...),col=1:20,lty=1:20) > > Any tips for making the legend fit the figure will very welcome! > Thanks! > > Best, > Baoqiang Cao > > ______________________________________________ > 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 >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm