我想读取.xls
格式文件来pgfplot
绘制图形。我找不到如何操作。可以这样做吗?我.xls
在这里附加了一个我想为其计算图的小文件。
答案1
您可以将文件保存为rate.csv
(逗号分隔)或rate.txt
(制表符分隔)。经过一些调整后,您的数据将如下所示:
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
现在您可以使用:
\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}