Python散点图拟合

news/2025/2/21 7:41:12/

散点图拟合

import matplotlib.pyplot as plt
import numpy as npx = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
y = np.array([5760, 3600, 1620, 1260, 1080, 900, 1080, 1800, 3060, 4680, 2880, 5040, 4140, 5580, 5040, 4860, 3780,3420, 4860, 3780, 4860, 5220, 4860, 3600])
z1 = np.polyfit(x, y, 4) # 用4次多项式拟合
p1 = np.poly1d(z1)
print(p1) # 在屏幕上打印拟合多项式
yvals=p1(x) # 也可以使用yvals=np.polyval(z1,x)
plot1=plt.plot(x, y, '*',label='original values')
plot2=plt.plot(x, yvals, 'r',label='polyfit values')
plt.xlabel('x axis')
plt.ylabel('y axis')
plt.legend(loc=4) # 指定legend的位置,读者可以自己help它的用法
plt.title('polyfitting')
plt.show()

运行效果如下:
在这里插入图片描述运行结果可得出拟合多项式
欢迎加群:620139909
在这里插入图片描述


http://www.ppmy.cn/news/136698.html

相关文章

常用的免费好用的DNS有哪些?

阿酷TONY 原创文章 关键词:免费dns、百度dns、阿里dns、114 dns 、Google DNS 2019-1-24 DNS(Domain Name Server,域名服务器)是进行域名(domain name)和与之相对应的IP地址 (IP address)转换的服务器。DNS中保存了一张域名(doma…

组建虚拟局域网,建立 IPv6 隧道

转载至:https://moe.best/tutorial/zerotier-ipv6.html 使用 ZeroTier 建立 IPv6 隧道 首先,你需要一台 VPS,并注册一个 ZeroTier 帐号:https://my.zerotier.com VPS 上的准备工作 编辑/etc/sysctl.conf,加入 net.ipv…

win10下 docker build 报错 “Failed to fetch xxxxxxxx Temporary failure resolving 'archive.ubuntu.com'”

错误信息 在docker中搭建禅道的时候执行docker build -t zentao ./命令后执行到apt-get update && apt-get install指令的时候报错,错误如下: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failur…

常用IPV6 DNS地址-供公网测试IPV6使用

谷歌IPV6 DNS地址: 首选:2001:4860:4860::8888 备用:2001:4860:4860::8844 阿里 IPv6 DNS (Alidns) 阿里云公共DNS已支持IPv6协议,成功国内首家向公众提供免费IPv4/v6公共解析服务的提供商。 2400:3200::1 2400:3200:baba::…

ubuntu解决域名不能访问的问题

刚装好的ubuntu22.04或ubuntu20.04不能访问百度,然后发现只能ping通ip,而不能ping通www.baidu.com,网上查了下解决方案, 方案一:修改dns: 修改 /etc/resolv.conf配置文件,但很快就会被覆盖&…

常用 DNS 分享

DNS 域名系统,他可以将域名(例如www.baidu.com)转换为计算机用于在互联网上的 IP 地址的系统。它允许用户使用易于记住的域名访问网站,而不必记住IP地址。全球常用DNS:Google Public DNS: 8.8.8.8 and 8.8.4.4 OpenDN…

全球免费公共 DNS 解析服务器 IP 地址列表推荐 (解决无法上网/加速/防劫持)

全球免费公共 DNS 解析服务器 IP 地址列表推荐 基本上接触过网络相关知识的人应该多少都会听过 DNS 这个名词。因为 DNS 它非常重要,在我们上网的过程中扮演着重要的角色——“将网址/域名解析成 IP 地址”。 如果配置了不合理的 DNS 服务器,可能会导致…

Linux 网络配置与网关设置

多网卡配置: metric 120 dns-nameservers 192.168.15.1 166.111.8.28 166.111.8.29 114.114.114.114 8.8.8.8 网关设置: ref: linux - How to configure systemd-resolved and systemd-networkd to use local DNS server for resolving local domains …