0

I want to vizualize my data as a barplot and I have this two codes. First is working fine but when I tried to add last line of code in the second code (ylim argument) Rstudio send me this message "Scale for 'y' is already present. Adding another scale for 'y', which will replace the existing scale." Is somehow possible to add breaks and limit the Y axis in one argument?

ggplot(df, aes(x=rok, y=pocetimigrantu)) + geom_bar(stat="identity")+
 scale_x_continuous(breaks=seq(1991,2014,1))+
 scale_y_continuous(breaks=seq(0,1500000,100000))+
 xlab('rok')+
 ylab("celkový počet imigrantů")



ggplot(df, aes(x=rok, y=pocetimigrantu)) + geom_bar(stat="identity")+
  scale_x_continuous(breaks=seq(1991,2014,1))+
  scale_y_continuous(breaks=seq(500000,1500000,50000))+
  xlab('rok')+
  ylab("celkový počet imigrantů")+
  ylim(500000, 1500000)
jeremycg
  • 24,657
  • 5
  • 63
  • 74
Cejkaad
  • 1
  • 1
  • 2
    add your limits to `scale_y_continuous(breaks = seq(0,1500000,100000), limits = c(500000, 1500000))`. See the help `?scale_y_continuous` for examples. – Gregor Thomas Feb 05 '16 at 20:20
  • I found this yesterday, but when i add the limits argument Y axis is alright but bars in the graph just disappear. I think its not what should happened, but dont know what do about it. – Cejkaad Feb 07 '16 at 11:55
  • Do your bars go over your maximum limit? You need to make sure your upper limit is bigger than the bars. If you [make your example reproducible](http://stackoverflow.com/q/5963269/903061) then we won't have to guess at the problem. – Gregor Thomas Feb 08 '16 at 05:34

0 Answers0