[問題] Matplotlib

看板Python作者 (kkkjukd)時間5年前 (2020/07/21 17:22), 編輯推噓1(1010)
留言11則, 3人參與, 5年前最新討論串1/1
想請問一下再用pandas做出一個dataframe後matplotlib參數要怎麼寫才能把dataframe的 index做成x軸 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.137.241.71 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1595323354.A.0F1.html

07/21 17:32, 5年前 , 1F
常見的圖形你可以直接用pandas內建的plot()功能。會直接抓
07/21 17:32, 1F

07/21 17:34, 5年前 , 2F
index跟column去當xy軸。Matplotlib的話就是plt.xticks()
07/21 17:34, 2F

07/21 17:36, 5年前 , 3F
請問是指說沒有用任何參數x軸就會直接抓index嗎
07/21 17:36, 3F

07/21 17:36, 5年前 , 4F
要用什麼自己填XD
07/21 17:36, 4F

07/21 17:41, 5年前 , 5F
07/21 17:41, 5F

07/21 17:53, 5年前 , 6F
ㄛㄛ這我知道但是我想用dataframe的index當x軸但是不
07/21 17:53, 6F

07/21 17:53, 5年前 , 7F
知道參數怎麼設
07/21 17:53, 7F

07/21 18:06, 5年前 , 8F
如果上面那個網址內容都看不懂我很難幫你耶…Good luck.
07/21 18:06, 8F

07/21 18:31, 5年前 , 9F
好吧 我們講的可能是不同問題謝謝
07/21 18:31, 9F

07/22 08:44, 5年前 , 10F
你可以df.reset_index() 原本index會變成新的columns
07/22 08:44, 10F

07/22 08:45, 5年前 , 11F
再拿去matplotlib plot
07/22 08:45, 11F
文章代碼(AID): #1V5hFQ3n (Python)
文章代碼(AID): #1V5hFQ3n (Python)