上QQ阅读APP看书,第一时间看更新
How to do it...
The following code block draws a scatter plot that depicts the relationship between the age and the weight of people:
- Set the figure size (width and height) to (10, 6) inches:
plt.figure(figsize=(10,6))
- Read age and weight data from an Excel file:
age_weight = pd.read_excel('scatter_ex.xlsx', 'age_weight')
x = age_weight['age']
y = age_weight['weight']
- Plot the scatter plot:
plt.scatter(x, y)
- Set x and y axis labels:
plt.xlabel('Age')
plt.ylabel('Weight)
- Display the graph:
plt.show()