Skip to content

changing y-axis intervals in a boxplot

9 messages · Pascal Oettli, Jim Lemon, Rui Barradas +2 more

#
Hello,

?par (particularly the 'yaxt' argument)
?axis ('side' and 'at' arguments)

Hope this help,
Pascal
On 29/03/13 16:37, Berg, Tobias van den wrote:
#
Thank you Pascal but unfortunelately i still didn't figure out how to change the numbers presented at the y-axis.

I looked up your suggestions but if I'm right, yaxt can set if the axis is presented (yaxt="s") or suppressed (yaxt="n") which does not help for changing the values on the y-axis.

The 'at' argument did solve my problem but in a clumsy way. Although I'm happy that I managed, does anyone know how to do the same job in a more convenient way?

This is the 'clumsy' code I used:

boxplot((fitted(finalfit4) *100) ~ instabilitydata2$MRI_Diag_Instab_rev, ylim=c(0,100), xlab="MRA diagnosis", ylab="Predicted probability (%)")
axis(side=2, at="10")
axis(side=2, at="30")
axis(side=2, at="50")
axis(side=2, at="70")
axis(side=2, at="90")

Kind regards, 

Tobias

-----Oorspronkelijk bericht-----
Van: Pascal Oettli [mailto:kridox at ymail.com] 
Verzonden: vrijdag 29 maart 2013 8:44
Aan: Berg, Tobias van den
CC: 'r-help at r-project.org'
Onderwerp: Re: [R] changing y-axis intervals in a boxplot

Hello,

?par (particularly the 'yaxt' argument)
?axis ('side' and 'at' arguments)

Hope this help,
Pascal
On 29/03/13 16:37, Berg, Tobias van den wrote:
#
Hi,

Example adapted from ?boxplot

par(las=1, mfrow=c(2,1))
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", yaxt='n')
axis(2, at=seq(0,25,2.5))
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", yaxt='n')
axis(2, at=seq(0,25,1))

HTH,
Pascal
On 29/03/13 18:22, Berg, Tobias van den wrote:
#
And if you would like to be able to read the crowded axis:

boxplot(count ~ spray, data = InsectSprays, col = "lightgray", yaxt='n')
library(plotrix)
staxlab(2, at=seq(0,25,1),cex=0.8)

Jim
On 03/29/2013 08:36 PM, Pascal Oettli wrote:
#
Hello,

You can use

axis(side=2, at=c(10, 30, 50, 70, 90))

or

axis(side=2, at=seq(10, 90, by = 20))

Hope this helps,

Rui Barradas

Em 29-03-2013 09:22, Berg, Tobias van den escreveu:
#
Every week, I learn something new with R-help.

Pascal
On 29/03/13 20:23, Jim Lemon wrote:
#
Thank you all,

Guess you'll learn everyday new stuff, especially in R.

Tobias

-----Oorspronkelijk bericht-----
Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Pascal Oettli
Verzonden: vrijdag 29 maart 2013 12:33
CC: 'r-help at r-project.org'
Onderwerp: Re: [R] changing y-axis intervals in a boxplot

Every week, I learn something new with R-help.

Pascal
On 29/03/13 20:23, Jim Lemon wrote:
______________________________________________
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.
#
This can also be done without the axis() function:
cex.axis=0.6,
     col = "lightgray")
cex.axis=0.6, 
     col = "lightgray")

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352