我有一个柱状图,看起来像这样: ggplot(mtcars, aes(x = cyl, y = hp)) + geom_bar(stat = "identity", width = 1) 我想调整geom_bar参数,使柱条向右移动(不是居中)...
试一下这个:ggplot(mtcars, aes(x = cyl, y = hp)) + geom_bar(stat = "identity", width = 1, position = position_nudge(x = 0.5)) 我是如何弄清这个问题的:前往 ?geom_bar 并发现有一个位置参数和一个指向 ?position_dodge 的链接。查看那里的示例并对您的代码进行了修改。看起来是一个令人满意的解决方案。