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.
Asked
Active
Viewed 1.3k times
3
Peter Jansson
- 7,206
tikzlearner
- 4,527
1 Answers
9
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}

rate.csvand thenpgfplotscan read it. – Jan 20 '13 at 07:17