What I want is probably not possible without a lot of work, but maybe someone has a solution. I have a plot like the following (this is an oversimplified example of course) where I have tick labels that fall very close to each other:
dd <- data.frame(x=1:4, y=c(-10,10.5,10.6,10.7),
z = LETTERS[1:4])
library(ggplot2)
gg1 <- ggplot(dd, aes(x,y)) +
geom_point() +
geom_segment(x=0, aes(xend=x, y=y, yend=y)) +
scale_y_continuous(breaks=dd$y, labels=dd$z)
If I really want to I can export as SVG, dump it into Inkscape, and move the labels apart manually (even adding in little indicator lines connecting the labels with the precise y-axis positions):
It would be nice to be able to do something like this programmatically/automatically. I thought about:
ggrepel
package (only works on labels/text within the plot AFAIK)directlabels
package (it has some placement options like "first.bumpup" that might be adaptable/hackable for this case)- the
n.dodge
andcheck.overlap
arguments toguide_axis
as illustrated here look useful and interesting, and they almost handle this case, butn.dodge
dodges labels horizontally, which will get ugly if the labels are longer than a few characters ...
I would be happy enough with a label.pos.nudge
argument that could be specified manually to displace the positions of the labels along the axis from their corresponding