帮用python我写一个nba季后赛球员效率散点图并标上姓名的程序
import matplotlib.pyplot as plt
球员姓名和效率值
players = ['LeBron James', 'Kevin Durant', 'Stephen Curry', 'Kawhi Leonard', 'James Harden'] efficiency = [30.1, 26.0, 23.8, 25.8, 29.0]
绘制散点图
plt.scatter(players, efficiency)
添加姓名标签
for i in range(len(players)): plt.annotate(players[i], (players[i], efficiency[i]), textcoords="offset points", xytext=(0,10), ha='center')
设置图表标题和坐标轴标签
plt.title("NBA Playoff Player Efficiency") plt.xlabel("Player") plt.ylabel("Efficiency")
显示图表
plt.show()
原文地址: https://www.cveoy.top/t/topic/ic1s 著作权归作者所有。请勿转载和采集!