I'm using nls with geom_smooth
as below. This works fine
ggplot(model.data, aes(x=T, y=Value)) +
geom_line(aes(colour=as.factor(Year)), size = 1) +
geom_smooth(method = "nls", formula = y ~ a * (1 - exp(-b * x)), method.args = list(start = c(a=-2000,b=0.005)), se=FALSE, size=2, color='Grey')
But I also want to reverse the x-axis so I add
scale_x_reverse()
This then results in errors from nls, i.e.
Warning message: Computation failed in
stat_smooth()
: number of iterations exceeded maximum of 50
So it appears that scale_x_reverse()
is transforming the x values passed to geom_smooth()
? How can I express the model so it works regardless of the axis transformation?