plot.py 文件源码

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

项目:pymake 作者: dtrckd 项目源码 文件源码
def plot_degree_2(P, logscale=False, colors=False, line=False, ax=None, title=None):
    """ Plot degree distribution for different configuration"""
    if ax is None:
        # Note: difference betwwen ax and plt method are the get_ and set_ suffix
        ax = plt.gca()

    x, y, yerr = P
    y = np.ma.array(y)
    for i, v in enumerate(y):
        if v == 0:
            y[i] = np.ma.masked
        else:
            break

    c = next(_colors) if colors else 'b'
    m = next(_markers) if colors else 'o'
    l = '--' if line else None

    if yerr is None:
        ax.scatter(x, y, c=c, marker=m)
        if line:
            ax.plot(x, y, c=c, marker=m, ls=l)
    else:
        ax.errorbar(x, y, yerr, c=c, fmt=m, ls=l)

    min_d, max_d = min(x), max(x)

    if logscale:
        ax.set_xscale('log'); ax.set_yscale('log')
        # Ensure that the ticks will be visbile (ie larger than in los step)
        #logspace = 10**np.arange(6)
        #lim =  np.searchsorted(logspace,min_d )
        #if lim == np.searchsorted(logspace,max_d ):
        #    min_d = logspace[lim-1]
        #    max_d = logspace[lim]
    if title:
        ax.set_title(title)

    ax.set_xlim((min_d, max_d+10))
    #ax.set_xlim(left=1)
    ax.set_ylim((.9,1e3))
    ax.set_xlabel('Degree'); ax.set_ylabel('Counts')

##########################
### Graph/Matrix Drawing
##########################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号