iT邦幫忙

2023 iThome 鐵人賽

DAY 15
0

安裝相依套件

  • Pandas
    • 這個安裝會花一些時間
    pipenv install pandas
    
  • Plotly
    pipenv install plotly
    
  • 另存圖片需要安裝 kaleido
    pipenv install kaleido
    

試用功能

  • 從前一篇找到的範例,拿來修改,試做看看
    import plotly.express as px
    import pandas as pd
    
    df = pd.DataFrame([
        dict(Task = "工作1", Start = '2023-09-13', End = '2023-10-25', Assigned = "Rita", Difficulty = 70),
        dict(Task = "工作2", Start = '2023-12-03', End = '2024-02-14', Assigned = "Rita", Difficulty = 20),
        dict(Task = "工作3", Start = '2023-10-20', End = '2024-03-17', Assigned = "奴隸 A", Difficulty = 30),
        dict(Task = "工作4", Start = '2023-02-21', End = '2024-07-06', Assigned = "奴隸 B", Difficulty = 50),
        dict(Task = "工作5", Start = '2024-01-01', End = '2024-09-28', Assigned = "奴隸 C", Difficulty = 80)
    ])
    
    fig = px.timeline(df, x_start = "Start", x_end = "End", y = "Task")
    # Tasks from top to bottom
    fig.update_yaxes(autorange = "reversed") 
    # fig.show()
    fig.write_image("甘特圖.png")
    
  • 圖片
    https://ithelp.ithome.com.tw/upload/images/20230917/20141784Y6OWgEHC4t.png
  • 上方 Task 都是同一種顏色,看不出來誰負責什麼項目,老闆看了會不開心。
  • 美化一下圖片,依 Task 指派給不同的人更換顏色,更容易識別誰做了哪些事。
    fig = px.timeline(df, x_start = "Start", x_end = "End", y = "Task", color = "Assigned")
    

https://ithelp.ithome.com.tw/upload/images/20230917/20141784n4zJE7Aq4h.png


上一篇
Day 14 - 調查甘特圖製作方法
下一篇
Day 16 - 理解 Python-pptx 的 Placeholder 類型並加入甘特圖
系列文
挽救肝指數 x 職場生存術 x 老闆愛看的投影片製造機30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言