I'm having some trouble aligning axis labels across facets in ggplot. I'm trying to left align all of the y-axis labels to make the text look more uniform, but the moment the "scales = free" argument is added to the script, the labels only become aligned within the facet. I've tested with some dummy code and the same issue occurs:
test <- data.frame(label = c('a', 'ab', 'a', 'abc', 'abcd', 'abcde',
'abcdef', 'abcdefg', 'abcdefgh',
'abcdefghi', 'abcdefghij',
'abcdefghijkfiutdkjgbhcvi'),
xdum = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12),
facett = rep(c("Facet 1", "Facet 2", "Facet 3"), 4),
data = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
ggplot(test, aes(x = xdum, y = label, label = data)) +
facet_grid(facett~., scales = "free", space = "free") +
geom_tile() +
theme(axis.ticks = element_blank(), axis.text.y = element_text(hjust = 0))
Has anyone seen this before and found a workaround or will I have to mess around with the gtable code?