開始使用免費開始

修正一個 Plotly 圖形

你的同事開始製作一個 2025 年前 3 個月銷售額的視覺化。不過她接著去休特休了——但老闆現在就要看到圖!

你可以看到她留下了一個用來定義視覺化的字典物件。你的任務是把這個字典補完整,加入關鍵參數,讓它變成一個 Plotly 視覺化。

plotly.express 已以 px 載入,monthly_sales DataFrame 也已為你準備好。

本練習屬於課程

Python 的 Plotly 資料視覺化入門

檢視課程

練習說明

  • 使用 "month""sales" 欄位來定義 x_columny_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()
編輯並執行程式碼