開始使用免費開始

視覺化問卷資料

延續上一個關於歐洲 IT 專家的問卷資料練習,請視覺化 experience_yearscurrent_salary 的線性關係,用來粗略估計不同年資的大致薪資。

我們已為你載入資料為 data,以及 pandas、Matplotlib.pyplot 和 NumPy,分別命名為 pdpltnp

本練習屬於課程

使用 Python 分析問卷資料

檢視課程

練習說明

  • 使用散佈圖繪製原始值。
  • 取得資料範圍。
  • 取得用於繪製迴歸線的取值範圍。
  • 繪製迴歸線。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Plot the original values using a scatter plot
x = data.____
y = data.____
____.____(x,y)

# Get the range of data
max_x = ____
min_x = ____

# Get the range of values
x = ____.____(min_x,max_x,1)
y = 1590.4569 * x + 58080

# Plot the regression line
____.____(x, y,'r')
plt.show()
編輯並執行程式碼