@final aspen import seaborn as sns
import matplotlib.pyplot as plt
生成数据
data = {
'Variant': ['Variant 1', 'Variant 2', 'Variant 3', 'Variant 4'],
'Make': ['Make 1', 'Make 2', 'Make 3', 'Make 4'],
'Length': [30, 35, 40, 45],
'Year': [2010, 2012, 2015, 2017],
'Hull material': ['Steel', 'Wood', 'Fiberglass', 'Aluminum'],
'Sail area': [150, 200, 250, 300],
'Sleeping capacity': [4, 6, 8, 10],
'Region': ['Europe', 'North America', 'Asia', 'South America'],
'PerGDP': [0.5, 0.7, 0.8, 0.9],
'Draft': [5, 6, 7, 8],
'Headroom': [6, 7, 8, 9],
'Displacement': [10000, 12000, 15000, 18000],
'Geographic region': ['Northern hemisphere', 'Southern hemisphere', 'Tropical', 'Temperate'],
'Boat width': [10, 11, 12, 13],
'GDP': [1000, 2000, 3000, 4000]
}
创建散点图
sns.scatterplot(x='Length', y='Sail area', data=data)
在图像外面添加标签
for i in range(len(data)):
plt.annotate(data['Variant'][i], (data['Length'][i], data['Sail area'][i]), xytext=(5, 5), textcoords='offset points')
显示图像
plt.show()修改代码