Center x and y axis with ggplot2

后端 未结 4 869
一整个雨季
一整个雨季 2020-11-29 10:29

Is there a way to get the axes, with labels in the center of a ggplot2 plot, like a traditional graphing calculator? I\'ve looked through the docs and there doesn\'t seem to

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 10:49

    A first approximation:

    dat = data.frame(x = 1, y =1)
    p = ggplot(data = dat, aes(x=x, y=y)) + theme_bw() +
      geom_point(size = 5) +
      geom_hline(yintercept = 0) +
      geom_vline(xintercept = 0)
    

    Plot

    Adjust limits as per SlowLearner's answer.

提交回复
热议问题