How do I right-align the Y-axis title ("Species") with the axis labels (the three species names), such that the axis title is close to the gray panel? hjust
does not seem to affect the position.
library(ggplot2)
ggplot(iris,
aes(x = Species,
y = Sepal.Width)) +
geom_boxplot() +
labs(x = "Species",
y = "Sepal Width") +
coord_flip() +
theme(axis.title.y = element_text(angle = 0, hjust = 0))
You can use
geom_text
together withclip = "off"
insidecoord_flip()
which will allow drawing plot element outside of the plot panel. Obviously you will have to play around withx
andy
to get the desired output with this manual methodCreated on 2018-10-27 by the reprex package (v0.2.1)