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

Plot half pitch for shots. #10

Closed
davidfombella opened this issue Feb 9, 2019 · 2 comments · Fixed by #27
Closed

Plot half pitch for shots. #10

davidfombella opened this issue Feb 9, 2019 · 2 comments · Fixed by #27
Assignees

Comments

@davidfombella
Copy link

When you use half size to plot shots , it should be required an scale y reverse... however since it is annotate_pitch previous scale this is not possible,
if you coord_flip x coordinate is ok but y is flipped

my trial
ggplot(goals) +
annotate_pitch(colour = "gray70", fill = "gray90") +
geom_point(aes(x = x, y = y,colour=team,shape=body.part), size = 4) +
theme_pitch()+
coord_flip()+
scale_y_reverse()+
ggtitle("Shotmap", "EPL ")+theme_classic()

@Torvaney Torvaney self-assigned this Feb 9, 2019
@Torvaney
Copy link
Owner

Torvaney commented Feb 9, 2019

When you use half size to plot shots , it should be required an scale y reverse

Ah yes, this is correct. I will update the README to reflect this.

if you coord_flip x coordinate is ok but y is flipped

This is weird. From what I can tell, any layers created with geom_rect do not actually get flipped. It may actually be a bug in ggplot2. I think I can workaround by using ggplot2::annotate, but I want to make sure I understand what's going on first.

Thanks for reporting this

@Torvaney
Copy link
Owner

Torvaney commented Feb 9, 2019

I've submitted an issue to ggplot2 here.

The workaround for geom_rect -> annotate(geom = "rect", ...) works fine, but getting the pitch circles to behave is a bit tricker. I think the options are as follows:

  • Submit PR/fix to ggplot2 so that it scales annotation_custom objects correctly
    • The ideal solution but probably also the most work involved
  • Mark pitch circles with annotate("point", pch = 21, ...)
    • Circles won't really scale properly with plot image size
  • Mark pitch circles with geom_path(data = circle_data(...), ...)
    • Circularity not guaranteed (they will generally look oblong)

In the meantime, the easiest way to work around this is probably to alter your input data (which is a bit grim, I know).

goals %>%
  ggplot(aes(x = x, y = 100 - y), ...) +
  # ...

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

Successfully merging a pull request may close this issue.

2 participants