2014-12-20 4 views
1

다음 데이터 프레임이 있고 ggplot을 사용하여 ind vs 값을 그려 봅니다.ggplot2의 축 조작 R

ggplot(data=stats,aes(x=ind,y=values,fill=ind))+geom_bar(stat="identity")+coord_flip()+scale_fill_brewer() 

통계
values  ind 
1 238970950 testdb_i 
2 130251496 testdb_b 
3 314350612 testdb_s 
4 234212341 testdb_m 
5 222281421 testdb_e 
6 183681071 testdb_if 
7 491868567 testdb_l 
8 372612463 testdb_p 

는 y 축에 플롯 + 00 0E의 형태이다

, + 08 1E 등등 2E + 08 대신 I는 100M 형태 필요 (억원), 200M (2 백만 달러) 등의 표시가 있습니다. ggplot에서 원하는 축을 얻으려면 어떻게해야합니까?

답변

4

당신은 시도 할 수

ggplot(data=stats,aes(x=ind,y=values,fill=ind))+ 
geom_bar(stat="identity")+ 
coord_flip()+ 
scale_fill_brewer()+ 
scale_y_continuous(labels=function(x) paste0(x/1e6,"M"))