# How to join the points from an external file with smooth lines in tikz

I am working on plotting data from an external file. When I use the following code I get the points in the curve joined with lines, however I would like to join them using smooth curves.

\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}
[
grid=major,
grid style={dashed,gray!30},
xmin=0,xmax=300,
ymin=375,ymax=475,
xtick={0,50,...,300},
ytick={375,400,...,475}
]
\addplot table [col sep=tab, x=a, y=b] {results/test_data.dat};
\addplot table [col sep=tab, x=a, y=c] {results/test_data.dat};
\end{axis}
\end{tikzpicture}
\caption{Test Plot}
\label{fig:test_plot}
\end{figure}


Following is the expected curve:

Also I cannot increase or decrease the number of data points. Since these are experimental data.

Can anyone suggest me how to achieve this ? I am new to using latex.

• Related (duplicate?): tex.stackexchange.com/q/109457/2552 – Jake May 24 '16 at 14:26
• I guess its a different scenario here. I want the smooth curve to be passing through all the data points ( As shown in expected picture which is made in excel sheet ). Also I tried using smooth with \addplot but did not achieve anything. – sravan kumar May 24 '16 at 14:39
• – Bernhard Kleine May 24 '16 at 14:42
• The smooth option should work in that case. Could you turn your example into a minimal compilable document (starting from \documentclass and including some dummy data). – Jake May 24 '16 at 14:42
• @sravankumar: I've written an answer. It includes a minimal compilable document, that is a short but complete .tex document that includes all the necessary parts (a documentclass, the packages, and example data) to reproduce the problem. – Jake May 24 '16 at 21:48

You can use the smooth option in the \addplot +[...] options to smooth the curve.

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot +[smooth] table [x=a, y=b] {
a b
50 410
80 390
120 405
150 430
180 445
210 455
240 440
270 415
};
\end{axis}
\end{tikzpicture}

\end{document}

• Works perfectly :) .. Thank you very much for your help jake :) – sravan kumar May 25 '16 at 8:59