plot.py 文件源码

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

项目:pymake 作者: dtrckd 项目源码 文件源码
def plot_csv(target_dir='', columns=0, sep=' ', separate=False, title=None):
    if type(columns) is not list:
        columns = [columns]

    title = title or 'LDA Inference'
    xlabel = 'Iterations'
    markers = cycle([ '+', '*', ',', 'o', '.', '1', 'p', ])
    if not separate:
        fig = plt.figure()
        ax1 = fig.add_subplot(111)
        ax1.set_xlabel(xlabel)
        ax1.set_title(title)
    for column in columns:

        if separate:
            fig = plt.figure()
            plt.title(title)
            plt.xlabel('xlabel')
            ax1 = plt.gca()

        filen = os.path.join(os.path.dirname(__file__), "../PyNPB/data/", target_dir)
        with open(filen) as f:
            data = f.read()

        data = filter(None, data.split('\n'))
        data = [x.strip() for x in data if not x.startswith(('#', '%'))]

        ll_y = [row.split(sep)[column] for row in data]

        ylabel, label = tag_from_csv(column)
        ax1.set_ylabel(ylabel)

        #ax1.plot(ll_y, c='r',marker='x', label='log likelihood')
        ax1.plot(ll_y, marker=next(markers), label=label)
        leg = ax1.legend()
    plt.draw()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号