在画直方图的时候出现了这个问题。
我最开始的代码如下:
import matplotlib.pyplot as plt
plt.hist(x=train.content_type, bins=len(labels_1), color="steelblue", edgecolor='black')
plt.xlabel('事件类型')
plt.ylabel('频数')
plt.show()
这个问题是 x=train.content_type 作为参数传进去的时候,其label(1,2,3....)等也传进去了。所以只要去掉这个前面的索引就行。
aa=[]
for type in train.content_type:
aa.append(type)
import matplotlib.pyplot as plt
plt.hist(x=aa, bins=len(labels_1), color="steelblue", edgecolor='black')
plt.xlabel('事件类型')
plt.ylabel('频数')
plt.show()
我的方法比较粗暴简单,直接用的是一个数据替代。
最后
以上就是清爽鸭子最近收集整理的关于ValueError: color kwarg must have one color per dataset的全部内容,更多相关ValueError:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复