enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

Change title font size and add label for X-axis in barplot of enrichResult?

Open JSLJ23 opened this issue 3 years ago • 2 comments

Hi YuLab,

I am trying to change the font size for the title of the barplot generated by this function but there doesn't seem to be an argument for this, is there any way to do so? Also when I try to add a label for the X-axis with xlab = "x-axis title", it doesn't update this in the rendered plot... Are these functions not possible within barplot.enrichResult?

Thanks!

JSLJ23 avatar Sep 14 '20 19:09 JSLJ23

Hi, it seems x and y are flipped in barplot(), and the font.size argument controls size of axis label. You can use ggplot2::labs() to modify axis and adjust title size withggplot2::theme():

library(DOSE)
library(enrichplot)
library(ggplot2)

data(geneList)
de <- names(geneList)[1:100]
x <- enrichDO(de)

barplot(x, title = "I'm the title") + 
    labs(y = "x-axis title") + #or ylab("x-axis title")
    theme(plot.title = element_text(size = 20))

Ning-L avatar Sep 17 '20 16:09 Ning-L

Wow this worked perfectly, thank you for your help!:)

JSLJ23 avatar Sep 18 '20 08:09 JSLJ23