ziqizhang at hotmail.co.uk
2012-Aug-16 15:56 UTC
[R] multiple boxplots on the same figure - reducing space in between
Hi I have two vectors of integers and I am plotting a box plot that contains both vectors. I have done the following: vec1 < -scan("file1") vec2 < -scan("file2") boxplot(vec1, vec2, range=0, horizontal=TRUE, names=c("One","Two"), boxwex=0.15) I managed to get both boxplots on the same figure but there they are wide apart. Is there a way to reduce the space between them? Currently they look like this: | | one| |--[]---------| | | | | | | | | | two| |----------[]-------| | | |__________________________ I mean to reduce the space between "one" and "two" and maybe also "two" and x-axis. How can I do this? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/multiple-boxplots-on-the-same-figure-reducing-space-in-between-tp4640503.html Sent from the R help mailing list archive at Nabble.com.
Rui Barradas
2012-Aug-16 17:18 UTC
[R] multiple boxplots on the same figure - reducing space in between
Hello, Without data, I've made up my own. Try the following. x <- rnorm(100) y <- rnorm(100) bp <- boxplot(x, y, range = 0, names=c("One","Two")) bx <- bxp(bp, horizontal=TRUE, boxwex = 0.15, at = c(1, 1 + 2*0.15)) bx Note that in the call to boxplot you only need the arguments that affect the returned value. See ?boxplot, section Value. And that without the argument 'at' to bxp, its returned value would be > bx [1] 1 2 (See also ?bxp) You can make the code more readable with something like bwex <- 0.15 and then use it wherever it's needed. Hope this helps, Rui Barradas Em 16-08-2012 16:56, ziqizhang at hotmail.co.uk escreveu:> Hi > I have two vectors of integers and I am plotting a box plot that contains > both vectors. I have done the following: > > vec1 < -scan("file1") > vec2 < -scan("file2") > boxplot(vec1, vec2, range=0, horizontal=TRUE, names=c("One","Two"), > boxwex=0.15) > > > I managed to get both boxplots on the same figure but there they are wide > apart. Is there a way to reduce the space between them? > Currently they look like this: > > | > | > one| |--[]---------| > | > | > | > | > | > | > | > | > | > two| |----------[]-------| > | > | > |__________________________ > > I mean to reduce the space between "one" and "two" and maybe also "two" and > x-axis. > > How can I do this? Thanks! > > > > -- > View this message in context: http://r.789695.n4.nabble.com/multiple-boxplots-on-the-same-figure-reducing-space-in-between-tp4640503.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
ziqizhang at hotmail.co.uk
2012-Aug-17 07:23 UTC
[R] multiple boxplots on the same figure - reducing space in between
thanks! this solves my problem perfectly -- View this message in context: http://r.789695.n4.nabble.com/multiple-boxplots-on-the-same-figure-reducing-space-in-between-tp4640503p4640570.html Sent from the R help mailing list archive at Nabble.com.