andrewRowlinson / mplsoccer

Football pitch plotting library for matplotlib
MIT License
391 stars 80 forks source link

Any example about how to annotate over the players with Animations? #58

Closed pakkk closed 2 years ago

pakkk commented 2 years ago

Hi Andrew,

Using StatsBomb and your framework, I am trying to add the following information inside the animation function:

pitch.annotate('?', (awayTeamXandYPosition.x[i], awayTeamXandYPosition.y[i]), va='center', ha='center', color='white', fontsize=15, ax=ax['pitch'])

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.title.html?highlight=title#matplotlib.pyplot.title

Could you help me?

Thank you!

Cheers, Paco.

andrewRowlinson commented 2 years ago

If you don't need an arrow you could try ax.text?

https://stackoverflow.com/questions/18274137/how-to-animate-text-in-matplotlib

pakkk commented 2 years ago

Thank you!!!! I have achieved it ;)

What about the pitch.annotate? Any ideas?

Thanks again!

andrewRowlinson commented 2 years ago

I would try Thomas Kuhn's suggestion here: https://stackoverflow.com/questions/18351932/animate-points-with-labels-with-matplotlib

Would you mind posting your ax.text solution as a reply or adding it to the example as a pull request? It might help some other people.

pakkk commented 2 years ago

Thank you!

For the ax.text solution:

Cheers, Paco.

pakkk commented 1 year ago

Thank you for your fast response :)

Yes, I tried it, but the pitch is empty (neither players nor text):

I share with you the animation.py in pastebin:

https://pastebin.com/LEJp2YMr https://pastebin.com/LEJp2YMr

Thanks.

El mié, 13 jul 2022 a las 19:52, Andrew Rowlinson @.***>) escribió:

If you don't need an arrow you could try ax.text?

https://stackoverflow.com/questions/18274137/how-to-animate-text-in-matplotlib

— Reply to this email directly, view it on GitHub https://github.com/andrewRowlinson/mplsoccer/issues/58#issuecomment-1183513741, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC5HPQZO6H3PZYMSQ27W53VT367FANCNFSM53PQ6MOA . You are receiving this because you authored the thread.Message ID: @.***>