我正在使用 Python (3.4) Jupyter Notebook。我尝试使用下面的代码绘制带有标签的直方图。
%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
bins = np.linspace(0, 1.0, 40)
plt.hist(good_tests, bins, alpha = 0.5, color = 'b' , label = 'good')
plt.show()
但是“好”标签根本没有显示。我错过了什么吗?谢谢!
最佳答案
您需要添加图例。参见 legend了解详情。
plt.legend()
关于 python matplotlib : label in histogram,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41213346/