Graphics, Figures & TablesProblem using pgfplotstable

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Problem using pgfplotstable

Post by mas »

I tried using pgfplotstableread in inline mode to read the data and plot them subsequently. The table is read and can be typeset. But, if I try to plot, I get an error message. The MWE:

Code: Select all

%
\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
  \pgfplotsset{compat=1.13}
\usepackage{pgfplotstable}

\begin{document}
%
\pgfplotstableread{
T      I1       I2
305   0.158   0.184  
310   0.147   0.175  
316   0.135   0.163   
320   0.127   0.156  
325   0.118   0.146  
330   0.107   0.137  
336   0.097   0.125  
340   0.090   0.116  
346   0.081   0.105  
350   0.071   0.097  
355   0.064   0.089
}\EXPDATA 

\begin{tikzpicture}
\begin{axis} 
  \addplot table [x=T, y=I1] { \EXPDATA } ;
\end{axis}  
\end{tikzpicture}

\end{document} 
The error message:

Code: Select all

...
! Undefined control sequence.
\EXPDATA ->\pgfpl@@ 
                    {T}\pgfpl@@ {I1}\pgfpl@@ {I2}
l.28   \addplot table [x=T, y=I1] { \EXPDATA } ;
  
?
Am I missing something very trivial here?

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Problem using pgfplotstable

Post by Johannes_B »

\pgfplotstableread will store the table as internal structure.

So \EXPDATA does not contain your simple tabular, but the parsed and disected information. Better use external files.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Problem using pgfplotstable

Post by mas »

Thanks for the clarification. Looks like the manual (p48) which says this:

Code: Select all

\pgfplotstableread{datafile.dat}\loadedtable % use any custom name in place of ‘\loadedtable’
...
\addplot table[x=dof,y=L2] {\loadedtable};
...
\addplot table[x=dof,y=Lmax] {\loadedtable};
...
is not not to be taken at face value.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Problem using pgfplotstable

Post by Johannes_B »

You are correct, this is in the manual of pgfplots. So, this is supposed to work and could be a bug. I investigate further.

EDIT: Ulrike Fischer saves the day, not the first time i have to say :-) http://chat.stackexchange.com/transcrip ... 4#27675874
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: Problem using pgfplotstable

Post by mas »

Thanks to you and Ulrike. Got it to work. Almost all the tikz related stuff use space and newlines liberally. Never suspected that the space would be a show stopper :D

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply