python绘制坐标系_python-有没有办法通过分散的X,Y坐标绘制“...

这将是适合您数据的经验函数:

import matplotlib.pyplot as plt

import numpy as np

from scipy.optimize import curve_fit

x = np.asarray([731501.13, 731430.24, 731360.29, 731289.36, 731909.72, 731827.89,

731742. , 731657.74, 731577.95, 731502.64, 731430.39, 731359.12,

731287.3 , 731214.21, 732015.59, 731966.88, 731902.67, 731826.31,

731743.79, 731660.94, 731581.29, 731505.4 , 731431.95, 732048.71,

732026.66, 731995.46, 731952.18, 731894.29, 731823.58, 731745.16,

732149.61, 732091.53, 732052.98, 732026.82, 732005.17, 731977.63,

732691.84, 732596.62, 732499.45, 732401.62, 732306.18, 732218.35,

732141.82, 732080.91, 732038.21, 732009.08, 733023.08, 732951.99,

732873.32, 732787.51])/732 -1000

y = np.asarray([7873771.69, 7873705.34, 7873638.03, 7873571.73, 7874082.33,

7874027.2 , 7873976.22, 7873923.58, 7873866.35, 7873804.53,

7873739.58, 7873673.62, 7873608.23, 7873544.15, 7874286.21,

7874197.15, 7874123.96, 7874063.21, 7874008.78, 7873954.69,

7873897.31, 7873836.09, 7873772.38, 7874564.62, 7874448.23,

7874341.23, 7874246.59, 7874166.93, 7874100.4 , 7874041.77,

7874912.56, 7874833.09, 7874733.62, 7874621.43, 7874504.65,

7874393.89, 7875225.26, 7875183.85, 7875144.42, 7875105.69,

7875064.49, 7875015.5 , 7874954.94, 7874878.36, 7874783.13,

7874674. , 7875476.18, 7875410.05, 7875351.67, 7875300.61])/7873 - 1000

def my_func( x, x0, y0, a, b, c, t, s):

xs = x-x0

p = a * xs**3 + b * xs**2 + c * xs + y0

t = t * np.tanh( s * xs )

return p + t

xth = np.linspace( -1.15, 1.5, 50 )

yth = my_func( xth, 0.03, 0.18, .01, 0, 0.05, .05 , 10)

sol, err = curve_fit( my_func, x, y, p0=[0.03, 0.18, .01, 0, 0.05, .05 , 10] )

print sol

fig = plt.figure()

ax = fig.add_subplot( 1, 1, 1 )

ax.scatter( x, y )

ax.plot( xth, yth )

ax.plot( xth, my_func( xth, *sol) )

plt.show()

给予

>>[ 2.86281016e-02 1.95292660e-01 9.62290944e-03 -1.26304655e-02 5.11281073e-02 4.63955967e-02 1.02260568e+01]

cwqJS.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值