Torvaney / ggsoccer

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

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

Closed Torvaney closed 1 year ago

Torvaney commented 1 year ago

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:

NB: I also used linewidth as the top-level aesthetic over size (https://github.com/Torvaney/ggsoccer/commit/0af098a0bd9e3e63c6da89df5c4115a951db4f54), 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 commented 1 year ago

@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! 😅)