[R] How to control number of significant digits (figures) in y-axis?

willow1980 jianghua.liu at shef.ac.uk
Mon Jan 11 17:22:37 CET 2010


Dear Peter,
Many thanks! 
Your code works perfectly. I hope this method will also be helpful to other
users with similar problems.
Best regards,
Jianghua


Peter Ehlers wrote:
> 
> Use the 'scales=' argument together with formatC:
> 
> x <- 1:10
> y <- sample(10)
> xyplot(y ~ x,
>    scales = list(
>               y = list(
>                 at = 1:10,
>                 lab = formatC(1:10,
>                   format = "f", digits = 1))))
> 
> ?formatC
> ?xyplot
> 
>   -Peter Ehlers
> 
> 
> willow1980 wrote:
>> Dear R users,
>> I encounter a problem regarding number of significant digits on y-axis.
>> Below is my basic code:
>> myplotkid<-xyplot(expected_offspringnumber~afr|decade,groups=SES,data1,
>> auto.key=list(space="right"),layout=c(9,1),xlab="",ylab="Offspring
>> number",
>> aspect="fill",scales=list(x=list(draw=F)),strip=T)
>>>From this code, you can see there are 9 small panels in a single row.
Thus,
>> there is only one y-axis in the left. However, number of offspring
>> displayed
>> is in integer. How to display such numbers in decimal numbers, e.g.
>> decimal
>> number with one digit after decimal point? Does someone have any idea to
>> fulfil this aim?
>> Thank you very much for kind help!
>> Best regards,
>> Jianghua
> 
> -- 
> Peter Ehlers
> University of Calgary
> 403.202.3921
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://n4.nabble.com/How-to-control-number-of-significant-digits-figures-in-y-axis-of-a-xyplot-tp1010693p1011339.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list