[R] Boxplot intervals combining names

Sarah Goslee sarah.goslee at gmail.com
Sun Jun 13 16:08:13 CEST 2010


Hi Ross,

You are indeed missing something simple. If there are 60 bars, the axis
runs from 1 to 60, and you want a label at every second one, rather than
at every one.

Like this (with 10 instead of 60):


testdata <- matrix(runif(100), ncol=10)
boxplot(testdata, xaxt="n")
axis(1, at=seq(1.5, 9.5, by=2), labels=letters[1:5])

Sarah

On Sun, Jun 13, 2010 at 9:40 AM, RCulloch <ross.culloch at dur.ac.uk> wrote:
>
> Hi R users,
>
> This seems like a simple problem but I have searched nabble for the answer
> and can't seem to find it.
>
> All I want to do is produce a boxplot where I have two boxes for one
> Individual but on the xaxis I only have one tick mark centred between the
> boxes so I can add the Individuals' name. I have 30 IDs and have shown the
> code I use below for a couple of IDs, I figure the data is not important
> here so it's not included.
>
> boxplot (ID1[,8],ID1[,9],ID2[,8],ID2[,9],xaxt='n')
>
> I have put all the ID names in as 'names1'
>
> and I have tried numerous variations on axis, e.g.
>
> axis(1,at=1:30,labels=names1)
>
> but nothing works: the boxplot appears to 'know' that there are 60 tick
> marks (data) and therefore only puts ticks half way up the graph, and using:
>
> axis(1,at=1:30,labels=names1)
>
> complains that there is a difference of length, which of course there is!
>
> I must be missing something simple here, but any suggestions would be
> gratefully received,
>
> Ross
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Boxplot-intervals-combining-names-tp2253442p2253442.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.
>



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list