修正一個 Plotly 圖形
你的同事開始製作一個 2025 年前 3 個月銷售額的視覺化。不過她接著去休特休了——但老闆現在就要看到圖!
你可以看到她留下了一個用來定義視覺化的字典物件。你的任務是把這個字典補完整,加入關鍵參數,讓它變成一個 Plotly 視覺化。
plotly.express 已以 px 載入,monthly_sales DataFrame 也已為你準備好。
本練習屬於課程
Python 的 Plotly 資料視覺化入門
練習說明
- 使用
"month"與"sales"欄位來定義x_column與y_column。 - 將
chart_title設為"Sales for Jan-Mar 2025"。 - 使用這些變數建立長條圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Define the x and y axis columns
x_column = "____"
y_column = "____"
# Define the chart title
chart_title = ____
# Create a bar plot
fig = px.____(
data_frame=monthly_sales, x=____, y=____, title=____)
fig.show()