我正在尝试根据每个基本方向的频率创建一个图。我按照这个优秀资源中的说明进行操作,但在尝试集中时遇到了一个重大问题...
我正在尝试根据每个基本方向的频率创建一个图。我遵循了此 优秀资源 ,但在尝试将 bin 置于中间时遇到了一个重大问题(例如,在 \'North\' bin 内从 NNW 到 N 再到 NNE 的观测值)。在原始示例中,在极端处未找到任何值,因此它没有显示为问题。
library(gcookbook) # Load gcookbook for the wind data set
wind
w287<-c(0, 3.5, 9, 10, 90, 5, 358)
w288<-c(0, 3.5, 9, 10, 90, 5, 357)
w289<-c(0, 3.5, 9, 10, 90, 5, 1)
w290<-c(0, 3.5, 9, 10, 90, 5, 2)
wind2<-rbind(wind, w287, w288, w289, w290,w287, w288, w289, w290,w287, w288, w289, w290,w287, w288, w289, w290,w287, w288, w289, w290,w287, w288, w289, w290)
wind2[is.na(wind2$SpeedCat),]$SpeedCat<-">20"
#initial plot without rotation
a<-ggplot(wind2, aes(x = DirCat)) +
geom_histogram(binwidth = 90, boundary = 0) +
coord_polar() +
labs(title="Bins visible : no rotation")+
scale_x_continuous(limits = c(0,360))
#plot with rotation in which the values from bin#1 are lost
b<-ggplot(wind2, aes(x = DirCat)) +
geom_histogram(binwidth = 90, boundary = -45) +
coord_polar() +
labs(title="Bin not visible: rotation")+
scale_x_continuous(limits = c(0,360))
c<-ggplot(wind2, aes(x = DirCat)) +
geom_histogram(binwidth = 90, boundary = -45) +
coord_polar() +
labs(title="Bin visible: rotation + scale increased")+
scale_x_continuous(limits = c(-45,405))
grid.arrange(a, b, c, ncol=3)