嘿,我正在尝试编译以下 Latex(最小不起作用的示例)
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{filecontents}
\begin{filecontents*}{hdfs_logs.csv}
iteration,GD/CD,data,data_size,basis/chunk size,#basis/chunks,dedup #basis/chunks
0,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-25.log,413141404,127,3227668,2653695
1,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-05.log,377418163,127,6176248,5057417
2,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-14.log,379043438,127,9137525,7471653
3,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-06.log,407971604,127,12324804,10078357
4,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-31.log,325649983,127,14868945,12497466
5,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-01.log,697979040,127,20321907,17709829
6,gd,files/hdfs_logs/hadoop-hdfs-namenode-mesos-01.log,1125510545,127,29114959,24421362
7,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-16.log,311133116,127,31545687,26325360
8,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-27.log,420281792,127,34829139,29016087
9,gd,files/hdfs_logs/hadoop-hdfs-secondarynamenode-mesos-01.log,88368089,127,35519515,29383729
10,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-19.log,449586557,127,39031910,32289842
11,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-17.log,447704440,127,42529601,35180232
12,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-10.log,397436049,127,45634571,37698415
13,gd,files/hdfs_logs/HDFS.log,1577982906,127,57962563,50020476
14,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-11.log,367908511,127,60836849,52344531
15,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-20.log,429342641,127,64191089,55098658
16,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-23.log,437840376,127,67611717,57912426
17,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-09.log,418434394,127,70880736,60585993
18,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-02.log,409896876,127,74083056,63201232
19,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-30.log,324151612,127,76615491,65592999
20,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-07.log,441950547,127,80068230,68440749
21,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-08.log,423204337,127,83374514,71111739
22,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-13.log,423620342,127,86684048,73820147
23,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-32.log,50871010,127,87081478,74192578
24,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-18.log,458333837,127,90662212,77156397
25,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-21.log,438525916,127,94088196,79965402
26,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-26.log,421852834,127,97383922,82661302
27,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-15.log,348380332,127,100105644,84806117
28,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-29.log,400564914,127,103235058,87346793
29,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-22.log,438617352,127,106661757,90158102
30,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-28.log,426304072,127,109992258,92878451
31,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-03.log,444897046,127,113468017,95736769
\end{filecontents*}
\begin{document}
\pgfkeys{/pgf/number format/.cd,1000 sep={\,}}
\begin{tikzpicture}
\begin{axis}[
ymajorgrids,
xlabel=MB ingested into system,
ylabel=MB stored in System
]
\addplot table [x=iteration, y=iteration, col sep=comma] {hdfs_logs.csv};
\end{axis}
\end{tikzpicture}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
但是我得到了错误:Illegal parameter number in definition of \pgfplotstable@loc@TMPa
我花了很长时间试图找出错误,但我找不到。有谁能发现我的错误?我也对这个错误感到很困惑,因为 csv 是有效的。
答案1
这些#
字符在 TeX 中很特殊,它们表示参数。使绘图正常工作的一种方法是从表中删除它们(因为这里不使用它们)。也许更优雅的可能性是使用键text special chars
。
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{filecontents}
\begin{filecontents*}{hdfs_logs.csv}
iteration,GD/CD,data,data_size,basis/chunk size,#basis/chunks,dedup #basis/chunks
0,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-25.log,413141404,127,3227668,2653695
1,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-05.log,377418163,127,6176248,5057417
2,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-14.log,379043438,127,9137525,7471653
3,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-06.log,407971604,127,12324804,10078357
4,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-31.log,325649983,127,14868945,12497466
5,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-01.log,697979040,127,20321907,17709829
6,gd,files/hdfs_logs/hadoop-hdfs-namenode-mesos-01.log,1125510545,127,29114959,24421362
7,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-16.log,311133116,127,31545687,26325360
8,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-27.log,420281792,127,34829139,29016087
9,gd,files/hdfs_logs/hadoop-hdfs-secondarynamenode-mesos-01.log,88368089,127,35519515,29383729
10,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-19.log,449586557,127,39031910,32289842
11,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-17.log,447704440,127,42529601,35180232
12,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-10.log,397436049,127,45634571,37698415
13,gd,files/hdfs_logs/HDFS.log,1577982906,127,57962563,50020476
14,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-11.log,367908511,127,60836849,52344531
15,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-20.log,429342641,127,64191089,55098658
16,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-23.log,437840376,127,67611717,57912426
17,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-09.log,418434394,127,70880736,60585993
18,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-02.log,409896876,127,74083056,63201232
19,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-30.log,324151612,127,76615491,65592999
20,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-07.log,441950547,127,80068230,68440749
21,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-08.log,423204337,127,83374514,71111739
22,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-13.log,423620342,127,86684048,73820147
23,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-32.log,50871010,127,87081478,74192578
24,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-18.log,458333837,127,90662212,77156397
25,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-21.log,438525916,127,94088196,79965402
26,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-26.log,421852834,127,97383922,82661302
27,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-15.log,348380332,127,100105644,84806117
28,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-29.log,400564914,127,103235058,87346793
29,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-22.log,438617352,127,106661757,90158102
30,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-28.log,426304072,127,109992258,92878451
31,gd,files/hdfs_logs/hadoop-hdfs-datanode-mesos-03.log,444897046,127,113468017,95736769
\end{filecontents*}
\begin{document}
\pgfkeys{/pgf/number format/.cd,1000 sep={\,}}
\begin{tikzpicture}
\begin{axis}[
ymajorgrids,
xlabel=MB ingested into system,
ylabel=MB stored in System
]
\addplot table [x=iteration, y=iteration, col sep=comma,text special chars={\#}] {hdfs_logs.csv};
\end{axis}
\end{tikzpicture}
\end{document}
或者您也可以使用ignore chars
,请参阅pgfplotstable
第 7 页的手册 v1.16:
然后你需要更换
\addplot table [x=iteration, y=iteration, col sep=comma,text special chars={\#}] {hdfs_logs.csv};
经过
\addplot table [x=iteration, y=iteration, col sep=comma, ignore chars={\#}] {hdfs_logs.csv};
在当前的例子中,这没有任何区别,因为没有使用相应的列。