Dear community,
For log_fit, the equation is log y=a+b*log x, whose output coefficients are ‘a’ and ‘b’. Slope ‘b’ is applied in view of log x, so how can I plot the non-linear regression in a loglog plot on scale of x?
Another way is to use log x as the scale, but all other attributes of loglog plot need to be mannually set in this case, i.e. vertically asymmetric error bar and axis notation. It seems to be harder for me and clumsy.
using CurveFit
coef=log_fit(x,y)
using Plots
scatter(x, y, yerror=se, scale=:log10)
Plots.abline!(coef[2],coef[1],line=:dash)
Plots.abline!(coef[2],coef[1],line=:dash,scale=:log10)#made no difference
Plots.abline!(coef[2],coef[1],line=:dash,xaxis=:log10)#made no difference
Thank you, your method should work but the coefficients output from log_fit are weird (making the ygrid infinite). To make it repeatable, I attached the data in codes.
#population size
x=[ 10 100 1000 10000] #mean time of an allele to extinction or fixation
y= [23.06 245.48 2437.8 31245.775510204083]
se=[2.068502366645087 26.886795788176432 264.41256106505153 2811.6173148600947] #of mean y
using CurveFit
coef=log_fit(x,y)
using Plots
scatter(x, y, yerror=se, scale=:log10,legend=false)