Moving x or y axis together with tick labels to the middle of a single ggplot (no facets)

后端 未结 4 1057
不思量自难忘°
不思量自难忘° 2020-12-03 06:35

I made the following plot in Excel:

But then I thought I would make it prettier by using ggplot. I got this far:

If you\'re curious, the da

4条回答
  •  醉酒成梦
    2020-12-03 06:59

    I tried to change the theme's axis.text.x,but only can change hjust.
    So I think you can delete axis.text.x,then use geom_text() to add.
    For example:

    test <- data.frame(x=seq(1,5), y=seq(-1,3))
    ggplot(data=test, aes(x,y)) +
      geom_line() +
      theme(axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
      geom_text(data=data.frame(x=seq(1,5), y=rep(0,5)), label=seq(1,5), vjust=1.5)
    

    Maybe these codes are useful.

提交回复
热议问题