Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have 4 sets of data that all have the same t values (x axis). Can all list be read in at once?

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.10}
\begin{document}
\begin{axis}
\addplot table{
     t  actual  measured  est Q = 0.01  est Q = 0.1
    .1  .1     .2107      .2107         .2107
    .2  .2     .5954      .4122         .4671
    .3  .3     .5940      .4820         .5464
    .4  .4     .4758      .4800         .5027
    .5  .5     .3183      .4207         .3661
    .6  .6     .4060      .4131         .3833
    }
\end{axis}
\end{document}

Can 4 lines be read in like this? If so, how can I differentiate them with 4 different markers?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Yes, absolutely:

screenshot

The idea is to read the data into a macro (called \mydata in the code below), and then you can use, for example:

  \addplot table[x=t,y=actual]{\mydata};

and specify the x and y as you wish.

Note that if you want to use spaces in the column names, then you need to enclose them in braces; for example, you'll note that I used {est Q = 0.1} in both the column name and the addplot command.

Here's a complete MWE that demonstrates the idea.

% arara: pdflatex
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.10}
\begin{document}

\pgfplotstableread{
t  actual  measured  {est Q = 0.01}  {est Q = 0.1}
    .1  .1     .2107      .2107         .2107
    .2  .2     .5954      .4122         .4671
    .3  .3     .5940      .4820         .5464
    .4  .4     .4758      .4800         .5027
    .5  .5     .3183      .4207         .3661
    .6  .6     .4060      .4131         .3833
    }\mydata
\begin{tikzpicture}
\begin{axis}
  \addplot table[x=t,y=actual]{\mydata};
  \addplot table[x=t,y=measured]{\mydata};
  \addplot table[x=t,y={est Q = 0.01}]{\mydata};
  \addplot table[x=t,y={est Q = 0.1}]{\mydata};
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
@dustin you'll have to change the pgfplotstableread command to include the comma, not the addplot command. But, yes, overall, it will work –  cmhughes May 4 at 23:47
    
@dustin use commas to separate every element in every row –  cmhughes May 5 at 1:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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