[Tex/LaTex] Alternative for drawing graphs

graphicstikz-pgf

I've been trying to draw a graph with a series of X,Y points in TikZ, but it won't accept my points so I'm seeking an alternative package that might handle scaling a bit better. The kind of points i've been trying to graph are imported from a text file and look something like:

0 -5181.542311
0.001388889 -5180.244522
0.002777778 -5176.351945
0.004166667 -5169.866943
0.005555556 -5160.793459
0.006944444 -5149.137011
0.008333333 -5134.904699
0.009722222 -5118.1052
0.011111111 -5098.748774
...

Any ideas on suitable alternatives for this kind of data?

Best Answer

Without more details of exactly what you attempted and the associated error messages it is difficult to pinpoint why tikz won't accept the points.

Here is an example of using \pgfplotstableread to read in the data from an external file. Here I used the filecontents package to create the external file and package this into a compilable example, but if you already have the data in an external file, this is not needed.

enter image description here

\documentclass{article}
\usepackage{pgfplots}

\usepackage{filecontents}
\begin{filecontents*}{data.dat}
          0 -5181.542311
0.001388889 -5180.244522
0.002777778 -5176.351945
0.004166667 -5169.866943
0.005555556 -5160.793459
0.006944444 -5149.137011
0.008333333 -5134.904699
0.009722222 -5118.1052
0.011111111 -5098.748774
\end{filecontents*}
%
\begin{document}
\pgfplotstableread{data.dat}{\MyDataTable}
\begin{tikzpicture}
\begin{axis}
    \addplot [blue, ultra thick, smooth] table {\MyDataTable};
\end{axis}
\end{tikzpicture}
\end{document}
Related Question