Torvaney / ggsoccer

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

Custom Pitch is Putting Penalty Box Arc in the Wrong location #31

Closed gregorydsam closed 1 year ago

gregorydsam commented 1 year ago

Using a custom pitch with 105x68 dimensions and a centre dot at (0,0)/ origin at (-52.5, 34) is plotting one of the penalty box arcs in the wrong location. This is true regardless of whether coord_flip is applied or not.

pitch_trac_cust <- list(
  length = 105,
  width = 68,
  penalty_box_length = 16.5,
  penalty_box_width = 40.3,
  six_yard_box_length = 5.5,
  six_yard_box_width = 18.32,
  penalty_spot_distance = 11,
  goal_width = 7.32,
  origin_x = -52.5,
  origin_y = -34
)
Screen Shot 2023-03-20 at 3 38 35 PM
Torvaney commented 1 year ago

Thanks for reporting this, Sam. This has been closed by @Flosch1006 in #34

Torvaney commented 1 year ago
library(ggplot2)
library(ggsoccer)

pitch_trac_cust <- list(
    length = 105,
    width = 68,
    penalty_box_length = 16.5,
    penalty_box_width = 40.3,
    six_yard_box_length = 5.5,
    six_yard_box_width = 18.32,
    penalty_spot_distance = 11,
    goal_width = 7.32,
    origin_x = -52.5,
    origin_y = -34
)

ggplot() +
    annotate_pitch() +
    theme_pitch() +
    coord_flip() +
    scale_y_reverse()
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.

Created on 2023-04-26 with reprex v2.0.2