'Change initial angle of spline created with scipy.interpolate.splprep
I have the following code that creates a spline:
import matplotlib.pyplot as plt
import numpy as np
from scipy import interpolate
l = [
(5, 5),
(4.92403876506104, 20.86824088833465),
(4.698463103929543, 31.710100716628343),
(9.396926207859085, 31.710100716628343),
(9.84807753012208, 20.86824088833465),
(10, 5),
]
nodes = np.array(l)
x = nodes[:, 0]
y = nodes[:, 1]
tck, u = interpolate.splprep([x, y], s=0)
xnew, ynew = interpolate.splev(np.linspace(0, 1, 100), tck, der=0)
plt.plot(x, y, "o", xnew, ynew)
plt.legend(["data", "spline"])
plt.axis([x.min() - 1, x.max() + 1, y.min() - 1, y.max() + 2])
plt.show()
However, I would like to change the initial angle of the spline to be ~90deg (closer to the next point), as so (green line):
Is there a way to do this with scipy.interpolate.splprep or another function/library that would be better suited?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


