1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import pandas as pd import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import CubicSpline
df = pd.read_excel("data.xlsx", engine="openpyxl") x = df["scan"].values y = df["ms"].values
x_new = np.linspace(x.min(), x.max(), 500) cs = CubicSpline(x, y) y_smooth = cs(x_new)
plt.figure(figsize=(10, 6)) plt.plot(x_new, y_smooth, "b-", linewidth=2, label="qu xian") plt.scatter(x, y, color="red", s=20, zorder=5, label="origin dot") plt.xlabel("scan", fontsize=12) plt.ylabel("ms", fontsize=12) plt.title("scan vs ms de guanghua quxian", fontsize=14) plt.grid(True, linestyle="--", alpha=0.7) plt.legend() plt.tight_layout() plt.show()
|