michael watson (IAH-C)
2004-Aug-26 08:33 UTC
[R] Problems with par() and labels with boxplot
Quite a simple one really! When I run boxplot(), the labels on the X axis are horizontal, and I want them vertical. So I did: par(las=3) boxplot(...) And my labels just aren't there anymore.... Any help???
michael watson (IAH-C) wrote:> Quite a simple one really! > > When I run boxplot(), the labels on the X axis are horizontal, and I > want them vertical. So I did: > > par(las=3) > boxplot(...) > > And my labels just aren't there anymore.... > > Any help???I guess they get clipped and you have to enlarge the margins, but you haven't given sufficient details such as version of R, OS, device you are using, a reproducible example, ... Please read the posting guide (see citation below). Uwe Ligges> > ______________________________________________ > 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
"michael watson (IAH-C)" <michael.watson at bbsrc.ac.uk> writes:> Quite a simple one really! > > When I run boxplot(), the labels on the X axis are horizontal, and I > want them vertical. So I did: > > par(las=3) > boxplot(...) > > And my labels just aren't there anymore.... > > Any help???You may need to make space for them. par(mar=....) E.g.: par(las=2,mar=c(10.1,4.1,4.1,2.1)) boxplot(list(foobarbazbletch=rnorm(10),snafu=rnorm(20))) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
michael watson (IAH-C)
2004-Aug-26 09:08 UTC
[R] Problems with par() and labels with boxplot
Hello I thought it was such a simple problem it didn't warrant too much detail! Sorry :-) OS is Suse Linux 8.2, R version is 1.9.0, device is x11. Example reproducible code: data(InsectSprays) subset <- InsectSprays[1:24,] # this creates normal horizontal text boxplot(count ~ spray, data = subset) # lets try vertical text par(las = 3) boxplot(count ~ spray, data = subset) # lets try it with long names par(las=3) boxplot(count ~ spray, data = subset, names = c('a really, really, really, really, really long name','a really, really, really, really, really long name')) # lets try adjusting the marjins par(las=3, mar=c(15,4,4,2)) boxplot(count ~ spray, data = subset, names = c('a really, really, really, really, really long name','a really, really, really, really, really long name')) I should state at this point that on Windows, R does as would be expected ie it draws the labels, but they are truncated if they are too long. However, on SuSe Linux, running R 1.9.0, it just doesn't draw the labels at all if they are too long (it does draw them if they are small enough to fit on the page) Thanks Mick -----Original Message----- From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de] Sent: 26 August 2004 09:48 To: michael watson (IAH-C) Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Problems with par() and labels with boxplot michael watson (IAH-C) wrote:> Quite a simple one really! > > When I run boxplot(), the labels on the X axis are horizontal, and I > want them vertical. So I did: > > par(las=3) > boxplot(...) > > And my labels just aren't there anymore.... > > Any help???I guess they get clipped and you have to enlarge the margins, but you haven't given sufficient details such as version of R, OS, device you are using, a reproducible example, ... Please read the posting guide (see citation below). Uwe Ligges> > ______________________________________________ > 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
michael watson (IAH-C)
2004-Aug-26 09:10 UTC
[R] Problems with par() and labels with boxplot
Yes, I thought of that, but when one is creating lots of images automatically, one doesn't always know how long one's labels are in advance. So I guess I need to check how long my labels are and truncate them if they are too large, or adjust the margins if they are just slightly bigger than normal. The different behaviour between Windows and Linux is a bit odd though (see my previous post) Mick -----Original Message----- From: Peter Dalgaard [mailto:p.dalgaard at biostat.ku.dk] Sent: 26 August 2004 09:51 To: michael watson (IAH-C) Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Problems with par() and labels with boxplot "michael watson (IAH-C)" <michael.watson at bbsrc.ac.uk> writes:> Quite a simple one really! > > When I run boxplot(), the labels on the X axis are horizontal, and I > want them vertical. So I did: > > par(las=3) > boxplot(...) > > And my labels just aren't there anymore.... > > Any help???You may need to make space for them. par(mar=....) E.g.: par(las=2,mar=c(10.1,4.1,4.1,2.1)) boxplot(list(foobarbazbletch=rnorm(10),snafu=rnorm(20))) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
michael watson (IAH-C)
2004-Aug-26 09:26 UTC
[R] Problems with par() and labels with boxplot
Nope. Even after par(las=3, mar=c(15,4,4,2)), it doesn't draw the labels, and at those margins the plot os all skwished up. I guess if I keep enlarging the margins then it maybe will draw my labels, but what use is that? What I would like it to do is simply try and squeeze the labels into the available space. It looks like what it is doing (on linux only, not on windows) is deciding there isn't enough space and therefore not drawing the labels. -----Original Message----- From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de] Sent: 26 August 2004 10:15 To: michael watson (IAH-C) Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Problems with par() and labels with boxplot michael watson (IAH-C) wrote:> Hello > > I thought it was such a simple problem it didn't warrant too much > detail! Sorry :-) > > OS is Suse Linux 8.2, R version is 1.9.0, device is x11. Example > reproducible code: > > data(InsectSprays) > subset <- InsectSprays[1:24,] > > # this creates normal horizontal text > boxplot(count ~ spray, data = subset) > > # lets try vertical text > par(las = 3) > boxplot(count ~ spray, data = subset) > > # lets try it with long names > par(las=3) > boxplot(count ~ spray, data = subset, names = c('a really, really, > really, really, really long name','a really, really, really, really, > really long name')) > > # lets try adjusting the marjins > par(las=3, mar=c(15,4,4,2)) > boxplot(count ~ spray, data = subset, names = c('a really, really, > really, really, really long name','a really, really, really, really, > really long name')) > > I should state at this point that on Windows, R does as would be > expected ie it draws the labels, but they are truncated if they are > too long. However, on SuSe Linux, running R 1.9.0, it just doesn't > draw the labels at all if they are too long (it does draw them if they> are small enough to fit on the page) > > Thanks > Mick > > > -----Original Message----- > From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de] > Sent: 26 August 2004 09:48 > To: michael watson (IAH-C) > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] Problems with par() and labels with boxplot > > > michael watson (IAH-C) wrote: > > >>Quite a simple one really! >> >>When I run boxplot(), the labels on the X axis are horizontal, and I >>want them vertical. So I did: >> >>par(las=3) >>boxplot(...) >> >>And my labels just aren't there anymore.... >> >>Any help??? > > > I guess they get clipped and you have to enlarge the margins, but you > haven't given sufficient details such as > version of R, OS, device you are using, a reproducible example, ... > > Please read the posting guide (see citation below). > > Uwe Ligges > > > >>______________________________________________ >>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 > >So my guess was right and it works for you after enlarging the margins using par(mar = ...), isn't it? Uwe Ligges