所以我已经坚持了一段时间。我想知道如何使用pchip或三次样条等不同方法在Semilogx图上进行插值。到目前为止,这是我拥有的代码。
from scipy.interpolate import PchipInterpolator
import numpy as np
import matplotlib.pyplot as plt
data = [[0.425, 100],
[0.18, 96],
[0.090, 85],
[0.075, 80],
[0.04, 59],
[0.02, 39],
[0.01, 26],
[0.005, 15],
[0.0015, 8]]
data = np.array(data)
x = data[:, 0]
y = data[:, 1]
x = np.flip(x)
y = np.flip(y)
interp_obj = PchipInterpolator(x, y)
new_x_vals = np.arange(0.0015, 0.42501, 0.0001)
new_y_vals = interp_obj(new_x_vals)
plt.semilogx(new_x_vals, new_y_vals)
plt.xlabel("Particle Diameter (mm) - Log Scale")
plt.ylabel("Percent Finer")
plt.show()
似乎这并不像它应该的那样平滑。我应该在插值之前转换数据吗?