我改变了我的y轴刻度,如下所述:
How can I format axis labels with exponents with ggplot2 and scales?
我使用了以下代码:
scale_y_continuous(breaks=c(0,1e-4,2e-4,3e-4,4e-4),label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", " %*% 10^", scientific_format()(x)))))} )
工作正常,但我没有做的是设置t0
expand=c(0,0) and/or limits=c(x,y)
(如链接图所示)
你们有没有人想出如何解决这个问题?
非常感谢您的关注,希望对您有所帮助!
最好的问候
我的数据如下:
,完整的代码是:
ggplot(data,aes(E,M,fill=factor(T)))+
geom_smooth(method='lm', colour="black",se=FALSE,size=0.01)+
geom_errorbar(aes(ymin=M-SE, ymax=M+SE), width=15, alpha=1)+
geom_point(size =2.5, colour="black", shape=21)+
ggtitle("")+
theme_classic()+
theme(axis.ticks.length=unit(.1, "cm"))+
theme(axis.text = element_text(colour = "black"))+
theme(axis.ticks = element_line(colour = 'black', size = 0.1))+
theme(axis.line=element_line(size=.1))+
theme(legend.key.size=unit(0.5,'lines'))+
theme(legend.key.height=unit(1,"line"))+
theme(legend.text=element_text(size=10))+
theme(legend.position=c(0.92,0.1))+
theme(legend.direction="vertical")+
guides(fill=guide_legend(title=NULL))+
ylab(expression(paste(k["Pi"]~","~~(s^-1))))+
scale_fill_manual(breaks=c("L","LN"),values=c("black", "white"))+
scale_x_continuous(limits = c(-0.1,1220),breaks=c(0,200,400,600,800,1000,1200), labels=c(0,"",400,"",800,"",1200),expand=c(0,0))+
# scale_y_continuous(breaks=c(0,1e-4,2e-4,3e-4,4e-4), labels=c(0,"",2e-4,"",4e-4),label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", " %*% 10^", scientific_format()(x)))))} ) +
# scale_y_continuous(limits=expand=c(-0.00001,4.e-4),breaks=c(0,1e-4,2e-4,3e-4,4e-4),label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", " %*% 10^", scientific_format()(x)))))} ) +
#scale_y_continuous(limits=c(-0.00001,4.e-4),breaks=c(0,1e-4,2e-4,3e- 4,4e-4),label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", " %*% 10^", scientific_format()(x)))))} ) +
#scale_y_continuous(breaks=c(0,1e-4,2e-4,3e-4,4e-4),label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", " %*% 10^", scientific_format()(x)))))} ) +
# scale_y_continuous(limits = expand=c(0,0))+
scale_y_continuous(breaks=c(0,1e-4,2e-4,3e-4,4e-4),label= function(x) {ifelse(x==0, "0", parse(text=gsub("[+]", "", gsub("e", " %*% 10^", scientific_format()(x)))))}, expand=c(0,0) )+
抱歉,仅将数据作为图片提供。我只是不知道更好。
我希望通过这些信息,你能够帮助我。
谢谢你已经尝试过了!