I have drawn a (netball) court in R using ggplot2
and the following code:
require(ggplot2)
ggplot(Coords, aes(X,Y, colour=Position)) +
geom_point() +
coord_equal() + theme(plot.background = element_rect(fill = 'grey')) +
geom_path(data=NetballCourt, aes(X,Y), colour="black", size=1)`<br><br>
The sidelines plus transverse lines of the court are fine and these are contained in a data.frame
that I have named "NetballCourt" with player movement "Coords" categorised according to individual position.
How do I draw a half circle, with a radius of 4.9 meters, at opposing ends of the court? For those unfamiliar with netball, the court dimensions are here... http://netball.com.au/our-game/court-venue-specifications/
Thank you for the links, @eipi10 and @tonytonov.
I employed the following circle function:
circleFun <- function(center=c(0,0), diameter=1, npoints=100, start=0, end=2)
{
tt <- seq(start*pi, end*pi, length.out=npoints)
data.frame(x = center[1] + diameter / 2 * cos(tt),
y = center[2] + diameter / 2 * sin(tt))
}
I then included the specifics of the netball court, given the center of a full circle would be (0,7.625) and a diameter of 9.8
dat <- circleFun(c(0,7.625), 9.8, start=1.5, end=2.5)
I then plotted this in R before adding the X and Y coordinates to my existing data.frame
named "NetballCourt"
ggplot(dat,aes(x,y)) +
geom_polygon(color="black") +
ggtitle("half circle") +
coord_equal()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With