我有一个简单的频率和12个扇区的平均风速。如何将这些数据绘制为风玫瑰(我不想使用plot_ly
)!
DF = structure(list(Sector = c("0-N", "1-NNE", "2-ENE", "3-E", "4-ESE", "5-SSE",
"6-S", "7-SSW", "8-WSW", "9-W", "10-WNW", "11-NNW"),
A_parameter = c(4.84, 5.04, 5.05, 4.7, 4.41, 4.66, 5.76,
7.44, 6.92, 4.87, 4.39, 4.13),
k_Parameter = c(2.24, 2.271, 2.115, 1.959, 1.779, 1.943, 2.01,
2.393, 2.326, 1.971, 1.908, 1.904),
frequency = c(0.057, 0.08, 0.086, 0.071, 0.05, 0.041,
0.071, 0.178, 0.182, 0.089, 0.051, 0.045),
mean_WS = c(4.287, 4.464, 4.473, 4.167, 3.924, 4.132, 5.104,
6.595, 6.131, 4.317, 3.895, 3.665)),
.Names = c("Sector", "A_parameter", "k_Parameter",
"frequency", "mean_WS"),
row.names = c("3", "4", "5", "6", "7",
"8", "9", "10", "11", "12", "13", "14"),
class = "data.frame")
在plot_ly
中,它会像:
plot_ly(DF, r = ~(DF$frequency*DF$mean_WS), t = ~DF$Sector)%>% add_area()
我的替代方案是什么?
答案 0 :(得分:1)
这是一个ggplot2
解决方案。我将网格线放在风玫瑰条的顶部,以匹配阴谋的外观,但你可以关闭它:
DF$Sector <- factor(DF$Sector, levels = DF$Sector)
ggplot(DF,
aes(x = Sector, y = frequency * mean_WS)) +
geom_col(width = 1, fill = "steelblue", color = "steelblue") +
coord_polar(start = -pi/12) + # change start value if you want a different orientation
theme_light() +
theme(axis.title = element_blank(),
panel.ontop = TRUE, # change to FALSE for grid lines below the wind rose
panel.background = element_blank())