我有两个数据框,一个更大(10个人),一个更小(两个人)。我为每个数据框生成了一个甘特图。我如何得到它,使得每条图的线之间的距离相同(即,不根据条目的数量进行缩放)。
# Generate vectors:
name <- paste("person", seq(10), sep = '_')
start <- sample(seq(5), size = 10, replace = T)
end <- sample(seq(6,10), size = 10, replace = T)
# Generate data frames:
big_chart <- data.frame(name = c(name,name), value = c(start,end))
small_chart <- big_chart[c(1:2,11:12),]
# big plot
library(ggplot)
ggplot(big_chart, aes(value, name)) +
geom_line()
# small plot
ggplot(small_chart, aes(value, name)) +
geom_line()
答案 0 :(得分:1)