[R] xsplineGrob() in grid: Find the point(s) two curves intersect

Shu Fai Cheung @hu|@|@cheung @end|ng |rom gm@||@com
Fri Aug 8 16:16:03 CEST 2025


Hi All,

I am new to the grid package. Please pardon me for asking a question
that may be a trivial one.

If two curves created by grid::xsplineGrob() intersect, is there any
existing function that can find this/these point(s)?

This is an example:

library(grid)

x1 <- c(0.25, 0.25, 0.75, 0.75)
x2 <- c(0.05, 0.15, 0.25, 0.35)
y1 <- c(0.25, 0.75, 0.75, 0.25)

a <- xsplineGrob(x1, y1, shape = 1)
b <- xsplineGrob(x2, y1, shape = .5)

grid.draw(a)
grid.draw(b)

Specifically, I would like to find these points without drawing the
two curves using grid.draw().

I found methods to find this/these point(s) on the internet. But this
is a frequently asked question, so I guess maybe there are existing
functions/packages that can do this. However, I could not yet find
any.

Regards,
Shu Fai Cheung



More information about the R-help mailing list