Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracab pitch not showing correctly #36

Open
mistpelt7 opened this issue May 28, 2024 · 4 comments
Open

Tracab pitch not showing correctly #36

mistpelt7 opened this issue May 28, 2024 · 4 comments

Comments

@mistpelt7
Copy link

Hi,

I am using tracab data to built heat maps in r. When loading the pitch with tracab dimensions the half circle in front of the left goal is not in the right place and appears in the middle of the pitch. I was wondering if there is a way to remove that part or a way to fix it so it's in the right position.
image

@Torvaney
Copy link
Owner

Hi! Thanks for reporting this - I will look into this issue over the weekend. In the meantime, you should be able to workaround this by rescaling your coordinates to another provider's spec using the rescale_coordinates function:

to_statsbomb <- rescale_coordinates(from = pitch_tracab, to = pitch_statsbomb)

ggplot(your_data) +
  annotate_pitch(dimensions = pitch_statsbomb) +
  geom_point(aes(x = to_statsbomb$x(x), y = to_statsbomb$(y))) +
  theme_pitch()

@Torvaney
Copy link
Owner

Hey, @mistpelt7, could I ask what version of ggsoccer you are using? If you're not sure, it should be in the output of sessionInfo().

Also, would you be able to make a reprex with your issue? When I run the following code, I don't see the same issue:

library(ggsoccer)
library(ggplot2)

ggplot() +
  annotate_pitch(dimensions = pitch_tracab) +
  theme_pitch()

Created on 2024-05-29 with reprex v2.0.2

@mistpelt7
Copy link
Author

Hi @Torvaney
I am on version 0.1.7 which appears to be the latest version according to R.

Here is the r code for the plot. I included all the packages I am using for my plot incase one of them is interfering with it.
Thanks for your help!

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(jsonlite)
library(tidyr)
library(nplyr)
library(tidyverse)
library(ggplot2)
library(viridis)
#> Loading required package: viridisLite
library(ggsoccer)

ggplot()+
  annotate_pitch(dimensions = pitch_tracab)

Created on 2024-05-29 with reprex v2.1.0

@Torvaney
Copy link
Owner

Got it - thanks. I can reproduce it on 0.1.7.

CRAN is lagging a bit behind the Github version. If you devtools::install_github("torvaney/ggsoccer"), it should solve your issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants