Torvaney / ggsoccer

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

Annotate pitch, rectangles not appearing #9

Closed rblay closed 5 years ago

rblay commented 5 years ago

Hello, big fan of this project! I tried to use it on some data and the annotate_pitch seems not to be working properly. I'm not sure if it is some issue with my R or ggplot2 version. Here is a picture of what is being displayed with ggplot() + annotate_pitch():

screen shot 2018-12-15 at 2 33 56 pm
rblay commented 5 years ago

@Torvaney What I did to solve the issue was to make some slight edits on the annotate_pitch() function. I simply altered the ggplot::geom_rect() calls with ggplot:annotate() cals and added a geom = 'rect' to the arguments. I'll do a pull request with that if necessary. Best!

Torvaney commented 5 years ago

Hey, thanks for reporting this.

I suspect that might be because of the coordinate limits in the plot are excluding the pitch rectangle (specifically the x limits), but I could be wrong. Could you post a reprex and the output of SessionInfo() here to help confirm the cause, please?

Ifgeom = "rect" is a strong fix to this, I would love to receive a PR!!

rblay commented 5 years ago

I tried to reproduce the error but now it seems to work. I'll post the reprex and make the PR if it reoccurs!

Torvaney commented 5 years ago

Ah sorry, I think this issue got closed by https://github.com/Torvaney/ggsoccer/commit/b6b2aaba2ab1737502d5237f7f4694a2d0d81189