我正在学习python代码,我有一些问题:
https://github.com/Slothfulwave612/Football-Analytics-Using-Python/blob/master/03.%20Analyzing%20Event%20Data/pass_map.py
我的dubt非常简单:
我想申请一个for expresion,以便将通行证代码应用于多场足球比赛
^{pr1}$
##计算通过精度
合格率=(合格率/(合格率+合格率))*100
通过acc=str(圆形(通过acc,2))
##向绘图中添加文本
plt.text(20,85,“{}传球地图vs皇家马德里”。格式(球员姓名),fontsize=15)
plt.text(20,82,'通过精度:{}'。格式(通过acc),fontsize=15)
##处理标签
句柄,标签=plt.gca()。获取\u图例\u句柄\u标签()
by_label=dict(拉链(标签、把手))
plt.legend(by_label.values()、by_label.keys()、loc='best',bbox_to_anchor=(0.9,1,0,0),fontsize=12)
##编辑体形大小并保存
图设置尺寸英寸(12,8)
fig.savefig({}passmap.png')格式(匹配id),dpi=200
##展示情节
plt.show()
我编辑代码只是为了用for expresion分析多个匹配项。
P1TMP=[162051613116265]
对于P1TMP中的i:
结果是:
在第一张图像中,结果几乎是完美的,但这种过程的过滤器不起作用。
enter image description here
在第二个图像中,过程是第一个匹配过程和第二个匹配过程的混合。我只想要第二场比赛的传球。
enter image description here
第三种是1号+2号+3号的组合。我需要第三张通行证:
enter image description here
提前感谢您的支持
致意
Tags:
所以它将所有匹配项合并到1上,因为该图是在前一个图的顶部“绘制”的。还有一些事情你也需要改变
vs. Real Madrid"
plt.title()
和plt.suptitle()
代替plt.text
插入标题(如果您想在特定的x,y坐标处进行注释,这是很好的),它将居中放置,并使文本的布局更加美观i
来匹配id变量,但随后不会在循环中更改/包括该变量(fig,ax) = createPitch(pitch_length_X, pitch_width_Y,'yards','gray')
是创建“空白画布”进行绘图的内容。因此,在每次绘图之前都需要调用它。这就像抓取一张新的空白纸进行绘图。如果只使用第一张初始图纸,则所有内容都将在该1张图纸上进行。因此,将其移动到for循环中代码
相关问题 更多 >
编程相关推荐