我一直在研究一些足球数据,并遇到了 alpha 美学使用的问题。基本上,我尝试在此处创建的足球场上绘制一些传球:https ://github.com/FCrSTATS/Visualisations/blob/master/3.CreateAPitch.md 但是,在使用 geom_segment 和 alpha 美学这样做时,我最终得到了当 alpha 小于 1 时没有线条,只绘制箭头。什么原因?它是在前面提到的链接的函数中定义的主题吗?我用过的代码:
pitch <- createPitch(10600, 7040, "#202020", "#797876", "#202020", "#131313")
pitch + geom_segment(data = data,
aes(x = x/100 * xmax, y = y/100 * ymax,
xend = as.numeric(as.character(pass_end_x))/100 * xmax,
yend = as.numeric(as.character(pass_end_y))/100 * ymax,
alpha = data$n/max(data$n)),
color = "blue",
arrow = arrow(length = unit(0.3, "cm"), ends = 'first', type = 'closed'))
和数据:
structure(list(x = c(77.076, 66.7944444444444, 60.425, 64.7828571428571
), y = c(77.672, 19.0888888888889, 52.8055555555556, 90.0485714285714
), pass_end_x = c(88.296, 77.8240740740741, 70.0472222222222,
73.5857142857143), pass_end_y = c(61.204, 20.7796296296296,
64.0083333333333, 89.8485714285714), n = c(25L, 54L, 36L, 35L)), .Names =
c("x", "y", "pass_end_x", "pass_end_y", "n"), row.names = c(NA, -4L), class
= c("tbl_df", "tbl", "data.frame"))