0

I am trying to read an external ascii file with multiple y-values per x value, to keep it simple I'll limit myself to xyy as the problem already occurs here.

However, I am trying to make several, completly independent figures, so I use the data from one file in multiple tikzpictures. So far this is working with one major flaw, no matter what I do I can only plot the first column vs. the second, e.g. power vs. quantumyield won't work, but power vs. intensity does. Maybe I just have a serious "f+#* up" in my code.

I know the column seperator is tab and not specified directly, but that is because no matter how I add the "col sep = tab" option, I always get the error that tikz doesn't know this key and therefore is ignoring it.

\begin{filecontents*}{rr_1_00.txt}
# phi = 1
power   intensity   quantumyield
10  4   8
20  8   4
40  12  0
\end{filecontents*}

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}

\begin{tikzpicture}[scale=2]
\begin{axis}[xlabel = {$I_{abs}$},  ylabel = {$Q.Y.$}]

    \addplot [x=power, y=quantumyield] table {rr_1_00.txt};

\end{axis}
\end{tikzpicture}
\end{document}

This should decline

The line in the graph I added should decline if the third column was read correctly, but as you can the, he took the second column for the y values. Unfortunatly I can't split the files to single xy-files as there are to many of them (about 120 files with up to 8 y-axis)

Hopefully some of you guys know the answer, I'm struggeling for days now and literally read hundreds and hundreds of posts and couldn't find a solution.

Best regards Chris

  • forgot to mention: I'm using Miktex 2.9 (last package update feb. 2019) and TEXnic Center 2. The minimal example was created and testet in Texmaker. The "art" of my pgfplot was done by starting from zero with the pgfplots manual from ctan – Chris Apr 16 at 9:51
2

The table keyword should be before the options:

\begin{filecontents*}{rr_1_00.txt}
# phi = 1
power   intensity   quantumyield
10  4   8
20  8   4
40  12  0
\end{filecontents*}

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}

\begin{tikzpicture}[scale=2]
\begin{axis}[xlabel = {$I_{abs}$},  ylabel = {$Q.Y.$}]

    \addplot  table [x=power, y=quantumyield]  {rr_1_00.txt};

\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • Holy s*#+ ..... that was quick.....and yes, stupid mistake by me. Thank you very much! – Chris Apr 16 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.