[英]How to increase axis label text size in ggplot R?
希望这是有道理的,并提前感谢您的时间:)
我制作了一个条形图来可视化微阵列数据集中显着下调的基因的 Gene Ontology 富集。
我试图增加标题的大小,“折叠浓缩”,y 轴上的数字和 x 轴上的标签。 我设法增加了标记条形的数字的大小(在 geom_text 下),但我一直在努力如何增加上述文本的大小。
我的txt文件内容
处理 fold_enrichment FDR
Mammillary_axonal_complex_development 200 <0.01
Corticospinal_tract_morphogenesis 200 <0.1
Notochord_morphogenesis 200 <0.1
体节发生 52.27 <0.01
骨化 16.87 <0.1
Epithelial_tube_morphogenesis 12.85 <0.1
Regulatory_of_cell_differentiation 4.92 <0.01
我的代码
dnfgfr1d <- read.table("dnfgfr1d.txt", header = TRUE)
library(ggplot2)
bc1d <- ggplot(dnfgfr1d, aes(x = reorder(process, fold_enrichment), y = fold_enrichment, fill = FDR)) +
geom_bar(stat = "identity", width = 0.5) +
ggtitle("Genes down regulated by dnFGFR1") +
geom_text(aes(label = fold_enrichment), nudge_y = 8, color = "black", size=4) +
scale_y_continuous(breaks = seq(0,220,by = 20), limits=c(0,220), expand=c(0,0)) +
xlab("") +
ylab("Fold enrichment") +
labs(fill='FDR') +
scale_x_discrete(labels=c("Regulation of cell differentiation",
"Epithelial tube morphogenesis",
"Ossification",
"Somitogenesis",
"Notochord morphogenesis",
"Corticospinal tract morphogenesis",
"Mammillary axonal complex development")) +
coord_flip() +
theme_classic() +
theme(plot.title = element_text(hjust=0.5))
bc1d + scale_fill_manual(breaks = c("<0.01", "<0.1"),
values=c("#3399CC", "#000099"))
对此的任何帮助将不胜感激,因为我已经为此苦苦挣扎了一段时间,并且我需要反复使用此代码来为我的论文生成多个数字。
谢谢,
丽芙
这是 Henry Wang 的一个非常好的概述,它显示了可以通过 ggplot 中的theme()
函数修改的所有不同元素。
在您的情况下,您必须使用bc1d + theme(axis.text.x = element_text(size = 14))
请注意,您可以专门调整 x 轴或 y 轴的大小,因为它们是从axis.text
继承的,因此也可以与element.text()
如果您想要更详细的信息,您可以随时访问@jared_mamrot 评论的参考。
这一切都可以在主题参数中完成。
bc1d + theme(axis.text=element_text(size=12),
axis.title=element_text(size=14,face="bold"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.