代码之家  ›  专栏  ›  技术社区  ›  RodrikTheReader

从数据框的两列创建矩形热图

  •  1
  • RodrikTheReader  · 技术社区  · 6 年前

    我有一个像这样的熊猫数据帧-

    enter image description here

    “s”列中的值是“k”和“w”对应值的模型精度。所以,严格来说,它在0和1之间。

    1 回复  |  直到 6 年前
        1
  •  2
  •   giser_yugang    6 年前

    import matplotlib.pyplot as plt
    import seaborn as sns
    
    flights = df.pivot("w", "k", "s")
    f, ax = plt.subplots(figsize=(9, 6))
    sns.heatmap(flights, annot=True,  linewidths=.5, ax=ax)
    plt.show()
    

    enter image description here