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 want to read .xls format file in pgfplot to draw a graph. I couldn't find how to do that. Is it possible to do that? I have attached a small .xls file here for which I want to compute plot.

http://www.2shared.com/document/5DT41bYC/rate.html

share|improve this question
5  
You may save it as rate.csv and then pgfplots can read it. –  Harish Kumar Jan 20 '13 at 7:17
    
Thanks Harish Kumar. Can you give me a small example for that? –  tikzlearner Jan 20 '13 at 7:54
3  
@user1280282: have a look to Jake's answer here. –  Claudio Fiandrino Jan 20 '13 at 9:35

1 Answer 1

up vote 5 down vote accepted

You may save the file as rate.csv (comma delimited) or rate.txt (tab delimited). After little conditioning, your data will look like:

a,       life hope,     theater review,     smoke cloud
1,       0.000004824,   0.00035694,         0.000004824
2,       0.000004687,   0.000360903,        0
3,       0.000009425,   0.000282764,        0
4,       0.000004794,   0.000278048,        0.000004794
5,       0.000004565,   0.000328691,        0

Now you can use:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents*}{mydata.csv}
a,       life hope,     theater review,     smoke cloud
1,       0.000004824,   0.00035694,         0.000004824
2,       0.000004687,   0.000360903,        0
3,       0.000009425,   0.000282764,        0
4,       0.000004794,   0.000278048,        0.000004794
5,       0.000004565,   0.000328691,        0
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
\begin{axis}[legend entries={life hope, theater review, smoke cloud},
%legend style={
%at={(0.5,-0.2)},
%anchor=north,
%legend columns=1,
%cells={anchor=west},
%font=\footnotesize,
%rounded corners=2pt,
%}, 
reverse legend, legend pos=outer north east,xlabel=Trend,
    ylabel=Data]
\addplot table [x=a, y=life hope,, col sep=comma] {mydata.csv};
\addplot table [x=a, y=theater review, col sep=comma] {mydata.csv};
\addplot table [x=a, y=smoke cloud, col sep=comma] {mydata.csv};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

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.