加入圖例
警官 Deshaun、孟飛(Mengfei)和 Aditya 一直和你合作調查 Bayes 綁架案。他們的主管想知道每位警官在此案件上花了多少時間。
Deshaun 在前一題已用 deshaun、mengfei 和 aditya 這三個 DataFrame 繪製了圖表。現在他想加入圖例,方便分辨三條折線。
本練習屬於課程
Python 的資料科學入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Add a label to Deshaun's plot
plt.plot(deshaun.day_of_week, deshaun.hours_worked, ____)
# Officer Aditya
plt.plot(aditya.day_of_week, aditya.hours_worked)
# Officer Mengfei
plt.plot(mengfei.day_of_week, mengfei.hours_worked)
# Display plot
plt.show()