zoukankan      html  css  js  c++  java
  • python的曲线平滑工具,及python画一条线中包含不同粗细不同颜色的画线方法

    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()
    '''
  • 相关阅读:
    02.v-on的事件修饰符
    01.Vue的系统指令
    00-Vue的介绍和vue-cli
    vs code快捷键
    分库分表之后,主键的处理方法
    动态扩容分库分表
    前端web通过flask操作数据库-增删改查
    mysql组复制集群简介
    vsftp进阶-锁定目录
    kvm克隆
  • 原文地址:https://www.cnblogs.com/welhzh/p/6925158.html
Copyright © 2011-2022 走看看