2012-09-11 4 views
4

다음 플롯에서 과학적 대신 y 축 레이블 형식을 보통 (xxx.xxx)으로 변경하려면 어떻게해야합니까?격자 플롯에서 축 레이블 서식 지정

df <- read.table(textConnection(" 
    ypogr_act amount   cumSum 
2012-09-20  30.00    30.00 
2012-11-19 1834.69   1864.69 
2012-11-30 2915.88   4780.57 
2012-11-30 2214.98   6995.55 
2012-12-18 21815.00   28810.55 
2012-12-19 315000.00   343810.55 
2012-12-21 1050.00   344860.55 
2012-12-28 1300.00   346160.55 
2013-01-10 1836.77   347997.32 
2013-01-17 122193.00   470190.32 
2013-03-22 415000.00   885190.32 
")->con,header=T);close(con) 

library(lattice) 
library(zoo) 
x <- zoo(df[2:3], df$ypogr_act) 

win.graph(12,8) 

print(xyplot(x, lwd=2,xlab='Μήνας', 
       col=c(rgb(127, 201, 127, max = 255),rgb(56, 108, 176, max = 255)), 
       scales = list(y=list(rot = 0,abbreviate=FALSE)))) 
trellis.focus("panel", 1, 1, highlight = F) 
panel.grid(h = -1, v = 0, col = "grey", lty = 3) 
trellis.unfocus() 

답변

4

편집 :은 간단한 해결책 있습니다 : 단지 options(scipen=10)를 설정 한 다음 코드를 실행합니다. 일시적으로 옵션을 변경하려면, 다음과 같이 작업을 수행 할 수 있습니다

oscipen <- options(scipen=10) 
## <Your plotting code> 
options(oscipen) 

이 간단한 해결책이 될 수 있지만, 여기에 내가 할 줄거야 수

## Write a customized axis annotation function 
## (Uses latticeExtra::xscale.components.log() et al. as templates.) 
yscale.components.custom <- function (lim, logsc = FALSE, ...) { 
    ans <- yscale.components.default(lim, logsc = logsc, ...) 
    ans$left$labels$labels <- format(ans$left$labels$at, digits=3, scientific=10) 
    ans 
} 

## Point to the customized function via xyplot's 'yscale.components=' argument 
xyplot(x, lwd=2,xlab='???a?', 
     col=c(rgb(127, 201, 127, max = 255),rgb(56, 108, 176, max = 255)), 
     scales = list(y=list(rot = 0,abbreviate=FALSE)), 
     yscale.components = yscale.components.custom)