Torvaney / ggsoccer

Plot soccer event data in R/ggplot2
https://torvaney.github.io/ggsoccer/
Other
178 stars 27 forks source link

Shot plots not matching pitch markings - how to adjust #11

Closed AntsNumbers closed 5 years ago

AntsNumbers commented 5 years ago

Has this been an issue for anyone else? I've plotted shots from 0-100 x y data and while the shots seem in the right place relative to the whole pitch, they look incorrect in ref to the penalty lines on the y axis. This is the whole pitch side-on view.

This is where they end up for me: MyShotPlot

This is where they should be. I've double checked these with video of the shots: WhereTheyShouldBe

Is this just an issue of scaling in ggplot or is it that your pitch plot is out? The penalty areas look differently proportioned.

Torvaney commented 5 years ago

Hey @AntsNumbers,

The dimensions in the ggsoccer plot are based on Opta data (the dimensions for penalty box etc are taken from their documentation). Do you know which data source you're using?

If it's something like Wyscout, the box dimensions might be slightly different. I can also see that the out-of-box shots for the right-hand side team look slightly different in WhoScored's plot (and I think Whoscored use Opta).

It's on the todo list to make composing a pitch from an arbitrary pitch spec (i.e. customisable for any provider), but I haven't gotten around to it yet, unfortunately.

AntsNumbers commented 5 years ago

Hi Ben, it's Whoscored data so should be the same as their plot.

The weird thing is that the right-hand team's out-of-box shots have been squeezed together on the y axis while the shot from just inside the box nearer the top of the screen has moved outwards.

Yes, being able to set pitch dimensions would be great. Is it possible for me to tweak the numbers in the function currently?

Torvaney commented 5 years ago

Is it possible for me to tweak the numbers in the function currently?

Not currently - the relative size/area of the penalty box is fixed. This is what I would like to change at some point.

However, if you fork the repo and/or copy the package locally, you could change the values in R/annotate_pitch.R, and reinstall to have custom dimenstions.

Torvaney commented 5 years ago

The weird thing is that the right-hand team's out-of-box shots have been squeezed together on the y axis while the shot from just inside the box nearer the top of the screen has moved outwards.

I'm wondering if WhoScored have applied their own transformation onto the data to rescale the y axis (Opta's data actually distorts things slightly as their penalty area doesn't exactly match the real life pitch specifications)

Torvaney commented 5 years ago

NB @AntsNumbers, the latest version of ggsoccer allows you to create a custom pitch plot from a set of dimensions (see the latest README).

In this case, I suspect it won't help. Since the relative position of the points to each other appears (subtly) different between your plot and Whoscored's (as opposed to just the markings being misaligned), I think there is something else going on.

For this reason, I am going to close this issue. However, feel free to re-open it if you think I have got this wrong and that the package needs amending.

Thanks