python的曲线平滑工具,及python画一条线中包含不同粗细不同颜色的画线方法
2024-10-29 15:33:49
from scipy.signal import savgol_filter
import matplotlib.pyplot as plt
cc = savgol_filter(c, 99, 1)
plt.plot(c)
plt.plot(cc)
plt.show()
from matplotlib.collections import LineCollection
import numpy as np
import math
import matplotlib.pyplot as plt pi = 3.1415 x = np.linspace(0, 4*pi, 100)
y = [math.cos(xx) for xx in x]
lwidths = abs(x)
color = []
for i in range(len(y)):
if i < 5:
color.append('#FF0000')
else:
color.append('#000000') print(x)
print(y)
print('--------------------------------------')
points = np.array([x, y]).T.reshape(-1, 1, 2)
print(points)
print('--------------------------------------')
segments = np.concatenate([points[:-1], points[1:]], axis=1)
print(segments)
lc = LineCollection(segments, linewidths=lwidths, color=color) ax = plt.axes()
ax.set_xlim(min(x), max(x))
ax.set_ylim(min(y), max(y))
ax.add_collection(lc)
plt.show() '''
fig, a = plt.subplots()
a.add_collection(lc)
a.set_xlim(0, 4*pi)
a.set_ylim(-1.1, 1.1)
fig.show()
'''
最新文章
- 关于不断刷新界面jsp+ajax
- js注册读秒进度条
- 开发中/listfile.jsp(11,31) quote symbol expected 这个错误
- SQL Server 2008中的hierarchyid
- Android 点击事件,4种回调。
- Xcode7.0设置网络白名单
- ssh自学笔记
- 「mysql优化专题」这大概是一篇最好的mysql优化入门文章(1)
- SpringBoot+Mybatis+ Druid+PageHelper 实现多数据源并分页
- MfgTool (i.MX53)使用
- Eclipse——手把手教新手安装Eclipse
- Spring Security 整合freemaker 实现简单登录和角色控制
- Perl的浅拷贝和深度拷贝
- 常见的HTTP报头(头参数)
- ubuntu14.04下开启ssh服务
- LoadIcon
- 【题解】 [HAOI2016]食物链 (拓扑排序)
- idea快捷键 好的网址收藏
- SharpMap源代码解析
- eclipse egit 解决冲突