pgfplots manual I'm reading only offers the code for linear regression. I'm using version 1.5 of pgfplots. Thanks,
Katie
pgfplots manual I'm reading only offers the code for linear regression. I'm using version 1.5 of pgfplots. Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Code: Select all
x y errory
21 15.93 1.72
42 28.35 2.27
65 34.93 0.83
78 37.09 1.42
82 37.96 2.26This is actually a linear functionkat_e wrote:[…] f(x)=16.09(x)-32.60 […]
f(x)=ax+b and not a logarithmic one. And is it already complete with fixed coefficients a=16.09 and b=-32.6. So you only need to plot exactly this function in addition to your data set.Code: Select all
\documentclass[a4paper,10pt]{report}
\usepackage{pgfplots,pgfplotstable}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[only marks, ylabel=Tensile index{,} $N m g^{-1}$,xlabel=Schopper-Riegler drainability{,} \emph{SR},legend entries={Reference, NaOH},
legend style={at={(0.97,0.35)}, cells={anchor=west}
}]
\addplot plot[error bars/.cd,
y dir=both, y explicit,
x dir=both, x explicit]
table[x=x,y=y,y error=errory]{data/chap4/RF_wetness_tensileindex.dat};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}Code: Select all
x y errory
21 15.93 1.72
42 28.35 2.27
65 34.93 0.83
78 37.09 1.42
82 37.96 2.26Code: Select all
\addplot[smooth,dashed,domain=0:85] {16.09*ln(x)-32.6};Code: Select all
\documentclass[11pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepackage{filecontents}
\begin{filecontents*}{RF-wetness-tensileindex.dat}
x y errory
21 15.93 1.72
42 28.35 2.27
65 34.93 0.83
78 37.09 1.42
82 37.96 2.26
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
only marks,
xmin=0,
xlabel={Schopper-Riegler drainability, \emph{SR}},
ymin=0,
ylabel={Tensile index, Nm\,g\textsuperscript{-1}},
legend entries={Reference, NaOH},
legend style={
at={(0.97,0.35)},
cells={anchor=west}
}
]
\addplot plot [
error bars/.cd,
y dir=both,
y explicit,
x dir=both,
x explicit
] table[x=x,y=y,y error=errory] {RF-wetness-tensileindex.dat};
% \addplot[smooth,dashed,domain=0:85] {16.09*ln(x)-32.6};
\addplot[raw gnuplot,smooth,dashed] gnuplot {
f(x)=a*log(x)+b;
fit f(x) 'RF-wetness-tensileindex.dat' using 1:2 via a,b;
plot [x=0:85] f(x);
};
\end{axis}
\end{tikzpicture}
\end{document}a and b can only be found in the terminal output, but not in the log file (*.log). Gnuplot finds a=16.0891 and b=-32.6035 after five iterations. So your function is quite close.Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis