
Thanks,
Katie
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
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.26
This 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.26
Code: 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.NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p