0
我有一个有不同范围和长度为n
的向量的多列(假设为n
)的数据框。我想为每个变量在每个箱形图下方显示不同的x轴。我试过facet_grid
和facet_wrap
,但它给出了公共x轴。 这是我曾尝试:在R中的盒子图和额外的点
d <- data.frame(matrix(rnorm(10000), ncol = 20))
point_var <- rnorm(20)
plot.data <- gather(d, variable, value)
plot.data$test_data <- rep(point_var, each = nrow(d))
ggplot(plot.data, aes(x=variable, y=value)) +
geom_boxplot() +
geom_point(aes(x=factor(variable), y = test_data), color = "red") +
coord_flip() +
xlab("Variables") +
theme(legend.position="none")
有什么问题吗? –
我想为每个地块绘制不同的x轴 – Rajan
也许facet_wrap(〜yourvar,scales ='free_x')? – lbusett