0

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:

enter image description here

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!

Rrrrrrrrrrr
  • 95
  • 1
  • 9
  • can you dput some data please? – Preston Sep 05 '17 at 13:43
  • `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) ) ` works on my R. – Marco Sandri Sep 05 '17 at 13:55
  • Thank you, I've tried it but it doesn't work for my R(Studio). I do not understand why :/ I have a very simple data set. x,y and a factor z with standard errors. – Rrrrrrrrrrr Sep 05 '17 at 14:31
  • @Rrrrrrrrrrr You should share your data. It will be easier to help you. – Marco Sandri Sep 06 '17 at 20:54
  • @Rrrrrrrrrrr Please, edit your post adding the output of `dput(data)` or at least `dput(head(data))`. Do not post images of your data. – Marco Sandri Sep 12 '17 at 16:44
  • There's no need to apologize for posting your data as a picture. There *is* a need to follow what others have already advised you, though. If you can't provide your data in reproducible form, we can't troubleshoot in the dark. – Z.Lin Sep 13 '17 at 03:42

0 Answers0