I am working on some viscosity experiments and I'm trying to make an Eyring plot with ν vs. θ. When I create the plot with ggplot2 I can't get my model displayed.
These are the values used:
> theta [1] 25 30 35 40 45 > nu [1] 1.448462 1.362730 1.255161 1.167408 1.083005 Here I create the plot with my values from above:
plot <- ggplot()+ geom_point(mapping = aes(theta, nu), colour = "#0072bd", size = 4, shape = 16)+ theme_bw()+ labs( x = expression(paste(theta, " ", "[°C]")), y = expression(paste("ln(", nu, ")", " ", "[mPa*s]")))+ ylim(0, 10)+ xlim(0, 100) That's what the plot looks like.
Now, I add my model with geom_smooth()
plot + geom_smooth( method = "nls", method.args = list(formula = nu~a*exp(b/theta), start=list(a=1, b=0.1))) But nothing happens... Not even an error message and the plot looks just the same as before.
I also tried to put the formula directly as a geom_smooth() argument and the start values as well,
plot + geom_smooth( method = "nls", formula = nu~a*exp(b/theta), start=list(a=1, b=0.1)) but then I get the
Error:Unknown parameter: start
Can anyone find the mistake I'm making?
Thanks in advance!
Cheers
EDIT
When separating the aesthetics mapping,
plot <- ggplot()+ aes(theta, nu)+ geom_point(colour = "#0072bd", size = 4, shape = 16)+ theme_bw()+ labs( x = expression(paste(theta, " ", "[°C]")), y = expression(paste("ln(", nu, ")", " ", "[mPa*s]")))+ ylim(0, 10)+ xlim(0, 100) I get the following error (and still nothing changes):
Warning message:
1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to min; returning -Inf 3: Computation failed in stat_smooth(): $ operator is invalid for atomic vectors



nlsoutside of ggplot?nlsoutside seems to work:> nls(nu~a*exp(b/theta), start=list(a=1, b=0.1))gives me the following:Nonlinear regression model model: nu ~ a * exp(b/theta) data: parent.frame() a b 0.6153 22.7767 residual sum-of-squares: 0.008136 Number of iterations to convergence: 5 Achieved convergence tolerance: 3.11e-06geom_point, i.e.ggplot()+aes(theta, nu)+geom_point(colour = "#0072bd", size = 4, shape = 16)+.... Then you'll get your error message.formulaingeom_smoothexpects you to refer to x and y rather than the actual names of the variables