Torvaney / ggsoccer

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

Support flipped axes in pitch dimensions #18

Closed Torvaney closed 1 year ago

Torvaney commented 4 years ago

If (0,0) is at the top-left of the pitch, then the L/R of the resulting pitch will be flipped. This is the case for Statsbomb data.

We should be able to write our pitch-specification to accommodate this automatically.

Torvaney commented 4 years ago

Some ideas:

  1. Enable negative pitch widths in pitch spec
  2. Add an additional parameter to pitch spec, on whether the origin is on the left or right of the pitch (and which end it is at?)

One issue with (1) is that it would require all widths (6-yard, penalty) to be negative, which is a bit annoying. One nice thing is that it would also open up the option having the origin in any corner of the pitch (through the option of negative widths and/or/nor negative lengths).

EDIT: thinking about it, (1) might not work at all, since the pitch would be in the range (0, -width) but the data points would still be in the range (0, +width)!

Torvaney commented 4 years ago

Equally - how big an issue is this, since scale_y_reverse exists?

Seems like the best option might be add an optional param to the pitch dimensions that tells annotate_pitch whether to flip the y axis (when limits = TRUE).

Although scale_y_reverse screws up the rendering of annotated grobs (the circles). Perhaps using ggforce to draw the circles would help.