[英]ggplot2 coord_flip() with geom_text
I'm trying to find a way to easily flip a plot annotated with geom_text(). 我正在尝试找到一种方法来轻松翻转带有geom_text()注释的图。 The problem is that if I use coord_flip(), the labels are kind of not flipped.
问题是,如果我使用coord_flip(),则标签不会翻转。
A simple example, if I flip the plot like that: 一个简单的例子,如果我像这样翻转情节:
df <- count(diamonds, cut)
ggplot(df, aes(x = cut, y = n, label = n)) +
geom_bar(stat = "identity") +
geom_text()
by adding coord_flip(), I'm getting: 通过添加coord_flip(),我得到:
I know that this could be a desired behaviour in some cases but instead of that, I need the labels on the bars to stay aligned with the bars and look more like: 我知道在某些情况下这可能是理想的行为,但是,除了这些之外,我还需要条形图上的标签与条形图保持对齐并看起来更像:
Is there any solution to that? 有什么解决办法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.