0

Hi I have the following code which produces the regression straight based on the points on the table. I suppose the red dots on the curve are the equivalent of each point but on the fitted straight. I would like a way to change the squares to circles and draw a line from each point the the square (that will be a circle) automatically if possible. Thank you very much in advance. Any advice on how to do better post will also be much appreciated.

\pgfplotstableread{
    X Y
    1 1
    2 3
    2.5 3.1
    1.5 2.7
    1.4 1.8
    2 4
    1.2 2
    1.8 2
    2.1 2 
    2.4 2

}{\datatable} \begin{figure} \label{Linear regression plot} \begin{tikzpicture} \begin{axis}[ xlabel={X}, ylabel={Y}, legend cell align=left, legend pos=north west] \addplot[only marks] table {\datatable}; \addlegendentry{Points ${x,y}$ in our dataset} \addplot table [y={create col/linear regression={y=Y}}] {\datatable}; \addlegendentry{Fitted simple regression} \end{axis} \end{tikzpicture} \caption{Plot of a linear regression} \end{figure}

Output I would like, mine is the same but without the vertical straight lines:

Output I would like, mine is the same but without the vertical straight lines

Torbjørn T.
  • 206,688

0 Answers0