Having the following table:

enter image description here

How can we make a plot diagram showing the relation between P,Q? I would like the P-value on y-axis and the Q-values on the x-axis.

  • 1
    The package pgfplotstable can do the job – Marco Daniel Jun 29 '13 at 18:43
  • As Marco pointed out, pgfplotstable can do this right out of the box; it is especially convenient when you have the raw data as a CSV file. – Sean Allred Jun 29 '13 at 19:13

Here's a minimal example:

Assuming you have the data in a file (I called the file data.dat):

P $Q_A$ $Q_B$ $Q_D$
10 5 7 12
8 8 10 18
6 12 16 28

Use the code:




  xlabel=Q Series,
  ylabel=P Values]
\addplot table [y=P, x=$Q_A$]{data.dat};
\addlegendentry{$Q_A$ series}
\addplot table [y=P, x=$Q_B$]{data.dat};
\addlegendentry{$Q_B$ series}
\addplot table [y=P, x=$Q_D$]{data.dat};
\addlegendentry{$Q_D$ series}


enter image description here

Check out the documentation for pgfplots. It's very well suited to creating graphs. I've only demonstrated the most basic possibilities. But it has a lot of power.

Note if you're going to use the package pgfplotstable then, technically, there's no need to load pgfplots. But, if you don't use pgfplotstable then be sure to load pgfplots to be able to graph your data.

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.