如何解决x没有重复的'有scipy?

发布于 2025-02-05 16:47:56 字数 1123 浏览 1 评论 0原文

我试图按以下方式制作曲线:

    x = all_dat['rcs']
    y = all_dat['Mean_Range']
    xnew = np.linspace(x.min(), x.max(), 200)
    cubic_interploation_model = interp1d(x, y, kind = "cubic")
    y_=cubic_interploation_model(xnew)
    pl.plot(xnew , y_)

但是我没有得到一个情节,并以错误结束:

Traceback (most recent call last):
  File "C:\Users\xxx\PycharmProjects\pythonProject1\seq_2_final.py", line 268, in <module>
    plot_alldata(df_all,p2)
  File "C:\Users\xxx\PycharmProjects\pythonProject1\seq_2_final.py", line 201, in plot_alldata
    cubic_interploation_model = interp1d(x, y, kind = "cubic")
  File "C:\Users\xxx\PycharmProjects\pythonProject1\venv\lib\site-packages\scipy\interpolate\_interpolate.py", line 564, in __init__
    self._spline = make_interp_spline(xx, yy, k=order,
  File "C:\Users\xxx\PycharmProjects\pythonProject1\venv\lib\site-packages\scipy\interpolate\_bsplines.py", line 1295, in make_interp_spline
    raise ValueError("Expect x to not have duplicates")
ValueError: Expect x to not have duplicates

Process finished with exit code 1


如何解决这个问题?

i was trying to make curve as follows:

    x = all_dat['rcs']
    y = all_dat['Mean_Range']
    xnew = np.linspace(x.min(), x.max(), 200)
    cubic_interploation_model = interp1d(x, y, kind = "cubic")
    y_=cubic_interploation_model(xnew)
    pl.plot(xnew , y_)

but i was not getting a plot and end with an error:

Traceback (most recent call last):
  File "C:\Users\xxx\PycharmProjects\pythonProject1\seq_2_final.py", line 268, in <module>
    plot_alldata(df_all,p2)
  File "C:\Users\xxx\PycharmProjects\pythonProject1\seq_2_final.py", line 201, in plot_alldata
    cubic_interploation_model = interp1d(x, y, kind = "cubic")
  File "C:\Users\xxx\PycharmProjects\pythonProject1\venv\lib\site-packages\scipy\interpolate\_interpolate.py", line 564, in __init__
    self._spline = make_interp_spline(xx, yy, k=order,
  File "C:\Users\xxx\PycharmProjects\pythonProject1\venv\lib\site-packages\scipy\interpolate\_bsplines.py", line 1295, in make_interp_spline
    raise ValueError("Expect x to not have duplicates")
ValueError: Expect x to not have duplicates

Process finished with exit code 1


How to solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文