我知道该plt.hist()方法需要x-axis作为参数来绘制。但我有以下情况:
id cluster_number
1 10
2 21
3 55
4 36
5 70
. .
. .
. .
如果我使用my_serie = df.groupby('cluster_number')['id'].size()
,输出将是每个簇中Serie
的数量id's
。
然后,通过plt.plot(my_serie)
,我得到一个plot
:
x-axis
:簇数...
y-axis
: 给定数量id's
当然,这种类型的数据更适合直方图。但plt.hist()
会将作为输入给出的序列理解为x-axis
值,而不是y-axis
值,如下所示plt.plot()
:
x-axis
id's
:簇中的数量...
y-axis
:以及具有该id's
读入数量的簇的数量x-axis
如何获得x-axis
和y-axis
排列等于 的直方图plt.plot()
?
慕桂英546537
相关分类