可视化调查数据
延续上一个关于欧洲 IT 专业人士调查数据的练习,请可视化 experience_years 与 current_salary 之间的线性关系,用于粗略估计不同工作年限的薪资水平。
数据已作为 data 为您加载,同时还导入了 pandas、Matplotlib.pyplot 和 NumPy,分别命名为 pd、plt 和 np。
本练习是课程的一部分
使用 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()