在ggplot中移动和左对齐y轴标签

时间:2021-06-17 17:04:02

标签: r ggplot2

这是我的情节:

ggplot(iris,aes(Sepal.Length,Species, fill = Species)) + geom_col() +
            theme(axis.text.y = element_text(hjust = 0))

我想要的只是将 y 轴向右移动并将它们向左对齐以将它们包含在条形中。

当我更改 hjus = 时,标签不会左对齐/对齐。

有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

您可以使用geom_text()

ggplot(iris,aes(Sepal.Length,Species, fill = Species)) +
 geom_col() +
 geom_text(aes(x = 100, label = Species))

enter image description here