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

Enable additional aesthetics in pitch annotation (linewidth, alpha, linetype) #27

Merged
merged 18 commits into from
Dec 13, 2022

Conversation

Torvaney
Copy link
Owner

This PR makes a few main changes to enable additional pitch aesthetics. Taken all together it's quite large, and I should have broken it up, but the key changes are more or less contained in a few commits which will be easier to browse than the full diff:

  • Use geom_curve to draw penalty box arcs (instead of drawing a full circle with grid::circleGrob): e991106
  • Add linewidth, alpha, linetype aesthetics to the arguments for annotate_pitch: 8cb51b8
  • Draw penalty- and six-yard boxes with 3 geom_segments (instead of geom_rect), so that there's no overlap with the whole-pitch outline (would interfere with linetype): a5e925f

NB: I also used linewidth as the top-level aesthetic over size (0af098a), since this was deprecated for lines in the latest ggplot2 release (3.4.0), although the points (penalty spots and centre point) take size = linewidth as well.


Some example images of what this looks like with different aesthetics:

library(ggplot2)
library(ggsoccer)

ggplot() +
  annotate_pitch(linewidth = 2) +
  theme_pitch()

ggplot() +
  annotate_pitch(linetype = "dashed") +
  theme_pitch()

ggplot() +
  annotate_pitch(colour = "white", linewidth = 1, linetype = "12", alpha = 0.1, goals = goals_line) +
  theme_pitch() +
  theme(panel.background = element_rect(fill = "steelblue"))

Created on 2022-11-30 with reprex v2.0.2


Closes #10, closes #17, closes #18, and closes #23

@Torvaney
Copy link
Owner Author

@lvanden - I can't add you as a reviewer (I think I might need to add you as a "collaborator" or something for that?), but I thought I'd put this up as a PR in case you wanted to have a look.

(It's a little late, but in my defence, I didn't say which Christmas break I would have some time in! 😅)

@Torvaney Torvaney merged commit 72f048f into master Dec 13, 2022
@Torvaney Torvaney deleted the pen-box-circle branch December 13, 2022 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants