Smoothing geom_path() with scale_y_reverse() and stat_smooth()

后端 未结 1 1994
离开以前
离开以前 2021-01-25 04:46

My dataset:

reading,depth
31055,0.0
57635,0.5
34268,1.0
20926,1.5
13507,2.0
12944,2.5
13002,3.0
12892,3.5
12610,4.0
12158,4.5
12004,5.0

I\'m pl

1条回答
  •  爱一瞬间的悲伤
    2021-01-25 05:13

    I may be wrong, but I think you probably want something like this:

    dat %>%
      ggplot(aes(x = depth, y = reading)) +
      geom_path() +
      stat_smooth() +
      theme_classic() + 
      scale_x_reverse() +
      scale_y_continuous(position = "top") +
      coord_flip()
    

    which produces

    For this, you're running the smooth with depth on the x and reading on the y, then flipping the coordinates.

    0 讨论(0)
提交回复
热议问题