plot - Calculate a 2D spline curve in R -
I am trying to calculate the spline curve like a bezier which passes through a sequence of x-y coordinate. An example would be in the cscvn function like the following code: Matlab ():
I believe ( grid.xspline function?) To do this, but I installed a stored version of the package I have not been able to, and in reality what I would like to do is not getting any examples on the lines
Bezier package looks promising too, but it is very slowAnd I can not get quite right:
library (bezier) Set.seed (1) n & lt; -10 x & lt; - runif (n) y & lt; - runif (n) p & lt; Cbind (x, y) xlim & lt; -c (min (x) - 0.1 * difference (range (x)), c (max (x) + 0.1 * difference (range (x)) ylim & lt; -c (min (y) - 0.1 * diff (Range (y)), c (maximum (y) + 0.1 * difference (range (y))) plot (p, axle = axle, yilm = yelim) text (p, labels = sic (n), pause = 3) BP & Lt; - PointOnBizIer (BP $ points) Arrow (BP $ points) [BOP $ points [NRO (BP $ points -1.1), BP $ points [NRO (BP $ points) -1,2) BP $ points [no (bp $ points), 2])
As you can see, it does not exceed any point except the end values.
I appreciate some guidance here!
This can not be the best method, bit grid disable certain Ly It is not included as a default package with R installation, it is the built-in graphics engine for plotting libraries such as lettuce and gzipplot. You do not need to install it, you should be able to load it. grid.xpline
set.seed (1) n < - 10 x & lt; - runif (n) How to translate your code to use y & lt (- (x)), c (maximum (x) + 0.1 * difference (range (x))) ylim & lt; - C (minimum (Y) - 0.1 * difference (range (Y)), C (Max (Y) + 0.1 * difference (range (Y))) library (grid) grid. Navepage () pushviewport (viewport (xscale = xlim, yscale = ylim)) grid.points (x, y, pch = 16, size = unit (2, "mm"), default.units = "native") grid.text Grid.xspline (x, y, size = c (0, representative (-1), (seq (n), x, y, only = c ("center", "bottom"), default. Units = "native" 10/2), 0), open = TRUE, default.units = "native") popViewport () resulting in
Note that the grid is very low level, so it's not super easy to work , But where else Allows fie control you plot.
And if you want to draw points on the curve rather than pulling it, see ? XsplinePoints help page
Comments
Post a Comment