6

3

## General purpose

My intension is to use data created by Mathematica as in

- Export Plots to $\LaTeX$,
- $\LaTeX$ and Mathematica, or
- How to export multiple Barcharts from Mathematica to $\LaTeX$

but with a nicer $\LaTeX$ conform font style and similar stuff. This is the reason why I am using the $\LaTeX$ package pgfplots. This package also allows me to add further information and fancy graphical stuff (by using TikZ) to the plot at later time.

## Issue

Now I do not get Mathematica to write me a data-file which can be read by the $\LaTeX$ package pgfplots. The current data (and export) has the following structure:

```
DataTable = {{9/50, 5.00251*10^9, 3.02252*10^9, 2.17472*10^9, 1.97472*10^9},<<1000>>};
Export["Energy.csv", DataTable];
```

The idea is to plot in the end something like

```
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
xlabel={xlabel},
ylabel={ylabel}]
\addplot[color=blue,mark=none]
table [x expr=\thisrowno{0}, y expr=\thisrowno{1}, col sep=space] {data.dat};
\addplot[color=blue,mark=none]
table [x expr=\thisrowno{0}, y expr=\thisrowno{2}, col sep=space] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}
```

## EDIT:

The $\LaTeX$ routine pgfplots uses the following data structure (where the option `col sep=space|tab|comma|colon|semicolon|braces|&|ampersand`

defines the separation character - same is also vaid for the column separation `row sep=newline|\\`

):

```
Field,Energy1, Energy2, Energy3, Energy4
9/50, 5.00251e+09,3.02252e+09,2.17472e+09,1.97472e+09
... (all data like this first row of data)
```

You might want to check out chapter 4.3.2 (Reading Coordinates From Tables) in the pgfplots manual which contains all important informations. By the way the header is not necessary but helps other readers to understand your data.

2So, what structure would be required for this to be possible, for those of us without a familiarity/working installation of $\LaTeX$? – Oleksandr R. – 2014-01-04T00:12:16.030

1The "CSV" export of

Mathematicacreates exactly the structure you like, where one line is exported as`9/50,5.00251e9,3.02252e9,2.17472e9,1.97472e9`

. In you pgfplots code, you used`data.dat`

which should be`data.csv`

with your current approach. What exactly is the issue? – halirutan – 2014-01-04T13:37:32.400@halirutan: It was a stupid error that occured because I did not choose the correct file (I still used the

`data.dat`

file. You are completely right. +1 I will rephrase an answer out of my question for other interested people (as I invested too much time in that issue). – strpeter – 2014-01-04T16:46:03.0271@strpeter No problem. This happens to everyone once in a while. The good thing is, that it works now. – halirutan – 2014-01-04T16:47:41.563