I'm working on making shot charts for basketball. I need to figure out how to actually draw the outline of a basketball court in the background. Any ideas?
Asked
Active
Viewed 1,172 times
10
-
Look at `annotate_raster` or similar. – mnel Oct 09 '12 at 04:56
-
Cool question. You could do something with `+ geom_path(data=
)`, if you know how a basket ball court is laid out. Check http://stackoverflow.com/questions/9805895/mapping-the-world-on-ggplot2 for ideas (replace `geom_polygon` with `geom_path`). – naught101 Oct 09 '12 at 05:13 -
5@EvanZamir: you should post that last image with the code in an answer. – naught101 Oct 09 '12 at 06:16
1 Answers
7
The following code was used to get this image:
ggplot(shots, aes(X,Y)) + stat_binhex(binwidth=c(3,3)) + geom_point(size=3, alpha=0.5, aes(color=RESULT), position="jitter") + coord_equal() + theme_grey() + opts(title="Golden State Warriors 2012 Shot Chart") + geom_path(data=ft_line, aes(x,y), colour="white", size=2) + geom_path(data=court, aes(x,y), colour="white", size=2)
The data in the geom_path commands contains the (x,y) coords for the white court diagram.

Evan Zamir
- 8,059
- 14
- 56
- 83