我想更改我的气泡图的布局和图块。不幸的是,我无法弄清楚如何更改下面的代码以获得所需的格式。
ggplot(test, aes(y = modules, x = correlation, colour=direction, size = pvalue)) +
geom_point(data = subset(test, correlation > 0.5 & pvalue > 1.3)) +
facet_grid(facets = . ~ Label) + ggtitle("Module-Trait Association") +
theme(axis.text = element_text(size = 10, color = "black")) +
theme(strip.background = element_rect(colour = "black", fill = "white",size = 1, linetype = NULL)) + scale_size_continuous(range = c(0, 12))+
scale_colour_manual(values=c(down= "blue", up = "red")) + theme_bw() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
strip.background = element_rect(colour="white", fill="white"),
panel.border = element_rect(colour = "black")
)
相关值介于0.5和1之间,因此x轴上的网格值范围为0.5到0.9。即使我减小了尺寸,许多气泡的边缘(r = 0.75或更高)也不在图表之外。我想将x轴更改为0.3 - 1.2的范围。
我想更改tile的名称,这些名称现在是“direction”(“EigenGene Direction”)和“pvalue”(“log10(p)”)列的名称。
最重要的是,我想更改代码块中p值的气泡大小范围。它显示5个气泡,范围从2到4(2,2.5,3,3.5,4)。我想泡泡的大小从1到4不等。
你能告诉我吗?
提前谢谢你。 阿妮塔
答案 0 :(得分:0)
如果您遇到类似的问题,我找到了问题的解决方案。
ggplot(test, aes(y = modules,x = correlation, colour=direction, size = pvalue))+
geom_point(data = subset(test, correlation > 0.5 & pvalue > 1.3))+
facet_grid(facets = . ~ Label,margins = FALSE)+
ggtitle("Module -Trait Association")+
labs(x="Correlation", y="Module")+
theme(strip.background = element_rect(colour = "black", fill = "white",size = 10, linetype = NULL))+
scale_colour_manual("EigenGene Direction", values=c(down= "blue", up = "red")) +
theme_bw()+
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),strip.background = element_rect(colour="white", fill="white"),panel.border = element_rect(colour = "black",size = 1.2))+
scale_size_area("p-value",max_size = 75, limits= c(1,50), breaks= c(1.3, 2, 3,4),labels= c("0.05","0.01","0.001","0.0001")) +
scale_x_continuous(breaks=c(0.5,0.7,0.9,1.1), limits=c(0.4,1.2), labels = c("0.5", "0.7","0.9", "1.1")) +
guides(color = guide_legend(override.aes = list(size=6))) +
theme(axis.text = element_text(size=12,colour = "black"),strip.text.x = element_text(colour = "black", face= "bold",angle = 0, size = 12)) +
theme(axis.title.y = element_text(size = 12,angle = 90,vjust = 1, face="bold"), axis.title.x = element_text(size = 12,angle = 0,vjust = 1, face="bold")) +
theme(legend.position= "right",legend.text = element_text(colour="black", size=10, face="bold"), legend.title = element_text(colour="black", size=12,face="bold"), plot.title=element_text(size=25))