Dear users, I would like all the ticks on a boxplot (x and y) to be labeled I have checked all the par() arguments but couldn't find what I'm looking for Here is an example to show it: df <- structure(list(SPECSHOR = structure(c(1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 4L, 4L), .Label = c("cotau", "dibic", "eqgre", "gicam"), class = "factor"), Sq122.median = c(2.335835, 1.76091, 1.64717, 1.285505, 1.572405, 1.86761, 1.82541, 1.62458, 0.157813, 0.864523)), .Names = c("SPECSHOR", "Sq122.median"), class = "data.frame", row.names = c(9L, 16L, 23L, 74L, 83L, 90L, 98L, 109L, 121L, 139L)) par(mfrow=c(2,2)) ## not necessary in that example, but I do need it with my real data boxplot(Sq122.median~SPECSHOR, data=df, horizontal=TRUE) ## the upper label on the y-axis (gicam) is not shown I know I can decrease the size of the labels by setting cex.axis=0.8, but I would prefer that all labels are always there, independent of their size, without me setting their size explicitly, and even if they then overlap. Am I clear? Is it possible, and how? Thanks in advance Ivan -- Ivan CALANDRA PhD Student University of Hamburg [[alternative HTML version deleted]]
Hi Dennis, Thanks for your answer (for some reason, the only one). I could do that for sure, but I think it looks better if the labels are all horizontal. Anyway, it looks like what I wanted to do is not really possible. I have to play with the arguments I already know... Regards, Ivan Le 9/21/2010 23:27, Dennis Murphy a écrit :> Why don't you just rotate the labels 90 degrees? > > D. > > On Tue, Sep 21, 2010 at 7:23 AM, Ivan Calandra > <ivan.calandra@uni-hamburg.de <mailto:ivan.calandra@uni-hamburg.de>> > wrote: > > Dear users, > > I would like all the ticks on a boxplot (x and y) to be labeled > I have checked all the par() arguments but couldn't find what I'm > looking for > > Here is an example to show it: > df <- structure(list(SPECSHOR = structure(c(1L, 1L, 1L, 3L, 3L, > 3L, 3L, > 3L, 4L, 4L), .Label = c("cotau", "dibic", "eqgre", "gicam"), class > "factor"), Sq122.median = c(2.335835, 1.76091, 1.64717, 1.285505, > 1.572405, 1.86761, 1.82541, 1.62458, 0.157813, 0.864523)), .Names > c("SPECSHOR", "Sq122.median"), class = "data.frame", row.names = c(9L, > 16L, 23L, 74L, 83L, 90L, 98L, 109L, 121L, 139L)) > > par(mfrow=c(2,2)) ## not necessary in that example, but I do need it > with my real data > boxplot(Sq122.median~SPECSHOR, data=df, horizontal=TRUE) ## the upper > label on the y-axis (gicam) is not shown > > I know I can decrease the size of the labels by setting cex.axis=0.8, > but I would prefer that all labels are always there, independent of > their size, without me setting their size explicitly, and even if they > then overlap. > > Am I clear? Is it possible, and how? > > Thanks in advance > Ivan > > > -- > Ivan CALANDRA > PhD Student > University of Hamburg > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org <mailto:R-help@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. > >-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra@uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]]
On 2010-09-21 8:23, Ivan Calandra wrote:> Dear users, > > I would like all the ticks on a boxplot (x and y) to be labeled > I have checked all the par() arguments but couldn't find what I'm > looking for > > Here is an example to show it: > df<- structure(list(SPECSHOR = structure(c(1L, 1L, 1L, 3L, 3L, 3L, 3L, > 3L, 4L, 4L), .Label = c("cotau", "dibic", "eqgre", "gicam"), class > "factor"), Sq122.median = c(2.335835, 1.76091, 1.64717, 1.285505, > 1.572405, 1.86761, 1.82541, 1.62458, 0.157813, 0.864523)), .Names > c("SPECSHOR", "Sq122.median"), class = "data.frame", row.names = c(9L, > 16L, 23L, 74L, 83L, 90L, 98L, 109L, 121L, 139L)) > > par(mfrow=c(2,2)) ## not necessary in that example, but I do need it > with my real data > boxplot(Sq122.median~SPECSHOR, data=df, horizontal=TRUE) ## the upper > label on the y-axis (gicam) is not shown > > I know I can decrease the size of the labels by setting cex.axis=0.8, > but I would prefer that all labels are always there, independent of > their size, without me setting their size explicitly, and even if they > then overlap. > > Am I clear? Is it possible, and how? > > Thanks in advance > Ivan >Two suggestions: 1) use staxlab() in the plotrix package (but the staggered labels might look a bit strange if you have short labels). library(plotrix) boxplot(Sq122.median~SPECSHOR, data=df, horizontal=TRUE, axes=FALSE) box(); axis(1) staxlab(side=2, at=1:4, lab=levels(df$SPECSHOR), cex=.8) 2) use mtext() to control your labelling. boxplot(Sq122.median~SPECSHOR, data=df, horizontal=TRUE, axes=FALSE) box(); axis(1) axis(2, at=1:4, lab=NA) mtext(levels(df$SPECSHOR), side=2, at=1:4, line=1, cex=0.8) -Peter Ehlers