[R] ggplot - position=position_dodge()) and scale_y_continuous

Knut Krueger rhe|p @end|ng |rom krueger-|@m||y@de
Tue Jul 30 11:50:01 CEST 2019


Hello to all,

how can I can set both  y as character to get the bars beside like 
example 1 and  use scale_y_continuous

And an additional question: why are the bar colors of  x-axes = 8 turned

datax= data.frame("fac"=c(c(rep(1,10),c(rep(2,10)))),"x"=c(c(1:10,c(1:10))),
        "y"=c(89,69,46,57,43,5,83,35,15,19,
              51,16,36, 4, 3,3,77, 5,30,61))


ggplot(data=datax, aes(x=x, y=as.character(y), fill=fac)) +
   geom_bar(stat="identity", color="black", position=position_dodge())+
   theme_minimal()+
   scale_x_continuous(breaks=c(1:12)) #+
  # scale_y_continuous(limits=c(0, 100))


ggplot(data=datax, aes(x=x, y=y, fill=fac)) +
   geom_bar(stat="identity", color="black", position=position_dodge())+
   theme_minimal()+
   scale_x_continuous(breaks=c(1:12)) +
scale_y_continuous(limits=c(0, 100))


Kind regards Knut



More information about the R-help mailing list