【问题标题】:python matplotlib: label in histogrampython matplotlib:直方图中的标签
【发布时间】:2016-12-18 22:01:28
【问题描述】:

我正在使用 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()

但“好”的标签根本没有显示。我错过了什么吗?谢谢!

【问题讨论】:

    标签: python matplotlib histogram


    【解决方案1】:

    您需要添加一个图例。详情请见legend

    plt.legend()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-03
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 2014-04-15
      • 2017-12-26
      • 1970-01-01
      相关资源
      最近更新 更多