cmon_plt.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:brainpipe 作者: EtienneCmb 项目源码 文件源码
def __new__(self, ax, y, x=None, color=None, cmap='inferno', pltargs={}, **kwargs):
        # Check inputs :
        y = np.ravel(y)
        if x is None:
            x = np.arange(len(y))
        else:
            x = np.ravel(x)
            if len(y) != len(x):
                raise ValueError('x and y must have the same length')
        if color is None:
            color = np.arange(len(y))

        # Create segments:
        xy = np.array([x, y]).T[..., np.newaxis].reshape(-1, 1, 2)
        segments = np.concatenate((xy[0:-1, :], xy[1::]), axis=1)
        lc = LineCollection(segments, cmap=cmap, **pltargs)
        lc.set_array(color)

        # Plot managment:
        ax.add_collection(lc)
        plt.axis('tight')
        _pltutils.__init__(self, ax, **kwargs)

        return plt.gca()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号