- Matplotlib 3.0 Cookbook
- Srinivasa Rao Poladi
- 73字
- 2021-08-13 15:15:50
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()