如何在ggplot的背景中绘制图形?

10

我正在制作篮球投篮图表。我需要找出如何在背景中实际绘制篮球场的轮廓线。有什么想法吗?

输入图片说明

输入图片说明

输入图片说明


看看 annotate_raster 或类似的函数。 - mnel
很棒的问题。如果你知道篮球场的布局,你可以使用 + geom_path(data=<basketball_court_specs>) 来实现一些功能。请查看 https://dev59.com/omHVa4cB1Zd3GeqPqMvz 以获取更多想法(将 geom_polygon 替换为 geom_path)。 - naught101
5
你应该将最后一张带着代码的图片发在回答中。 - naught101
1个回答

7
以下代码用于获取这张图片:
    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)
geom_path 命令中的数据包含了白色球场图表的 (x,y) 坐标。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接