Quantcast

Boxplot names

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Boxplot names

Jessica Streicher
When i make Boxplots with a lot of boxes, the names of them get only written down every second "column".
Since they aren't in any way ordered, you don't see anymore to what they belong.

example:

l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20))

Is there a way to show them all, or do i have to split the plots?
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Boxplot names

Peter Ehlers
On 2012-07-19 06:58, Jessica Streicher wrote:
> When i make Boxplots with a lot of boxes, the names of them get only written down every second "column".
> Since they aren't in any way ordered, you don't see anymore to what they belong.
>
> example:
>
> l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20))
>
> Is there a way to show them all, or do i have to split the plots?

[Actually, your example is not reproducible without error - see
?sample.]

Two solutions:
1. use the cex.axis argument to reduce the label size.
2. check out the staxlab() function in the plotrix package.

Peter Ehlers

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Boxplot names

Jessica Streicher
Copied the wrong lines, sry

l<-rep(list(1:5),20); boxplot(l,names=sample(1:20,20))

of course.

thanks for the answer

.
On 19.07.2012, at 16:17, Peter Ehlers wrote:

> On 2012-07-19 06:58, Jessica Streicher wrote:
>> When i make Boxplots with a lot of boxes, the names of them get only written down every second "column".
>> Since they aren't in any way ordered, you don't see anymore to what they belong.
>>
>> example:
>>
>> l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20))
>>
>> Is there a way to show them all, or do i have to split the plots?
>
> [Actually, your example is not reproducible without error - see
> ?sample.]
>
> Two solutions:
> 1. use the cex.axis argument to reduce the label size.
> 2. check out the staxlab() function in the plotrix package.
>
> Peter Ehlers
>
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Boxplot names

Bert Gunter
You might alternatively find the horizontal = TRUE with las=2 to be useful; e.g.

dat <- data.frame(val=rnorm(100),
  grp=rep(apply(matrix(sample(letters,100,rep=TRUE),nr=5),2,paste,collapse=""),5))

boxplot(val~grp,horizontal=TRUE,data=dat,las=2)

## Note that las=2 might also help with horizontal=FALSE, but I prefer
reading Roman language labels horizontally. CJK languages might prefer
vertically.

-- Bert




On Thu, Jul 19, 2012 at 7:58 AM, Jessica Streicher
<[hidden email]> wrote:

>
> Copied the wrong lines, sry
>
> l<-rep(list(1:5),20); boxplot(l,names=sample(1:20,20))
>
> of course.
>
> thanks for the answer
>
> .
> On 19.07.2012, at 16:17, Peter Ehlers wrote:
>
> > On 2012-07-19 06:58, Jessica Streicher wrote:
> >> When i make Boxplots with a lot of boxes, the names of them get only written down every second "column".
> >> Since they aren't in any way ordered, you don't see anymore to what they belong.
> >>
> >> example:
> >>
> >> l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20))
> >>
> >> Is there a way to show them all, or do i have to split the plots?
> >
> > [Actually, your example is not reproducible without error - see
> > ?sample.]
> >
> > Two solutions:
> > 1. use the cex.axis argument to reduce the label size.
> > 2. check out the staxlab() function in the plotrix package.
> >
> > Peter Ehlers
> >
> >
>
> ______________________________________________
> [hidden email] 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.




--

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Boxplot names

John Fox
In reply to this post by Jessica Streicher
Dear Jessica,

You might try par(las=2) to rotate the tick labels to be perpendicular to the axes.

I hope this helps,
 John

------------------------------------------------
John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/
       
On Thu, 19 Jul 2012 16:58:26 +0200
 Jessica Streicher <[hidden email]> wrote:

> Copied the wrong lines, sry
>
> l<-rep(list(1:5),20); boxplot(l,names=sample(1:20,20))
>
> of course.
>
> thanks for the answer
>
> .
> On 19.07.2012, at 16:17, Peter Ehlers wrote:
>
> > On 2012-07-19 06:58, Jessica Streicher wrote:
> >> When i make Boxplots with a lot of boxes, the names of them get only written down every second "column".
> >> Since they aren't in any way ordered, you don't see anymore to what they belong.
> >>
> >> example:
> >>
> >> l<-rep(list(1:5),20); boxplot(l,names=sample(20,1:20))
> >>
> >> Is there a way to show them all, or do i have to split the plots?
> >
> > [Actually, your example is not reproducible without error - see
> > ?sample.]
> >
> > Two solutions:
> > 1. use the cex.axis argument to reduce the label size.
> > 2. check out the staxlab() function in the plotrix package.
> >
> > Peter Ehlers
> >
> >
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Boxplot names

S Ellison-2
In reply to this post by Jessica Streicher
> When i make Boxplots with a lot of boxes, the names of them
> get only written down every second "column".
> Since they aren't in any way ordered, you don't see anymore
> to what they belong.

Jessica,

Another possibility if the names are long is to use abbreviated factor levels. The labels appear when there is room; they are only omitted if there isn't space. So you could use  something like

y <- rnorm(55)
g <- factor(paste("Unduly long factor level name", rep(1:5, each=11)))

boxplot(y~g) #Not useful

ga <- g
levels(ga) <- abbreviate(levels(g))
boxplot(y~ga) #Much better

If you don't want to change the actual factor level labels, use something like

boxplot(y~g, axes=FALSE, at=1:nlevels(g))
box()
axis(2)
axis(1, at=1:nlevels(g), labels=abbreviate(levels(g)))
# or
axis(1, at=1:nlevels(g), labels=abbreviate(levels(g)), las=2) #vertical text


S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
[hidden email] 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.
Loading...