I am having trouble getting regression to work. If you wouldn't mind just looking over the code and point me in the right direction I'd really appreciate it. I have loaded pgfplots and pgfplotstable packages.I am new to asking questions here, I apologise if I have made any errors in etiquette.

      axis lines=left,
      width=\linewidth, % Scale the plot to \linewidth
      xlabel=$\omega ^-1$, % Set the labels
      ylabel=Limiting Current,
      x unit=\si{\radian\per\second}$^-\frac{1}{2}, % Set the respective units
      y unit=\si{\ampere},
      legend style={at={(1,0.7)},anchor=north east}
    \addplot [mark=*,color=red,only marks,col sep=comma]
    table {Data/nRDE400.csv};
    \addplot [mark=none,color=blue]
    table[y={create col/linear regression={y=column 2}},col sep=comma] {Data/nRDE400.csv};
\caption{RDE studies of modified electrode in 0.5 M NaOH saturated with \ce{O2} and scan rate of 20 \si{\milli\volt\per\second}.}

My .csv file looks like this:

column 1,column 2
  • Hi Charles, welcome to the site! In general, it's preferred to include a minimal working example instead of code snippets, i.e. a complete document (starting with \documentclass) that can be compiled without changes and that includes only the minimum code necessary to demonstrate the problem. The code I included in my answer is an example of how such a document could look in your case. – Jake Jul 21 '15 at 15:44
  • Hi Jake, thank you for the welcome. I am very excited to contribute and improve my LateX with the help of the people here. I understand what mean completely. I will be sure to post questions in the manner you have said from now on. – Charles O'Donoghue Jul 22 '15 at 7:39

The col sep key needs to go in the table [...] options, not the \addplot [...] options:


    \addplot [mark=*,color=red,only marks]
    table [col sep=comma] {data.csv};
    \addplot [mark=none,color=blue]
    table[y={create col/linear regression={y=column 2}},col sep=comma] {data.csv};

  • Hi Jake, thank you very, very much for your answer. It sorted everything out straight away. – Charles O'Donoghue Jul 22 '15 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.