我有一个连续的变量显示给定日期的风角,在一个名为expt $ iso_xs [,8]的列表中,然后我将风速与expt $ iso_xs [,2]中的那个角度相对应。
head(expt$iso.xs)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 736105.4 16.62729 2.183740 7.234774 0.9791632 4.01 4.20 238.62
[2,] 736105.4 18.96705 2.489668 7.036234 0.9640366 3.82 4.00 243.14
[3,] 736105.5 20.52089 2.687636 10.355394 1.3698454 4.99 5.14 247.02
[4,] 736105.5 19.94449 2.611556 10.306912 1.3655301 4.85 5.12 249.57
[5,] 736105.5 19.43309 2.551787 11.098302 1.4646251 4.83 5.12 243.89
[6,] 736105.5 20.48259 2.689075 11.928011 1.5710530 4.89 5.09 254.23
由于角度是连续变量,我如何制作风速与角度的箱线图?有没有办法将它分成10º的箱子?
与此同时,这看起来不错但没有分档:
boxplot(x=expt$iso.xs[,8],y=expt$iso.xs[,2],col = "51",horizontal = T)
ggplot
我尝试将数据放入data.frame:
df<-data.frame(expt$iso.xs)
> dput(head(df,4))
structure(list(X1 = c(736105.427083333, 736105.447916667, 736105.46875,
736105.489583333), X2 = c(16.6272942088244, 18.9670495788553,
20.520886525004, 19.9444891323463), X3 = c(2.18373958682272,
2.48966826448766, 2.68763649372061, 2.61155634303594), X4 = c(7.23477401700351,
7.0362340804356, 10.3553936916397, 10.3069117034676), X5 = c(0.979163231089235,
0.964036556743421, 1.36984543807235, 1.36553014658159), X6 = c(4.01,
3.82, 4.99, 4.85), X7 = c(4.2, 4, 5.14, 5.12), X8 = c(238.62,
243.14, 247.02, 249.57)), .Names = c("X1", "X2", "X3", "X4",
"X5", "X6", "X7", "X8"), row.names = c(NA, 4L), class = "data.frame")
ggplot(df, aes(y = X2, x = factor(X8))) +
geom_boxplot( outlier.shape = NA,outlier.colour = NA)
产生正确的想法但不够控制:
包括以下评论:
df<-data.frame(expt$iso.xs)
df$X8 <- cut(df$X8, breaks = seq(0,360,10))
ggplot(df, aes(y = X2/45, x = factor(X8))) +
geom_boxplot( outlier.shape = NA,outlier.colour = NA)+
geom_point(color="red")+
labs(x = "Angle", y = "Normalised ACh" )+
scale_x_discrete(breaks=seq(0,360,15))
新图表看起来非常像:
但我可以修复xticks吗?