[Tex/LaTex] How to create a line graph in LaTeX

graphicsgraphspackages

I am in need of displaying line graphs in a LaTeX document but I can't figure out how. I searched on Google but did not receive any promising results. Is it really possible to do this within LaTeX or will I have to embed a jpeg image of a line graph created in Excel?

Best Answer

Well pgfplots definitely:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[domain=-2*pi:2*pi]
    \addplot[mark=none, samples=100, red] function {sin(x)};
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Its simple, clean and will produce high quality plots, which fit perfectly into the document style. For more complex plots you may use gnuplot for computation. pgfplots can include table files as well (data stored in columns such tables gnuplot prints).

Related Question