How to annotate a reference line at the same angle as the reference line itself?

前端 未结 4 345
情歌与酒
情歌与酒 2020-12-03 05:24

I need to find a way to annotate a reference line at the same angle as the reference line itself.

The following statement will produce the reference line and the la

4条回答
  •  死守一世寂寞
    2020-12-03 06:30

    An addendum to @Andrie's answer: instead of hard-coding the aspect ratio in the plot the first time to get the relative coordinate scales, you can recover the current working aspect ratio with the following function:

    getCurrentAspect <- function() {
       uy <- diff(grconvertY(1:2,"user","inches"))
       ux <- diff(grconvertX(1:2,"user","inches"))
       uy/ux
    }
    

    So you can create your plot: set asp <- getCurrentAspect(); and proceed with the rest of @Andrie's solution.

    For all I know this function exists somewhere in the R ecosystem, but I haven't seen it ...

提交回复
热议问题