Stephane Bourgeois
2008-Aug-06 14:37 UTC
[R] Font size in plots (I do NOT understand par help)
Hi, I do not get how par works, help please. Let's say I have a simple plot: plot(1:10) I want to change the font size for the x axis... how do I do that? Thank you, Stephane -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a compa ny registered in England with number 2742969, whose registered office is 2 15 Euston Road, London, NW1 2BE. [[alternative HTML version deleted]]
Leandro Marino
2008-Aug-06 14:49 UTC
[R] RES: Font size in plots (I do NOT understand par help)
> par(ps=15) > plot(1:10)-----Mensagem original----- De: r-help-bounces em r-project.org [mailto:r-help-bounces em r-project.org]Em nome de Stephane Bourgeois Enviada em: quarta-feira, 6 de agosto de 2008 11:38 Para: r-help em r-project.org Assunto: [R] Font size in plots (I do NOT understand par help) Hi, I do not get how par works, help please. Let's say I have a simple plot: plot(1:10) I want to change the font size for the x axis... how do I do that? Thank you, Stephane -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a compa ny registered in England with number 2742969, whose registered office is 2 15 Euston Road, London, NW1 2BE. [[alternative HTML version deleted]] ______________________________________________ R-help em 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.
Peter Dalgaard
2008-Aug-06 14:56 UTC
[R] Font size in plots (I do NOT understand par help)
Stephane Bourgeois wrote:> Hi, > > > > I do not get how par works, help please. > > > > Let's say I have a simple plot: plot(1:10) > > > > I want to change the font size for the x axis... how do I do that? >Well, you start by reading help(par) multiple times, and then play around.... Start with, e.g. plot(1:10, cex.axis=2) The problem with that is that it controls the y axis too, so plot(1:10, cex.axis=2, yaxt="n") axis(2) or vice versa plot(1:10, xaxt="n") axis(1, cex.axis=2) If you didn't actually mean the values, consider similar techniques involving cex.lab or cex.sub and the title() function. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Prof Brian Ripley
2008-Aug-06 15:03 UTC
[R] Font size in plots (I do NOT understand par help)
On Wed, 6 Aug 2008, Stephane Bourgeois wrote:> Hi, > > > > I do not get how par works, help please. > > > > Let's say I have a simple plot: plot(1:10) > > > > I want to change the font size for the x axis... how do I do that?You mean of the tick labels (as distinct from the ylab)? Look at plot(1:10, xaxt="n") axis(1, cex.axis=1.5) and then look up ?par for the descriptions.> > > > Thank you, > > > > Stephane > > > > > -- > The Wellcome Trust Sanger Institute is operated by Genome Research > > Limited, a charity registered in England with number 1021457 and a > compa > ny registered in England with number 2742969, whose registered > office is 2 > 15 Euston Road, London, NW1 2BE. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Wed, Aug 06, 2008 at 03:37:48PM +0100, Stephane Bourgeois wrote:> Hi, > > > > I do not get how par works, help please. > > > > Let's say I have a simple plot: plot(1:10) > > > > I want to change the font size for the x axis... how do I do that?OK, so firstly go to the help page for par by typing ?par I'm not saying you should read the whole thing right now. There's quite a lot of options. But you want to change something to do with axes, so search for the word 'axis'. The 3rd hit I get shows the following lines. 'cex.axis' The magnification to be used for axis annotation relative to the current setting of 'cex'. 'cex.lab' The magnification to be used for x and y labels relative to the current setting of 'cex'. Note that one of those refers to the axis annotation (i.e the numbers along the axis), whereas the other refers to the axis labels. Now there's two ways to proceed. First, note that par() is a function. When you call the function, it changes the values of the graphics parameters you specify. So say you want to make the axis labels font twice as big. The first method would be par(cex.lab=2) plot(1:10) An alternative method is as follows: plot(1:10, cex.lab=2) If you don't know why that works, look at the help page for plot by typing ?plot, and read the stuff about the three dots (...) If you go for the first method, one useful trick is to save the previous values, so you can restore them. You would do that like this: old.par.settings <- par(cex.lab=2) plot(1:10) ## now restore them par(old.par.settings) That works because the function par() happens to spit out the old values as its return value, although its effect is to change them. To be fair, you actually asked how to change the font size on the x-axis, whereas the above changes it on both axes. AFAIK there's no par() options that do exactly that, so the way I'd do it would be to first plot without any axis labels, and subsequently add the x- and y- labels independently using the title() function, and passing extra 'cex.lab=' arguments in the same way as the second method above:> plot(1:10, xlab="", ylab="") > title(xlab="xlab title", cex.lab=3) > title(ylab="ylab title", cex.lab=.5)Dan> > > > Thank you, > > > > Stephane > > > > > -- > The Wellcome Trust Sanger Institute is operated by Genome Research > > Limited, a charity registered in England with number 1021457 and a > compa > ny registered in England with number 2742969, whose registered > office is 2 > 15 Euston Road, London, NW1 2BE. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.