plot.py 文件源码

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

项目:pymake 作者: dtrckd 项目源码 文件源码
def log_binning(counter_dict,bin_count=35):
    max_x = np.log10(max(counter_dict.keys()))
    max_y = np.log10(max(counter_dict.values()))
    max_base = max([max_x,max_y])

    min_x = np.log10(min(drop_zeros(counter_dict.keys())))

    bins = np.logspace(min_x,max_base,num=bin_count)

    # Based off of: http://stackoverflow.com/questions/6163334/binning-data-in-python-with-scipy-numpy
    #bin_means_y = (np.histogram(counter_dict.keys(),bins,weights=counter_dict.values())[0] / np.histogram(counter_dict.keys(),bins)[0])
    #bin_means_x = (np.histogram(counter_dict.keys(),bins,weights=counter_dict.keys())[0] / np.histogram(counter_dict.keys(),bins)[0])
    bin_means_y = np.histogram(counter_dict.keys(),bins,weights=counter_dict.values())[0]
    bin_means_x = np.histogram(counter_dict.keys(),bins,weights=counter_dict.keys())[0]
    return bin_means_x,bin_means_y

#def plot_degree(y, title=None, noplot=False):
#    if len(y) > 6000:
#        return
#    G = nxG(y)
#    degree = sorted(nx.degree(G).values(), reverse=True)
#    if noplot:
#        return degree
#    #plt.plot(degree)
#    x = np.arange(1, y.shape[0] + 1)
#    fig = plt.figure()
#    plt.loglog(x, degree)
#    if title:
#        plt.title(title)
#    plt.draw()
#
#def plot_degree_(y, title=None):
#    if len(y) > 6000:
#        return
#    G = nxG(y)
#    degree = sorted(nx.degree(G).values(), reverse=True)
#    x = np.arange(1, y.shape[0] + 1)
#    plt.loglog(x, degree)
#    if title:
#        plt.title(title)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号