I transformed my y-axis scales as described here:
How can I format axis labels with exponents with ggplot2 and scales?
I used the following code:
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)))))} )
which works fine, but what I am failing to do is, to set t0
expand=c(0,0) and/or limits=c(x,y)
(as visible in the graphs of the link)
Did anyone of you figure out how to solve this?
Thank you very much for your attention and hopefully help!
Best Regards
My data looks like this:
and the complete code is:
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) )+
sorry for providing the data only as a picture. I just do not know better. I hope with this information you are able to help me. Thank you already for trying!