【发布时间】:2020-05-14 22:37:18
【问题描述】:
我使用了一个不同的库,我希望得到类似这个函数输出的结果。这是一个ndarray吗? https://graph-tool.skewed.de/static/doc/stats.html#graph_tool.stats.vertex_hist
>>> a=gt.vertex_hist(g, "out")
>>> print(gt.vertex_hist(g, "out"))
[
array([ 5., 32., 85., 148., 152., 182., 160., 116., 53., 25., 23., 13., 3., 2., 1.]),
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
dtype=uint64)
]
以下函数来自 matplotlib.pyplot,返回两个不同变量中的计数和 bin:
counts, bins, bars = plt.hist(list(nx.dict(degree(G)).values()),histtype='stepfilled')
//output
[0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0]
[3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5]
如何将两个列表组合到一个对象/变量中,或者我是否可以理解以下表达式具有哪些值:
for i in range(0,len(a[0])):
v = a[1][i]
c = a[0][i]
【问题讨论】:
标签: python python-3.x matplotlib histogram numpy-ndarray