有没有人知道如何水平改变y轴并添加箭头?我想做这样的图。这是我用来制作这张图的代码。
ggplot(plot, aes(x=Worried.about.the.problems.caused.by.the.garbage., y=mean))
+ geom_bar(stat = "identity", position ="dodge", fill='#6699FF') + theme_minimal()+ ggtitle("Korea") + theme(plot.title = element_text(family = "serif", face = "bold", hjust = 0.5, size = 15, color = "black"))


发布于 2020-02-08 03:25:54
可以使用theme来调整绘图中的元素,以将箭头添加到y轴,而不是使用annotate图层。
library(ggplot2)
ggplot(mtcars, aes(x = cyl)) +
geom_bar() +
theme(axis.line.y = element_line(arrow = grid::arrow(length = unit(0.3, "cm"),
ends = "both")))至于“转储更多”和“转储更少”的轴标签,使用annotate可能是最简单的,但是如果您真的出于某种原因想要避免它,您可以在y轴标题中使用换行符,并在theme中调整标题的角度
library(ggplot2)
ggplot(mtcars, aes(x = cyl)) +
geom_bar() +
theme(axis.line.y = element_line(arrow = grid::arrow(length = unit(0.3, "cm"),
ends = "both")),
axis.title.y = element_text(angle = 0)) +
labs(y = "More Common\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLess Common")输出如下:

https://stackoverflow.com/questions/60111822
复制相似问题