Some time ago I got a question from Tom Worville, at http://analyticsfc.co.uk/ if I could share how I create my plots. As I have mentioned before I use Plotly. In my opinion a superb visualization tool with a great api and a sound user policy. Being a Python programmer their eminent python library is of course extra appreciated.
Here is how I create a football pitch with Plotly. Meet footballpitchplot!
I have made a small Python library that draws a football pitch on a Plotly graph. It can then then add/plot events on top of the pitch.
I have put the code up on github. So one way of using the library from github would of course be to use it as a submodule, or fork it, or maybe just take inspiration and implement it in another programming language.
pip install footballpitchplot
That will install the library as well as Plotly. To set up Plotly one will need to create an account and have some credentials created locally. Instructions here.
Once this is done the following code will produce a plot of some events on top of a football pitch in Plotly.
from pitchplotter.plotter import Plotter plotter = Plotter("Demo") #create array as follows: [xpos, ypos, 'event name', event size] demo_arr = [ [25,50,'Event 1', 34], [35,41,'Event 2', 14], [20,33,'Event 3', 23], [10,52,'Event 4', 56], [45,60,'Event 5', 9] ] plotter.add_events(demo_arr, "Demo events") plotter.plot()
Thats all really!