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 带小数/负值时,空间会变大。
最佳答案
您可以设置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于2019年4月10日创建(v0.2.1.9000)
关于r - 使用scale = "free_y"时如何设置相等的面板水平空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55623864/