4
基於ggplot2的seals example,我試圖改變箭頭的粗細,以使它們的整體大小更好地反映數據變量。我可以指定長度和厚度,但不知道如何改變箭頭的大小。非常感謝任何建議。ggplot中的按比例大小的箭頭
require(ggplot2)
require(grid)
d = seals[sample(1:nrow(seals), 100),]
d$size = sqrt(sqrt(d$delta_long^2 + d$delta_lat^2))
ggplot(d, aes(x = long, y = lat, size = size)) +
geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat), arrow = arrow(length = unit(0.1,"cm")))
編輯
解決方案代碼:
ggplot(d, aes(x = long, y = lat, size = size)) +
geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat),
arrow = arrow(length = unit(d$size/3, "cm"), type='closed')) +
scale_size(range = c(0, 2))
我給你的!請參閱上面的附加代碼以獲取解 – geotheory