I am attempting to draw a linear regression line on my graph using pgfplotstable
. However, for some reason, it appears to be calculating the regression three orders of magnitude too large and inverted, is this a bug or am I doing something wrong?
My data-set:
lnPa 1/T
6.5723 0.002304
6.7214 0.002273
6.7178 0.002273
6.7117 0.002278
6.7178 0.002278
6.6783 0.002283
6.6490 0.002288
6.6254 0.002294
6.6026 0.002299
6.5820 0.002304
6.5539 0.002309
6.4907 0.002320
6.4281 0.002331
6.3509 0.002347
6.2823 0.002364
6.2066 0.002381
6.1312 0.002381
6.0707 0.002404
6.0113 0.002421
5.8861 0.002445
5.8141 0.002506
5.7236 0.002475
5.6490 0.002494
5.5759 0.002506
5.5134 0.002519
5.3660 0.002545
5.2679 0.002571
5.1761 0.002584
5.0876 0.002597
5.0239 0.002611
4.9628 0.002625
4.8283 0.002646
4.7791 0.002660
It plots a graph like this without the regression line:
However, when I add in the line of best fit:
The figure
for this is as below:
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[legend pos=north east,anchor=west, xlabel={$T^{-1}/ K^{-1}$}, ylabel={$\ln P*_a$}]
\addplot table [only marks, x=1/T,y=lnPa]{GraphData.txt};
\addplot [no markers, thick, red] table [y={create col/linear regression={y=lnPa}}]{GraphData.txt};
%\addlegendentry{$\dfrac{dy}{dx} = \pgfplotstableregressiona$}
%\addlegendentry{$y_{intercept} = \pgfplotstableregressionb$}
\end{axis}
\end{tikzpicture}
\caption{Graph to show the relationship between the natural log of pressure and the inverse of temperature}
\label{fig:ResultsGraph}
\end{figure}
Can anyone spot what's going on here?