我想在很长一段时间内绘制 wind ,因此动态情节是其他人选择时间范围的不错选择。我希望将风向显示为箭头;风速可以线。
但是如果我在上面的每一行添加箭头会很麻烦,而且似乎很难在x轴上添加更多日期。我想得到的最终结果是这样的:
是否可以在R?中绘制风箭头图?
Plus:这是情节的演示数据
structure(list(date = c("2016-04-01", "2016-04-01", "2016-04-01",
"2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01",
"2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01",
"2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01",
"2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01", "2016-04-01",
"2016-04-01", "2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02",
"2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02",
"2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02",
"2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02",
"2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02", "2016-04-02"
), time = c("0:00:00", "1:00:00", "2:00:00", "3:00:00", "4:00:00",
"5:00:00", "6:00:00", "7:00:00", "8:00:00", "9:00:00", "10:00:00",
"11:00:00", "12:00:00", "13:00:00", "14:00:00", "15:00:00", "16:00:00",
"17:00:00", "18:00:00", "19:00:00", "20:00:00", "21:00:00", "22:00:00",
"23:00:00", "0:00:00", "1:00:00", "2:00:00", "3:00:00", "4:00:00",
"5:00:00", "6:00:00", "7:00:00", "8:00:00", "9:00:00", "10:00:00",
"11:00:00", "12:00:00", "13:00:00", "14:00:00", "15:00:00", "16:00:00",
"17:00:00", "18:00:00", "19:00:00", "20:00:00", "21:00:00", "22:00:00",
"23:00:00"), ws = c(0.6, 0.6, 0.3, 0.3, 0.5, 0.5, 0.4, 0.4, 0.4,
0.6, 0.9, 0.4, 0.9, 2.3, 2, 2.5, 2.6, 2.4, 2, 2.2, 1.7, 1.2,
1, 1, 1.4, 1.1, 1.4, 0.8, 1, 1.5, 1.2, 1.3, 1.4, 1.3, 2, 2.1,
2.7, 2.2, 2.1, 2.5, 1.9, 2, 1.7, 1.9, 1.2, 0.4, 0.5, 0.4), wd = c(179,
151.5, 200, 178.7, 205.5, 115.1, 110.9, 175.7, 192.9, 121, 117.5,
171.7, 204.8, 160.7, 169.3, 171, 169.4, 172.8, 154.5, 170.6,
151, 131.1, 105.3, 109.5, 141.9, 137.1, 113.7, 116.6, 88.7, 110.1,
99.9, 105.5, 98.4, 101.3, 128.6, 146.9, 148.1, 148.4, 152.5,
144.1, 145, 160, 179.2, 147.3, 156.6, 147.1, 158, 157.9)), .Names = c("date",
"time", "ws", "wd"), class = "data.frame", row.names = c(NA,
-48L))
________________________________更新________________________________________
很抱歉没有强调我的问题。
感谢@koekenbakker,该功能在一个地块中绘制风向和速度方面做得很好。否则,我的问题可能更多地集中在如何将风地图转换为动态情节。日期选择中的动态就足够了)
答案 0 :(得分:0)
使用Arrowhead
参数尝试shape
包中的angle
函数:
箭头角度(逆时针,相对于x轴),以度为单位 [0360];一个值或一个向量
我不确定这与你对风向的描述相符,也许你需要从360度或类似的东西中减去你的风向。
library(shape)
plot(1:nrow(a), rep(1,nrow(a)), pch=NA, ylim=c(0,5))
Arrowhead(x0 = 1:nrow(a), y0 = a$ws, angle=a$wd)