2

I have 7 *.txt files each with 2 columns of data thus:

time(mins) contacts
3.25    8
1.166666667 4
3.2 6
3.2 7
2.25    8
5.466666667 12
2.25    3
2.166666667 7

I'd like to plot them in separate scatter plots (via TikZ or other at your discretion) but on the same page. I've exported excel versions and they look somewhat unprofessional. Can you point me in the right direction, or a push to get started?

I'd also like to put on a linear regression line with its equation and R^2 value. I can provide both but I see in How do I draw a scatterplot with a function plot? it's possible to do it automatically.

an MWE:

\begin{tikzpicture}[only marks, y=.5cm]
 \draw plot[mark=*,xshift=-6cm] file {data/ScatterPlotExampleData.data};
\draw[->,xshift=-6cm] (6,0) -- coordinate (x axis mid) (17,0);
\draw[->,xshift=-6cm] (6,0) -- coordinate (y axis mid)(6,27);
\foreach \x in {6,8,10,12,14,16}
    \draw [xshift=-6cm](\x cm,1pt) -- (\x cm,-3pt)
        node[anchor=north] {$\x$};
\foreach \y/\ytext in {0/0,2.5/5000,5/10000,7.5/15000,10/20000,12.5/25000}
    \draw (1pt,\y cm) -- (-3pt,\y cm) node[anchor=east] {$\ytext$};
\node[below=1cm] at (x axis mid) {Education};
\node[left=2cm,rotate=90] at (y axis mid) {Income};
\end{tikzpicture}

Equally this matlab2tikzlooks interesting

HCAI
  • 3,325
  • 1
    Doesn't the answer to the question you linked to basically answer your question? It shows how to create a scatterplot from a data table using PGFPlots, including the fit line. Could you clarify what more information you need? – Jake Mar 13 '13 at 17:07
  • I'd like to make 1) a grid of plots from 2)data in separate files. 3) Perform linear regression. I note that pgfplots doesn't actually do linear regression but fits a line through extreme points, is this correct? – HCAI Mar 13 '13 at 19:11
  • 1
    Pgfplots actually does a linear regression. The remark on your linked question meant that it does not extrapolate the resulting line to the left or right of the endpoints. – Christian Feuersänger Mar 13 '13 at 20:47

0 Answers0