I am trying to change the font size and face of x-axis tick labels based on the line.
The label on 1st line to bold and 12 and label on 2nd line to regular and 8.
structure(list(`501` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00340136054421769,
0.00680272108843537, 0, 0, 0, 0, 0, 0, 0.00340136054421769, 0.00340136054421769,
0, 0.00340136054421769, 0.0442176870748299, 0.00340136054421769,
0, 0.0442176870748299, 0, 0, 0, 0, 0, 0, 0, 0.00340136054421769,
0, 0, 0, 0, 0.00340136054421769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
), `48` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00340136054421769,
0.00340136054421769, 0.00340136054421769, 0, 0, 0, 0, 0, 0, 0,
0.00340136054421769, 0, 0, 0, 0.00340136054421769, 0, 0.00340136054421769,
0, 0, 0, 0.00340136054421769, 0, 0, 0, 0, 0, 0, 0.00340136054421769,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `8` = c(0, 0, 0, 0, 0, 0, 0.00340136054421769,
0, 0, 0, 0, 0, 0, 0.00680272108843537, 0, 0, 0.00340136054421769,
0, 0, 0, 0, 0, 0.00680272108843537, 0, 0, 0.00340136054421769,
0, 0, 0, 0, 0.00340136054421769, 0.0102040816326531, 0, 0, 0,
0, 0, 0.00340136054421769, 0, 0, 0, 0.00340136054421769, 0, 0,
0, 0, 0, 0, 0.00340136054421769, 0), `44` = c(0, 0, 0.0340136054421769,
0, 0, 0, 0, 0.00680272108843537, 0.00340136054421769, 0, 0, 0,
0, 0, 0, 0, 0.00340136054421769, 0, 0.00340136054421769, 0, 0,
0.00680272108843537, 0, 0, 0, 0, 0, 0, 0, 0.00340136054421769,
0, 0.00340136054421769, 0, 0, 0, 0, 0, 0.00680272108843537, 0,
0, 0, 0, 0, 0, 0, 0, 0.00680272108843537, 0, 0, 0), `5` = c(0,
0, 0.00340136054421769, 0, 0, 0, 0.00680272108843537, 0, 0, 0,
0, 0, 0, 0, 0.00340136054421769, 0, 0, 0, 0, 0.00340136054421769,
0.00340136054421769, 0, 0, 0, 0.00680272108843537, 0, 0, 0, 0,
0, 0.00340136054421769, 0, 0, 0.00340136054421769, 0.00340136054421769,
0, 0, 0, 0.00340136054421769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
)), row.names = c(NA, 50L), class = "data.frame")
I want to add values as annotation below the xaxis tick labels. So I changed the column names. Now I am trying to set different font size and face to the tick labels.
colnames(b) <- c("501\nN=804 ","48\nN=31","8\nN=74", "44\nN=66","5\nN=38")
ggplot(data = melt(b), aes(x=variable, y=value)) + stat_boxplot(geom ='errorbar', width = 0.3) + scale_fill_manual(values = c("red","red","red","green","green"))+ geom_boxplot(aes(fill=variable), outlier.shape = NA) + xlab("Human (heavy)") + ylab("Mutation frequency") + theme_bw() + theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank(), legend.title= element_blank()) + scale_y_continuous(limits = c(0,0.08), expand = c(0,0)) + theme(axis.title = element_text(face = "bold", size = 14), legend.position = "none", axis.text = element_text(size = 12))
Or instead of changing column names can I just add values below x axis with different font? I tried grid and annotation custom but it didn't work.
annotation <- c("N=804 ","N=31","N=74", "N=66","N=38")
Can anyone help. Thanks