下图显示了我用下面的代码创建的图表。我强调了缺失或重叠的标签。有没有办法告诉ggplot2不重叠标签?如何防止两个标签在条形图中重叠?
week = c(0, 1, 1, 1, 1, 2, 2, 3, 4, 5)
statuses = c('Shipped', 'Shipped', 'Shipped', 'Shipped', 'Not-Shipped', 'Shipped', 'Shipped', 'Shipped', 'Not-Shipped', 'Shipped')
dat <- data.frame(Week = week, Status = statuses)
p <- qplot(factor(Week), data = dat, geom = "bar", fill = factor(Status))
p <- p + geom_bar()
# Below is the most important line, that's the one which displays the value
p <- p + stat_bin(aes(label = ..count..), geom = "text", vjust = -1, size = 3)
p
您可以在特定坐标处绘制文本。这不是最好的方法,但它会完成工作。 – 2013-04-21 02:47:52
@Ricardo:这是一个想法,但酒吧可以是任何高度。 – Martin 2013-04-22 14:58:11