x axis limits for ggplot bar graph in R

后端 未结 1 1046
轮回少年
轮回少年 2021-01-15 06:17

How can I set limits on the x axis for a ggplot graph? My code is

    ages <- 6:16
    mu <-  c(0.66849315, 0.55386301,  1.17609589, 0.26111781,  0.466         


        
相关标签:
1条回答
  • 2021-01-15 07:01

    Use scale_x_continuous rather then scale_x_discrete.

    df_GP  + scale_x_continuous(breaks=ages)
    

    enter image description here

    If you want to zoom the x labels you can add limits parameter:

     scale_x_continuous(breaks=ages,limits=c(10, 17)) 
    
    0 讨论(0)
提交回复
热议问题