2016-04-22 12 views
2

y軸の値を変更する際に問題が発生します。ggplot y軸の値を10,000単位で表示

これは私のDFである:

Years <-c("1997","1997","1997", "1998","1998","1998", "1999", "1999","1999","2000", "2000", "2000") 
Type <-c("Export","Import", "Production","Export","Import", "Production", "Export","Import", "Production","Export","Import", "Production") 
Amount <- c(12063595,19465000,38591914,14929732,20941620,42570725,33598846,30533486,62633597,39755626,30129958,49493053) 
df <-data.frame(Years, Type, Amount) 

そして、これは私が作り出したグラフである:あなたが、私は非常に高い数字(最高= 62633597)を持っており、今、彼ら見ることができるように

ggplot(data=df, aes(x=Years, y=Amount, group=Type, colour=Type)) + 
    geom_line(size=1.1) + 
    scale_colour_manual(values=cbPalette)+ 
    theme_bw()+ 
    ylab("Timber [in 10,000 m3(r)]") + 
    xlab("Years") + 
    expand_limits(y=0) + guides(colour = guide_legend(override.aes = list(size=3)))+ 
    theme(legend.title=element_blank(), 
     legend.position="top", 
     legend.text = element_text(size=20), 
     axis.text.x = element_text(size=20), axis.title.x=element_text(size=20), 
     axis.text.y = element_text(size=20), axis.title.y=element_text(size=20)) 

科学的に表示されます(6e + 07)。 私はラベルに示されているように「10万」という値を表示したいと思います。それを行う方法があるかどうかは全く考えていません。

答えて

2

あなたは

ggplot(data=df, aes(x=Years, y=Amount/10000, group=Type, colour=Type)) 

に最初の行を変更した場合、あなたはこれを取得します:

は、あなたが何を望むか、このですか?

私がから来ているものをパッケージcbPaletteわからないので、私は唯一のscale_colour_manual(values=cbPalette)を削除する必要がありました注...

enter image description here

+0

私のああ!そのような簡単な解決策...ありがとうございました! また、cbPaletteとの混乱について私のお詫び申し上げます。私はそれを取っておくべきだったが、忘れてはならなかった。 – samyandi

関連する問題