set.seed(3)
data <- tibble(Group = c(rep("g1", 10), rep("g2", 10), rep("g3", 10)),
Value = c(runif(10, min = 1, max=5), runif(10, min = 1, max=5), runif(10, min = -5, max=5)))
ggplot(data, aes(Group, Value)) +
geom_point() +
facet_wrap(~ Group, scales = "free")
您可以看到y带有十进制/负值时,空间变大了。
答案 0 :(得分:3)
您可以设置fixed width for your y-axis labels
ggplot(data, aes(Group, Value)) +
geom_point() +
facet_wrap(~ Group, scales = "free") +
scale_y_continuous(labels = function(label) sprintf("%10.1f", label))
或使用coor_flip()
ggplot(data, aes(Group, Value)) +
geom_point() +
facet_wrap(Group ~ ., scales = "free") +
coord_flip()
由reprex package(v0.2.1.9000)于2019-04-10创建