Code example
Let me take this little example:
example.data <- data.frame(
x = seq(1,5),
y = c(seq(1,3), 4.1, 4.11),
y.label = letters[1:5]
)
library(ggplot2)
ggplot(example.data, aes(x=x, y = y)) +
geom_point() +
scale_y_continuous(breaks = example.data$y, labels = example.data$y.label)
Since 4.1 and 4.11 are extremely close to one another the labels will overlap:
Info
I plot a very similar graph for a publication and do not want to increase the size of the figure just to make the labels fit (which would require the plot to be very large). I'm familiar with ggrepel
, but as far as I know this only works for text annotation within the plot itself and not for axis.
Question
How can I make sure that the labels do not overlap without having to increase the size of the whole plot?