Tag: rstats

Posts

09 January 2021 / / R / handball / visualization
The strategy to draw a court is to define the different lines and use ggplot2::geom_path to draw each segment. For circles, we use the following function to create the x-y coordinates. draw_circle <- function(center = c(0, 0), diameter = 1, npoints = 12000, start = 0, end = 2){ tt <- seq(start*pi, end*pi, length.out = npoints) data.table::data.table( x = center[1] + diameter / 2 * cos(tt), y = center[2] + diameter / 2 * sin(tt) ) } Now, we can define each line: