[Tex/LaTex] How to adjust the size of the pgf plot and get rid of these colours

pgfplots

I am having too much trouble trying to get a nice looking plot that takes latex font with gnuplot so I am trying pgfplots again.

The only trouble is that I cannot resize the plot, so that it fills half the page. I would also like the points to be smaller and don't know how to make it so. I would also like to not have to paste the data twice to get it to work. I cannot pull it from a file because pgplots seems to need titles and my file format has not the titles in it.

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}


\begin{tikzpicture}[domain=0:18]
\begin{axis}[xlabel={Current $mA$}, ylabel={Voltage $mV$}]

\addplot[scatter, only marks, scatter src=\thisrow{Current},
      error bars/.cd, y dir=both, x dir=both, y explicit, x explicit, error bar style={color=mapped color}]
      table[x=Current,y=Voltage,x error=xerr,y error=yerr] {
Current Voltage xerr   yerr     
13.9900 -1.80000 0.149900 0.197300 
12.0200 -1.50000 0.130200 0.197750 
9.99000 -1.30000 0.109900 0.198050 
8.00000 -1.00000 0.0900000 0.198500 
6.02000 -0.800000 0.0702000 0.198800 
4.01000 -0.500000 0.0501000 0.199250 
2.00000 -0.300000 0.0300000 0.199550 
0.00000 0.00000 0.0100000 0.200000 
-2.00000 0.300000 -0.0100000 0.200450 
-4.00000 0.500000 -0.0300000 0.200750 
-6.02000 0.800000 -0.0502000 0.201200 
-8.00000 1.10000 -0.0700000 0.201650 
-10.0000 1.30000 -0.0900000 0.201950 
-12.0300 1.50000 -0.110300 0.202250 
-13.9800 1.80000 -0.129800 0.202700 
};
   \addplot[no markers,color=blue,forget plot] table [x=Current, y={create col/linear regression={y=Voltage}}]{
   Current Voltage xerr   yerr     
13.9900 -1.80000 0.149900 0.197300 
12.0200 -1.50000 0.130200 0.197750 
9.99000 -1.30000 0.109900 0.198050 
8.00000 -1.00000 0.0900000 0.198500 
6.02000 -0.800000 0.0702000 0.198800 
4.01000 -0.500000 0.0501000 0.199250 
2.00000 -0.300000 0.0300000 0.199550 
0.00000 0.00000 0.0100000 0.200000 
-2.00000 0.300000 -0.0100000 0.200450 
-4.00000 0.500000 -0.0300000 0.200750 
-6.02000 0.800000 -0.0502000 0.201200 
-8.00000 1.10000 -0.0700000 0.201650 
-10.0000 1.30000 -0.0900000 0.201950 
-12.0300 1.50000 -0.110300 0.202250 
-13.9800 1.80000 -0.129800 0.202700 
}; 

\end{axis}
\end{tikzpicture}
\end{document}

graph

Update: When trying the method below: This is the file:

13.9600 -7.60000 0.149600 0.188600 
12.0100 -6.50000 0.130100 0.190250 
9.98000 -5.40000 0.109800 0.191900 
7.99000 -4.30000 0.0899000 0.193550 
6.01000 -3.30000 0.0701000 0.195050 
4.00000 -2.20000 0.0500000 0.196700 
2.00000 -1.10000 0.0300000 0.198350 
0.00000 0.00000 0.0100000 0.200000 
-2.00000 1.10000 -0.0100000 0.201650 
-3.99000 2.20000 -0.0299000 0.203300 
-6.01000 3.20000 -0.0501000 0.204800 
-7.99000 4.30000 -0.0699000 0.206450 
-9.99000 5.40000 -0.0899000 0.208100 
-12.0000 6.40000 -0.110000 0.209600 
-13.9700 7.50000 -0.129700 0.211250

graphoutcome

enter image description here

Best Answer

  1. PGFPlots does not require data files to have headers. If there are no headers, you can refer to the columns using x index=<column number>, x error=<column number>, etc. In the linear regression options, you can set y=1 to refer to the second column.
  2. To resize the plot, you can specify the height and/or width of the plot. If you only specify one of these, the aspect ratio will be kept constant, and the plot will just be scaled. If you specify both, the aspect ratio changes.
  3. If you want the data points to be smaller, set mark size=1.5 (or something like that).
  4. If you don't want colours for the markers (as your question title suggests), don't use scatter, just use only marks.

A file data.csv:

13.9900 -1.80000 0.149900 0.197300 
12.0200 -1.50000 0.130200 0.197750 
9.99000 -1.30000 0.109900 0.198050 
8.00000 -1.00000 0.0900000 0.198500 
6.02000 -0.800000 0.0702000 0.198800 
4.01000 -0.500000 0.0501000 0.199250 
2.00000 -0.300000 0.0300000 0.199550 
0.00000 0.00000 0.0100000 0.200000 
-2.00000 0.300000 -0.0100000 0.200450 
-4.00000 0.500000 -0.0300000 0.200750 
-6.02000 0.800000 -0.0502000 0.201200 
-8.00000 1.10000 -0.0700000 0.201650 
-10.0000 1.30000 -0.0900000 0.201950 
-12.0300 1.50000 -0.110300 0.202250 
-13.9800 1.80000 -0.129800 0.202700 

The .tex file:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}


\begin{tikzpicture}[domain=0:18]
\begin{axis}[xlabel={Current mA}, ylabel={Voltage mV}]

\addplot[mark size=1.5, only marks,
      error bars/.cd,
        y dir=both, y explicit,
        x dir=both, x explicit
      ]
      table [x error index=2, y error index=3]
      {data.csv};
   \addplot[no markers,color=blue,forget plot]
    table [y={create col/linear regression={y=1}}]
    {data.csv}; 

\end{axis}
\end{tikzpicture}
\end{document}