Question adapted from this question and solution: Highlighting individual axis labels in bold using ggplot2
I would like to selectively substantiate the labels of the horizontal axes depending on their compliance with the criteria. So, borrowing from the above question and answer, I created an example:
require(ggplot2) require(dplyr) set.seed(36) xx<-data.frame(YEAR=rep(c("X", "Y"), each=20), CLONE=rep(c("A", "B", "C", "D", "E"), each=4, 2), TREAT=rep(c("T1", "T2", "T3", "C"), 10), VALUE=sample(c(1:10), 40, replace=T))

So, I took a function from the above question + to create a vector of excuses:
# Modify to control justification colorado2 <- function(src, boulder) { if (!is.factor(src)) src <- factor(src) src_levels <- levels(src) brave <- boulder %in% src_levels if (all(brave)) { b_pos <- purrr::map_int(boulder, ~which(.==src_levels)) b_vec <- rep(0.2, length(src_levels)) b_vec[b_pos] <- 0.9 b_vec } else { stop("All elements of 'boulder' must be in src") } }
I get this miserable mess: 
The labels are justified in the direction I want, but taking up too much space for reasons that I cannot understand. How to fix it?