看板 Python 關於我們 聯絡資訊
大家好,我的資料是(9820,2),其中一個變數是類別變數為0跟1 0的個數為689個,1為9131個,我想畫出一個散佈圖分別為1跟0上色 groups = error_df.groupby('true_class') groups.size() 6fig, ax = plt.subplots() for name, group in groups: ax.plot(group.index, group.reconstruction_error, marker='o', ms=3, linestyle='', label= "fraud" if name == 1 else "normal", color="blue" if name == 1 else "k") ax.legend() plt.title("Reconstruction error for different classes") plt.ylabel("Reconstruction error") plt.xlabel("Data point index") plt.show(); 但跑不出來不知道為什麼藍色的區域蓋過黑色的區域,謝謝 https://imgur.com/a/evlxjXD -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 120.126.194.162 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1556782712.A.574.html