\documentclass{article}

% Required packages
\usepackage{tikz}
\usepackage{pgfplots}


\begin{document}

% Drawing a graph
\begin{tikzpicture}
 \begin{axis}[
  title={Title of the graph},       % Title of the graph
  xlabel={Horizontal axis label},   % Horizontal label
  ylabel={Vertical axis label},     % Vartical label
  xmin=0, xmax=10,                 % Range of the horizontal axis
  ymin=0,ymax=10,                  % Range of the vertical axis
  legend pos=north west             % Position of the legend
 ]

 % First set of data, directly decribed in the tex file
 \addplot[color=red] % Color of data
  coordinates {(1,2)(4,6)(10,1)}; % The data itself
  \addlegendentry{Direct input} % Data name

 % Second set of data, extracted from an external file
 \addplot[color=blue]
  table {data.dat}; % Extracting data from the file data.dat
  \addlegendentry{File input}

 \end{axis}
\end{tikzpicture}


\end{document}
