set upper limit in ggplot to include label greater than the maximum value

后端 未结 5 934

My data range always seems to be greater than the top label in the y-axis. Is there a way I can automatically include it without manually setting limits?

e.g. in

5条回答
  •  独厮守ぢ
    2020-12-16 02:07

    Maybe with scale_y_continuous and the expand argument:

    ggplot(data.frame(x=1:10, y=c(11:17,5:3)), aes(x,y)) +
      geom_point() +
      scale_y_continuous(expand=c(0.5, 0.5))
    

提交回复
热议问题