Reputation: 1950
I have the following dataframe and I am using ggplot to plot the ind vs values.
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
The plot in y-axis is in the form of 0e+00, 1e+08, 2e+08 and so on but instead I need it in the form of 100M(hundred million), 200M(two hunderd million) etc marks. How can I get the desired axes in ggplot?
Upvotes: 1
Views: 141
Reputation: 886968
You may try
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"))
Upvotes: 4