Specific spaces between bars in a barplot - ggplot2 - R

前端 未结 3 1112
北海茫月
北海茫月 2020-12-19 11:07

I have a simple bargraph like the following

a<-data.frame(x=c(\"total\",\"male\",\"female\",\"low education\",
            \"mid education\",\"high educ         


        
3条回答
  •  感动是毒
    2020-12-19 11:37

    If you are specifying scale_x_discrete (or y) you can simply add in a "" wherever you want a space to appear in the limits and labels statements. This is similar to the first answer but you don't have to add zero values to your dataset.

    e.g. This dataset only has 8 bars but they are grouped into two groups of four.

    scale_x_discrete( limits=c("BMayC","UMayC","BMayN","UMayN","","BJuneC","UJuneC","BJuneN","UJuneN"), labels=c("BMayC","UMayC", "BMayN","UMayN","","BJuneC","UJuneC","BJuneN","UJuneN"))

提交回复
热议问题