PGFPlots 和 .CSV - 仅读取前 301 行,或者“跳过最后 n=?”?

PGFPlots 和 .CSV - 仅读取前 301 行,或者“跳过最后 n=?”?

好吧,我正在处理一个输出 CSV 文件的测试设置。它有数据列,最长的数据是每次我都需要的 301 行数据,除非它失败,否则它会提前退出。但是,然后有一个空白行,然后又是标题,上面是整个列的平均值。

因此,编写该程序的人将 CSV 的页脚设计成一个摘要区域。起初,我使用的是 gnuplot,它读取文件没有问题:

gnuplot example code snippet: 
plot 'temp4.csv' every ::1::301 using 3 with line lc rgb "blue", \
'temp4.csv' every ::1::301 using 4 with line lc rgb "orange", \
'temp4.csv' every ::1::301 using 5 with line lc rgb "green", \
'temp4.csv' every ::1::301 using 6 with line lc rgb "brown", \
-12 lt rgb "red"
set title "Aux Channel"
set yrange [*:-17]
plot 'temp4.csv' every ::1::301 using 7 with line lc rgb "blue", \
'temp4.csv' every ::1::301 using 8 with line lc rgb "orange", \
'temp4.csv' every ::1::301 using 9 with line lc rgb "green", \
'temp4.csv' every ::1::301 using 10 with line lc rgb "brown", \

因此,他们的跳行技术很花哨,可以被滥用。而且一旦到达页脚部分,它仍然会阻塞少于 301 行的失败数据集。

现在我转向乳胶,因为我能够制作的 PDF 看起来很棒,而且我想自动生成此报告,CSV 如下所示:

Iteration,Sample,MSE ChA,MSE ChB,MSE ChC,MSE ChD,MSE_remote ChA,MSE_remote ChB,MSE_remote ChC,MSE_remote ChD,
1,0,-22.198,-21.981,-22.341,-21.366,-21.573,-21.573,-21.525,-20.588,
1,1,-22.468,-21.815,-22.38,-21.564,-21.577,-21.561,-21.562,-20.701,
1,2,-21.929,-22.087,-22.409,-21.741,-21.588,-21.561,-21.553,-20.6,
1,3,-22.297,-22.347,-22.234,-21.805,-21.549,-21.55,-21.548,-20.592,
1,4,-22.417,-22.183,-22.352,-21.764,-21.568,-21.552,-21.567,-20.587,
1,5,-22.286,-22.123,-22.363,-21.638,-21.564,-21.66,-21.576,-20.611,
2,0,-21.219,-15.412,-22.314,-21.956,-19.949,-21.554,-21.57,-20.583,
2,1,-20.814,-21.962,-22.341,-22.284,-20.602,-21.604,-21.564,-19.845,
2,2,-21.133,-22.157,-22.114,-21.865,-20.58,-21.555,-21.545,-19.773,
2,3,-20.719,-19.621,-22.338,-22.345,-20.488,-21.558,-21.546,-20.534,
2,4,-20.831,-21.867,-22.511,-21.825,-20.636,-21.56,-21.565,-20.586,
2,5,-20.667,-21.865,-22.332,-22.168,-20.585,-21.635,-21.554,-20.338,
3,0,-22.095,-21.782,-22.424,-21.875,-20.828,-21.584,-21.73,-20.585,
3,1,-22.196,-21.782,-22.393,-22.187,-21.563,-22.452,-22.059,-20.616,
3,2,-21.314,-21.821,-22.354,-21.67,-21.552,-22.63,-21.533,-20.622,
3,3,-21.756,-22.059,-22.334,-21.797,-21.077,-22.375,-21.618,-20.65,
3,4,-21.803,-22,-22.31,-21.846,-20.795,-22.633,-22.645,-20.588,
3,5,-21.929,-18.391,-22.369,-21.983,-21.529,-22.555,-22.634,-20.592,
4,0,-21.213,-21.889,-22.382,-21.59,-21.565,-22.634,-22.661,-20.667,
4,1,-20.721,-21.466,-22.352,-21.821,-21.798,-22.549,-22.664,-20.716,
4,2,-20.969,-21.992,-21.973,-21.441,-21.562,-22.646,-22.651,-20.636,
4,3,-21.24,-21.887,-22.62,-21.312,-21.543,-22.644,-22.636,-20.598,
4,4,-21.211,-21.752,-22.358,-21.463,-21.87,-22.63,-22.643,-20.594,
4,5,-20.816,-21.811,-22.426,-21.703,-21.72,-22.645,-22.656,-20.634,
5,0,-21.287,-21.488,-22.398,-21.912,-21.559,-22.643,-22.576,-21.569,
5,1,-20.923,-21.524,-21.873,-21.042,-22.64,-22.701,-22.635,-21.543,
5,2,-21.388,-21.9,-22.271,-21.809,-21.837,-22.646,-22.32,-21.543,
5,3,-20.869,-21.846,-22.155,-21.398,-21.557,-22.643,-22.652,-21.514,
5,4,-20.938,-21.66,-22.395,-21.417,-22.63,-22.649,-22.636,-21.551,
5,5,-21.271,-21.867,-22.533,-21.405,-22.633,-22.657,-22.651,-21.563,
6,0,-22.198,-21.337,-21.844,-21.737,-19.804,-21.555,-21.564,-19.793,
6,1,-22.278,-22.382,-22.4,-21.821,-20.584,-22.617,-21.555,-19.729,
6,2,-22.371,-21.386,-22.369,-21.735,-20.587,-21.593,-21.101,-19.707,
6,3,-22.226,-22.262,-22.413,-21.944,-20.594,-21.578,-20.646,-19.726,
6,4,-21.832,-22.378,-22.464,-21.624,-20.593,-21.582,-21.538,-19.738,
6,5,-21.741,-22.356,-22.354,-21.445,-20.592,-21.629,-21.303,-19.74,
7,0,-21.881,-22.011,-22.317,-21.852,-22.606,-21.555,-21.571,-20.657,
7,1,-21.877,-21.65,-22.358,-21.66,-21.565,-21.609,-21.587,-20.587,
7,2,-22.127,-21.715,-22.502,-21.384,-22.136,-21.588,-21.571,-20.58,
7,3,-22.239,-22.125,-22.286,-21.256,-21.678,-21.565,-21.597,-20.589,
7,4,-21.819,-21.937,-22.535,-21.316,-22.242,-21.595,-21.589,-20.594,
7,5,-21.813,-21.946,-22.522,-21.337,-22.383,-21.597,-21.586,-20.6,
8,0,-20.984,-21.892,-22.389,-21.53,-21.55,-22.629,-21.574,-21.502,
8,1,-21.31,-21.803,-21.778,-21.506,-21.539,-22.431,-21.673,-21.57,
8,2,-21.221,-21.827,-22.267,-21.84,-20.65,-21.559,-21.753,-21.567,
8,3,-21.353,-21.79,-21.811,-21.715,-21.254,-21.83,-21.544,-21.568,
8,4,-21.141,-21.867,-22.262,-21.614,-20.724,-22.626,-22.066,-21.561,
8,5,-21.421,-21.75,-22.129,-21.889,-21.434,-21.704,-21.877,-21.578,
9,0,-21.967,-22.104,-22.17,-21.848,-21.484,-22.431,-21.553,-20.603,
9,1,-22.367,-21.825,-22.314,-21.854,-20.919,-21.865,-21.565,-20.64,
9,2,-21.795,-21.461,-22.198,-21.294,-21.565,-21.6,-21.551,-20.588,
9,3,-22.435,-22.312,-22.172,-21.921,-21.563,-21.645,-21.597,-20.623,
9,4,-22.245,-21.916,-22.187,-21.84,-21.5,-22.552,-21.553,-20.68,
9,5,-22.343,-21.668,-22.336,-21.854,-21.389,-22.466,-21.564,-20.667,
10,0,-21.227,-21.846,-22.682,-21.333,-21.577,-22.641,-21.566,-21.528,
10,1,-21.312,-22.349,-22.328,-21.776,-21.568,-22.622,-21.562,-21.557,
10,2,-20.832,-21.689,-22.297,-21.244,-21.512,-22.613,-21.818,-21.519,
10,3,-21.252,-21.998,-22.211,-21.166,-21.564,-22.615,-22.469,-21.551,
10,4,-21.246,-21.852,-22.468,-21.392,-21.562,-21.653,-21.65,-20.635,
10,5,-20.31,-21.873,-22.157,-21.273,-21.575,-22.38,-22.369,-21.552,
11,0,-22.148,-22.002,-21.985,-21.731,-21.169,-21.564,-21.49,-18.936,
11,1,-22.387,-22.404,-22.358,-21.638,-21.429,-21.571,-21.521,-18.933,
11,2,-22.08,-22.085,-22.291,-21.654,-20.991,-21.555,-21.501,-19.685,
11,3,-21.875,-22.332,-22.343,-22.258,-20.842,-21.56,-20.728,-18.96,
11,4,-22.301,-21.998,-21.873,-21.626,-20.593,-21.603,-21.536,-19.671,
11,5,-22.082,-22.176,-22.019,-21.624,-20.592,-21.576,-21.548,-19.025,
12,0,-22.354,-21.836,-22.363,-21.807,-20.556,-21.562,-21.644,-18.947,
12,1,-22.226,-19.106,-22.347,-21.636,-20.663,-21.558,-21.65,-18.909,
12,2,-21.76,-21.844,-22.446,-21.821,-20.62,-21.609,-21.724,-19.716,
12,3,-21.793,-21.815,-22.356,-21.954,-21.229,-21.549,-21.602,-19.13,
12,4,-21.856,-21.562,-22.513,-21.721,-20.759,-21.583,-21.743,-18.939,
12,5,-21.797,-21.254,-22.349,-22.136,-21.003,-21.568,-22.106,-19.653,
13,0,-21.431,-17.446,-22.221,-21.825,-20.558,-21.403,-21.563,-21.558,
13,1,-21.256,-17.741,-22.378,-21.793,-20.595,-20.606,-21.572,-21.573,
13,2,-21.296,-21.774,-22.459,-21.819,-20.043,-21.523,-21.575,-21.582,
13,3,-21.374,-21.455,-22.358,-22.219,-20.546,-21.504,-21.514,-21.562,
13,4,-21.494,-18.749,-22.444,-21.83,-20.599,-21.208,-21.535,-21.546,
13,5,-21.327,-21.275,-22.336,-21.842,-20.483,-20.595,-21.54,-21.59,
14,0,-21.666,-21.834,-22.349,-21.554,-21.22,-21.655,-21.542,-21.56,
14,1,-21.741,-22.108,-22.367,-21.756,-20.603,-21.748,-21.582,-21.915,
14,2,-21.392,-21.707,-22.213,-21.474,-21.527,-22.646,-21.555,-21.644,
14,3,-21.124,-21.417,-22.008,-21.869,-20.595,-22.049,-21.532,-21.552,
14,4,-21.323,-21.805,-22.393,-21.277,-21.525,-21.59,-21.555,-21.571,
14,5,-21.29,-21.795,-21.807,-21.954,-21.137,-21.882,-21.559,-21.589,
15,0,-21.402,-22.193,-22.341,-22.097,-20.59,-21.686,-21.58,-20.593,
15,1,-21.118,-21.844,-22.015,-21.842,-20.59,-21.794,-21.597,-20.576,
15,2,-21.496,-21.795,-21.819,-21.919,-20.59,-22.554,-21.56,-20.594,
15,3,-21.256,-22.085,-22.338,-21.844,-20.585,-22.621,-21.788,-20.604,
15,4,-21.298,-21.858,-22.349,-21.805,-20.625,-21.584,-21.566,-20.667,
15,5,-21.306,-22.243,-21.9,-22.176,-20.637,-21.586,-21.571,-20.605,
16,0,-21.318,-21.827,-21.83,-21.904,-20.567,-21.54,-20.903,-19.635,
16,1,-21.506,-22.265,-21.795,-21.898,-20.284,-21.551,-21.377,-19.696,
16,2,-21.296,-21.927,-21.756,-20.882,-20.572,-21.555,-21.429,-19.741,
16,3,-21.37,-22.354,-21.709,-21.269,-20.618,-21.547,-21.56,-19.724,
16,4,-21.419,-22.384,-21.919,-21.198,-20.598,-21.568,-21.558,-19.718,
16,5,-20.864,-22.293,-21.827,-20.934,-20.562,-21.573,-20.782,-19.721,
17,0,-20.845,-21.636,-21.933,-21.809,-20.593,-21.382,-21.565,-21.093,
17,1,-21.204,-21.719,-21.821,-21.811,-20.603,-20.619,-21.545,-21.508,
17,2,-21.016,-21.803,-22.295,-21.996,-20.789,-20.589,-21.544,-20.631,
17,3,-20.906,-21.844,-22.391,-21.815,-20.615,-20.667,-21.569,-20.767,
17,4,-21.116,-22.04,-22.376,-21.608,-20.666,-21.525,-21.584,-21.559,
17,5,-21.012,-21.394,-21.652,-21.701,-20.606,-20.594,-21.559,-20.569,
18,0,-22.256,-21.836,-22.323,-20.397,-21.515,-21.566,-21.557,-20.587,
18,1,-21.626,-22.334,-22.301,-20.072,-20.847,-21.566,-21.549,-20.533,
18,2,-22.367,-22.271,-22.31,-20.378,-21.53,-21.533,-21.553,-20.65,
18,3,-22.299,-22.008,-22.249,-20.466,-21.511,-21.6,-21.541,-20.646,
18,4,-22.129,-21.768,-21.985,-20.097,-21.52,-21.579,-21.557,-20.632,
18,5,-22.093,-22.428,-22.367,-20.286,-21.566,-21.595,-21.561,-20.597,
19,0,-22.004,-19.488,-22.426,-21.937,-21.627,-21.574,-21.536,-22.244,
19,1,-21.433,-21.935,-22.349,-21.83,-21.571,-21.962,-21.471,-21.592,
19,2,-21.542,-21.817,-22.393,-21.77,-21.569,-21.675,-21.561,-21.691,
19,3,-22.354,-21.809,-22.42,-21.782,-21.522,-21.559,-21.596,-21.886,
19,4,-21.62,-21.933,-22.393,-21.815,-22.625,-21.848,-21.572,-22.171,
19,5,-22.352,-21.766,-22.363,-21.921,-21.694,-21.557,-21.551,-21.566,
20,0,-20.803,-22.204,-22.332,-22.036,-19.746,-20.648,-21.574,-20.581,
20,1,-20.88,-22.008,-22.325,-21.842,-19.731,-20.603,-21.582,-20.078,
20,2,-21.154,-22.131,-22.404,-21.693,-19.727,-20.682,-21.566,-20.615,
20,3,-20.975,-22.354,-22.506,-21.879,-19.75,-20.594,-21.562,-20.586,
20,4,-21.041,-21.287,-22.363,-22.106,-19.753,-20.669,-21.565,-20.57,
20,5,-21.314,-22.049,-21.969,-22.011,-19.729,-20.765,-21.558,-20.582,
21,0,-21.357,-21.904,-22.437,-21.296,-20.964,-20.752,-20.592,-19.712,
21,1,-20.984,-22.312,-22.761,-21.819,-20.728,-20.639,-20.544,-18.96,
21,2,-21.514,-21.906,-22.374,-21.366,-20.607,-20.584,-20.589,-19.685,
21,3,-21.097,-22.108,-22.082,-21.606,-21.452,-20.8,-21.427,-19.722,
21,4,-21.12,-22.256,-22.245,-21.122,-21.545,-20.708,-21.503,-19.78,
21,5,-21.231,-21.784,-22.493,-21.809,-20.719,-20.707,-21.529,-19.719,
22,0,-21.66,-21.819,-22.365,-21.784,-20.226,-21.557,-20.542,-19.677,
22,1,-21.037,-22.114,-22.349,-21.865,-20.443,-21.54,-20.591,-19.678,
22,2,-21.219,-22.387,-22.391,-21.797,-19.851,-21.294,-20.587,-19.716,
22,3,-21.179,-22.284,-22.376,-21.618,-20.294,-21.548,-20.598,-19.548,
22,4,-21.217,-21.801,-22.406,-22.061,-20.429,-21.552,-21.079,-19.718,
22,5,-21.124,-21.856,-22.544,-21.788,-20.563,-21.553,-20.598,-18.919,
23,0,-21.325,-21.842,-22.711,-21.246,-21.46,-21.563,-21.561,-20.604,
23,1,-21.439,-22.347,-21.925,-21.392,-21.561,-21.602,-21.559,-20.624,
23,2,-20.767,-22.063,-22.347,-21.304,-21.601,-21.574,-21.547,-20.592,
23,3,-20.656,-22.239,-22.138,-21.31,-21.561,-21.565,-21.575,-20.598,
23,4,-20.467,-21.958,-22.187,-21.504,-21.557,-21.556,-21.557,-20.588,
23,5,-20.96,-22.142,-22.389,-21.337,-21.391,-21.608,-21.558,-20.778,
24,0,-21.112,-22.155,-22.365,-21.349,-21.533,-22.594,-22.233,-20.584,
24,1,-21.097,-22.053,-22.252,-21.842,-21.505,-22.629,-22.64,-20.573,
24,2,-21.355,-22.183,-22.363,-21.353,-21.56,-22.646,-22.612,-20.549,
24,3,-20.847,-22.148,-22.063,-21.005,-20.982,-22.476,-22.631,-20.568,
24,4,-21.386,-21.941,-22.343,-21.873,-20.966,-22.624,-22.437,-20.547,
24,5,-21.325,-21.817,-22.336,-21.302,-21.455,-21.563,-22.554,-19.867,
25,0,-21.384,-21.944,-22.055,-21.846,-21.528,-21.643,-21.469,-21.559,
25,1,-21.322,-22.36,-22.314,-21.715,-21.581,-21.561,-21.57,-21.564,
25,2,-20.967,-22.019,-22.358,-21.854,-21.624,-21.58,-21.58,-21.557,
25,3,-21.304,-21.793,-22.206,-21.803,-21.573,-21.581,-21.561,-21.405,
25,4,-21.554,-21.975,-22.26,-21.782,-21.565,-21.553,-21.679,-20.95,
25,5,-21.078,-21.54,-22.36,-21.827,-21.67,-21.565,-21.555,-21.554,
26,0,-20.763,-21.817,-22.273,-22.002,-21.468,-21.561,-20.705,-20.525,
26,1,-21.033,-22.002,-22.33,-21.992,-21.555,-21.514,-21.078,-19.914,
26,2,-20.692,-22.213,-22.36,-21.723,-21.58,-21.554,-21.513,-20.42,
26,3,-20.667,-21.776,-22.23,-21.799,-21.556,-21.56,-21.526,-19.787,
26,4,-20.854,-22.343,-22.517,-21.803,-21.643,-21.556,-21.563,-19.97,
26,5,-21.137,-22.354,-22.352,-21.892,-21.541,-21.54,-21.559,-19.833,
27,0,-22.249,-22.215,-22.422,-22.334,-21.538,-21.558,-21.569,-21.573,
27,1,-22.363,-22.341,-22.376,-21.877,-21.569,-21.446,-21.109,-21.563,
27,2,-22.271,-22.153,-22.369,-21.803,-21.549,-21.546,-21.566,-21.543,
27,3,-22.374,-22.356,-22.428,-21.894,-21.558,-21.591,-21.566,-21.553,
27,4,-21.825,-21.996,-22.4,-21.54,-21.256,-21.499,-21.517,-21.573,
27,5,-22.345,-22.185,-22.398,-21.848,-21.541,-21.585,-21.001,-21.72,
28,0,-22.267,-21.805,-22.374,-21.919,-21.56,-21.557,-21.55,-21.539,
28,1,-22.295,-22.021,-22.363,-21.815,-21.547,-21.555,-21.542,-21.032,
28,2,-21.821,-21.867,-22.278,-21.713,-21.172,-21.569,-21.574,-21.556,
28,3,-22.334,-22.065,-22.354,-21.815,-21.25,-21.536,-21.562,-20.839,
28,4,-22.356,-21.66,-22.119,-21.96,-21.539,-21.556,-21.533,-20.686,
28,5,-22.288,-21.799,-22.099,-21.848,-21.54,-21.689,-20.681,-21.557,
29,0,-21.2,-21.793,-22.129,-21.322,-21.558,-21.495,-21.551,-20.586,
29,1,-21.335,-21.715,-22.374,-21.304,-21.637,-21.556,-21.557,-20.581,
29,2,-20.699,-21.916,-22.468,-21.2,-22.581,-21.617,-21.541,-20.12,
29,3,-21.374,-21.987,-22.378,-21.122,-21.695,-21.652,-21.549,-20.591,
29,4,-21.033,-21.784,-22.36,-21.215,-21.567,-21.626,-21.553,-20.584,
29,5,-21.078,-21.79,-22.286,-21.32,-21.6,-22.555,-21.553,-20.571,
30,0,-21.331,-21.941,-22.33,-21.967,-20.725,-21.554,-21.546,-21.525,
30,1,-21.158,-21.715,-22.56,-21.91,-20.561,-21.574,-21.538,-21.262,
30,2,-21.012,-22.053,-22.144,-21.758,-20.707,-21.557,-21.331,-20.881,
30,3,-21.281,-21.842,-22.464,-21.887,-20.612,-21.556,-21.556,-21.465,
30,4,-21.421,-21.875,-22.053,-21.877,-20.606,-21.55,-21.518,-21.465,
30,5,-20.941,-21.463,-22.36,-22.208,-20.661,-21.522,-21.559,-21.527,
31,0,-21.148,-21.9,-22.213,-21.514,-21.544,-21.49,-21.568,-19.821,
31,1,-21.024,-21.948,-21.939,-21.612,-20.637,-21.177,-21.547,-20.504,
31,2,-21.318,-22.065,-22.356,-21.852,-21.532,-21.51,-21.576,-20.591,
31,3,-21.248,-22.306,-21.925,-21.476,-21.516,-20.607,-21.553,-20.293,
31,4,-21.325,-22.082,-22.291,-21.349,-20.442,-21.554,-21.564,-20.516,
31,5,-21.003,-22.389,-22.078,-21.821,-20.623,-20.895,-21.546,-20.581,
32,0,-21.689,-22.063,-22.371,-21.863,-21.551,-22.635,-20.585,-20.591,
32,1,-21.139,-22.295,-22.04,-21.827,-20.995,-21.579,-21.561,-20.569,
32,2,-21.227,-16.514,-21.854,-21.801,-21.566,-21.924,-21.152,-20.596,
32,3,-21.154,-22.234,-22.123,-21.838,-21.564,-22.62,-20.655,-20.57,
32,4,-21.748,-22.089,-22.428,-21.793,-21.534,-21.825,-20.639,-20.59,
32,5,-21.423,-21.844,-22.352,-21.992,-21.527,-22.609,-21.315,-20.621,
33,0,-21.38,-21.652,-21.927,-21.958,-20.562,-21.574,-22.638,-20.577,
33,1,-21.4,-21.735,-22.389,-21.811,-20.592,-21.576,-21.825,-20.595,
33,2,-21.345,-18.344,-22.442,-21.956,-20.552,-21.456,-21.672,-20.589,
33,3,-21.114,-21.459,-21.844,-21.975,-20.614,-21.566,-22.607,-20.581,
33,4,-21.244,-21.852,-22.262,-21.883,-20.6,-21.555,-22.146,-20.32,
33,5,-21.287,-21.602,-22.221,-21.881,-20.287,-21.587,-22.642,-20.253,
34,0,-21.223,-21.813,-22.446,-22.112,-21.583,-22.588,-22.677,-21.532,
34,1,-20.967,-21.711,-22.347,-22.023,-21.559,-22.645,-22.66,-21.635,
34,2,-21.3,-21.49,-22.191,-21.827,-21.546,-22.672,-22.637,-21.565,
34,3,-21.608,-21.914,-22.347,-22.142,-21.155,-22.648,-22.601,-21.557,
34,4,-21.221,-21.705,-22.495,-22.07,-21.568,-22.635,-22.635,-21.563,
34,5,-21.691,-21.776,-22.78,-21.819,-21.557,-22.594,-22.13,-21.564,
35,0,-22.202,-22.356,-22.424,-21.79,-20.657,-21.561,-21.427,-19.727,
35,1,-22.308,-22.247,-22.413,-21.948,-20.608,-21.57,-21.565,-19.728,
35,2,-22.228,-21.842,-22.365,-21.797,-20.581,-20.85,-21.458,-19.726,
35,3,-21.889,-22.363,-22.334,-21.717,-20.594,-21.476,-21.548,-19.718,
35,4,-22.03,-22.358,-22.363,-21.374,-20.831,-21.512,-21.567,-19.725,
35,5,-22.091,-22.019,-22.371,-21.941,-20.618,-21.499,-21.545,-19.714,
36,0,-22.18,-19.09,-22.198,-21.727,-20.582,-21.669,-21.556,-20.588,
36,1,-22.393,-19.955,-22.398,-21.809,-20.604,-21.589,-21.572,-20.039,
36,2,-21.823,-21.682,-22.448,-22.206,-20.589,-21.58,-21.559,-20.549,
36,3,-22.011,-19.54,-22.395,-21.921,-20.446,-21.553,-21.549,-19.824,
36,4,-21.83,-15.43,-21.969,-21.47,-19.661,-21.543,-21.56,-20.593,
36,5,-22.328,-22.119,-22.072,-21.137,-19.716,-21.549,-21.586,-20.593,
37,0,-22.433,-21.821,-21.91,-22.2,-20.597,-21.594,-21.552,-19.764,
37,1,-22.398,-22.219,-21.944,-21.819,-20.592,-21.716,-21.583,-19.961,
37,2,-22.356,-21.817,-21.994,-22.384,-20.589,-21.576,-21.59,-19.862,
37,3,-22.365,-20.818,-21.725,-22.03,-20.568,-21.579,-21.571,-19.72,
37,4,-22.341,-21.929,-21.825,-21.854,-20.587,-21.567,-21.544,-19.788,
37,5,-22.217,-21.858,-22.249,-22.271,-20.16,-21.554,-21.589,-19.835,
38,0,-22.367,-21.78,-22.202,-21.739,-20.591,-21.552,-21.607,-20.559,
38,1,-22.356,-22.174,-22.319,-22.165,-20.592,-21.372,-21.551,-20.613,
38,2,-22.136,-21.39,-22.382,-21.805,-20.893,-21.569,-21.549,-20.604,
38,3,-21.9,-21.604,-22.119,-21.86,-20.897,-21.345,-21.567,-20.608,
38,4,-21.811,-21.799,-22.114,-21.455,-20.598,-21.553,-21.558,-20.569,
38,5,-21.834,-21.809,-22.471,-21.937,-20.635,-21.553,-21.672,-20.602,
39,0,-20.995,-22.282,-22.049,-21.823,-22.633,-22.647,-22.631,-20.64,
39,1,-21.12,-22.258,-22.325,-21.258,-21.565,-22.634,-22.657,-20.894,
39,2,-21.179,-21.838,-22.384,-21.994,-21.95,-22.576,-22.62,-20.644,
39,3,-21.258,-22.08,-22.363,-21.697,-22.64,-22.627,-21.938,-20.57,
39,4,-21.339,-21.827,-22.265,-21.48,-22.641,-21.702,-22.636,-21.556,
39,5,-21.347,-21.813,-22.021,-21.701,-21.557,-22.644,-22.638,-20.748,
40,0,-21.187,-22.153,-22.352,-21.819,-21.639,-20.589,-21.568,-19.72,
40,1,-21.496,-22.308,-22.275,-21.415,-21.163,-21.564,-21.582,-19.721,
40,2,-21.183,-21.854,-22.297,-21.805,-21.583,-21.557,-21.548,-19.734,
40,3,-21.54,-22.319,-22.258,-21.616,-21.558,-20.81,-21.601,-19.801,
40,4,-21.53,-22.317,-22.404,-21.574,-21.56,-21.015,-21.557,-19.834,
40,5,-21.37,-22.243,-22.44,-21.039,-21.571,-21.52,-21.557,-19.711,
41,0,-21.343,-22.044,-22.063,-21.786,-21.55,-22.628,-21.786,-21.558,
41,1,-21.737,-21.983,-22.142,-21.832,-21.55,-22.632,-21.605,-21.584,
41,2,-20.947,-22.363,-22.343,-21.606,-21.564,-22.616,-21.73,-21.553,
41,3,-21.135,-22.08,-22.343,-21.803,-21.558,-22.642,-21.714,-21.553,
41,4,-21.512,-21.772,-22.025,-21.803,-21.496,-22.636,-22.189,-21.559,
41,5,-21.127,-22.314,-22.308,-21.846,-20.813,-22.647,-21.716,-21.588,
42,0,-21.929,-19.589,-22.172,-21.823,-21.543,-21.589,-21.556,-20.309,
42,1,-22.015,-21.889,-22.354,-21.827,-21.545,-21.56,-21.569,-19.748,
42,2,-22.183,-21.632,-21.817,-21.506,-21.341,-21.545,-21.556,-19.725,
42,3,-22.347,-22.413,-22.308,-21.325,-20.784,-21.555,-21.567,-19.707,
42,4,-22.354,-22.125,-22.108,-21.809,-20.921,-21.526,-21.568,-19.723,
42,5,-22.091,-22.347,-22.448,-21.846,-21.536,-21.542,-21.547,-19.495,
43,0,-21.378,-21.707,-22.382,-21.846,-20.687,-21.555,-20.808,-20.194,
43,1,-21.162,-21.788,-22.338,-21.844,-20.631,-21.465,-21.534,-20.563,
43,2,-21.127,-21.656,-22.354,-21.838,-20.712,-21.598,-20.698,-20.591,
43,3,-20.445,-22.328,-22.241,-21.756,-20.826,-21.562,-20.606,-20.58,
43,4,-21.343,-22.356,-22.136,-21.766,-20.638,-21.607,-20.628,-20.122,
43,5,-21.429,-21.403,-22.121,-21.809,-20.043,-21.552,-20.586,-20.581,
44,0,-22.142,-21.64,-22.104,-21.803,-20.577,-21.557,-21.232,-19.148,
44,1,-21.405,-21.766,-22.347,-21.674,-19.715,-21.592,-21.146,-19.309,
44,2,-22.341,-21.811,-22.341,-21.554,-20.552,-21.568,-20.587,-19.7,
44,3,-22.31,-21.823,-22.14,-21.834,-20.576,-21.564,-21.535,-19.709,
44,4,-22.044,-21.819,-22.446,-21.312,-20.576,-21.604,-21.49,-19.249,
44,5,-21.875,-22.236,-22.299,-21.807,-20.591,-21.615,-21.535,-18.94,
45,0,-21.025,-19.526,-22.415,-21.875,-20.591,-21.59,-21.655,-19.096,
45,1,-20.938,-21.832,-22.314,-21.813,-19.749,-21.558,-21.69,-18.936,
45,2,-20.845,-21.813,-22.321,-21.819,-20.566,-21.524,-21.595,-19.243,
45,3,-21.097,-21.937,-22.435,-21.821,-20.488,-21.552,-21.599,-19.181,
45,4,-21.225,-21.865,-22.347,-21.793,-19.911,-21.574,-21.607,-18.947,
45,5,-20.658,-21.709,-22.371,-21.902,-19.819,-21.559,-21.557,-19.733,
46,0,-21.977,-21.958,-22.428,-21.788,-20.589,-21.529,-21.473,-19.758,
46,1,-21.784,-21.838,-22.515,-21.429,-20.606,-21.541,-21.543,-20.389,
46,2,-21.925,-21.682,-22.376,-21.325,-19.947,-21.53,-21.562,-20.602,
46,3,-21.944,-21.79,-22.42,-21.566,-20.53,-21.565,-21.579,-20.585,
46,4,-22.301,-22.211,-22.323,-21.183,-20.348,-21.544,-21.669,-20.59,
46,5,-21.318,-22.034,-22.332,-20.843,-20.571,-21.602,-21.616,-20.464,
47,0,-21.065,-21.83,-22.378,-22.148,-20.579,-21.548,-21.85,-20.463,
47,1,-20.584,-21.838,-21.941,-21.634,-20.575,-21.565,-21.573,-20.581,
47,2,-20.865,-17.656,-22.376,-21.758,-20.041,-21.548,-21.56,-19.848,
47,3,-21.086,-21.343,-22.325,-21.542,-20.577,-21.539,-21.607,-20.577,
47,4,-21.063,-21.832,-22.4,-21.811,-20.598,-21.562,-22.636,-20.535,
47,5,-21.269,-21.892,-22.343,-21.819,-20.567,-21.577,-22.637,-20.581,
48,0,-22.358,-21.294,-22.172,-22.123,-21.625,-22.62,-22.074,-20.632,
48,1,-22.245,-21.628,-21.846,-21.916,-21.595,-22.65,-22.485,-20.631,
48,2,-21.908,-21.687,-22.157,-21.867,-21.914,-22.64,-22.64,-20.633,
48,3,-22.36,-21.411,-22.26,-22.116,-22.099,-22.386,-22.65,-21.245,
48,4,-22.196,-21.815,-22.273,-21.817,-21.599,-22.073,-22.642,-20.688,
48,5,-22.395,-21.788,-22.338,-21.83,-21.902,-22.649,-21.598,-20.622,
49,0,-20.877,-22.367,-22.269,-21.074,-21.576,-21.576,-22.65,-20.921,
49,1,-21.514,-22.247,-22.367,-21.461,-21.553,-21.57,-22.638,-21.005,
49,2,-20.88,-21.766,-22.282,-21.48,-21.563,-21.554,-22.642,-21.473,
49,3,-20.869,-21.858,-22.38,-21.705,-22.015,-21.697,-22.662,-20.726,
49,4,-21.484,-21.933,-22.161,-21.803,-21.609,-21.587,-22.652,-20.776,
49,5,-21.19,-22.025,-22.347,-21.719,-21.68,-21.494,-22.638,-20.612,
50,0,-20.854,-17.194,-22.034,-21.409,-20.607,-21.554,-21.573,-19.761,
50,1,-20.66,-21.801,-22.482,-21.77,-20.584,-21.479,-21.499,-20.197,
50,2,-21.082,-18.262,-22.234,-21.854,-20.51,-21.561,-21.511,-19.736,
50,3,-21.413,-21.476,-22.352,-22.019,-20.584,-20.613,-21.554,-19.743,
50,4,-21.164,-22.323,-22.312,-21.782,-20.605,-20.694,-21.564,-19.765,
50,5,-21.101,-19.237,-21.95,-21.923,-20.619,-21.56,-21.549,-20.127,
,,,,,,,,,,
Summery Results,,,,,,,,,,
,,MSE ChA,MSE ChB,MSE ChC,MSE ChD,MSE_remote ChA,MSE_remote ChB,MSE_remote ChC,MSE_remote ChD,
,Average MSE per Channel,-21.518,-21.691,-22.27,-21.697,-21.072,-21.715,-21.663,-20.534,
,Mask-Min MSE for test,-12,-12,-12,-12,-17.5,-17.5,-17.5,-17.5,
,Pass/Fail Status,Pass,Pass,Pass,Pass,Pass,Pass,Pass,Pass,

因此,如果我手动打开 CSV 并删除底部部分,下面的 MWE 代码可以正常工作:

\documentclass{report}
\usepackage[letterpaper, total={6in, 8in}]{geometry}

%Graph/Chart stuff!!
\usepackage{siunitx}
\usepackage{tikz} % To generate the plot from csv
\usepackage{pgfplots}
\pgfplotsset{compat=newest} % Allows to place the legend below plot
\usepgfplotslibrary{units} % Allows to enter the units nicely
\sisetup{
  round-mode          = places,
  round-precision     = 2,
}

\begin{document}

\subsection{Data Output - Graphed (Main Channel)}

\begin{figure}[h!]
  \begin{center}
    \begin{tikzpicture}
      \begin{axis}[
          width=\linewidth,
          grid=major,
          grid style={dashed,gray!30},
          xlabel=Iterations,
          ylabel=Decibels,
          y unit=\si{\decibel},
          legend style={at={(0.5,-0.2)},anchor=north},
          x tick label style={rotate=90,anchor=east}
        ]
        \addplot [mark=*,blue]   table[x expr=\coordindex,y=MSE ChA,col sep=comma] {mse.csv}; 
        \addplot [mark=*,orange]     table[x expr=\coordindex,y=MSE ChB,col sep=comma] {mse.csv}; 
        \addplot [mark=*,green]  table[x expr=\coordindex,y=MSE ChC,col sep=comma] {mse.csv}; 
        \addplot [mark=*,brown]  table[x expr=\coordindex,y=MSE ChD,col sep=comma] {mse.csv}; 
        \addplot[red] (0,-12) -- (300,-12);
        \legend{ChannelA - Main,ChannelB - Main,ChannelC - Main,ChannelD - Main,Pass/Fail Limit}
      \end{axis}
    \end{tikzpicture}
    \caption{Mean Square Energy (Main Channel)}
  \end{center}
\end{figure}
\clearpage

\subsection{Data Output - Graphed (Aux Channel)}
\begin{figure}[h!]
  \begin{center}
    \begin{tikzpicture}
      \begin{axis}[
          width=\linewidth,
          grid=major,
          grid style={dashed,gray!30},
          xlabel=Iterations,
          ylabel=Decibels,
          y unit=\si{\decibel},
          legend style={at={(0.5,-0.2)},anchor=north},
          x tick label style={rotate=90,anchor=east}
        ]
        \addplot [mark=*,blue]      table[x expr=\coordindex,y=MSE_remote ChA,col sep=comma] {mse.csv}; 
        \addplot [mark=*,orange]        table[x expr=\coordindex,y=MSE_remote ChB,col sep=comma] {mse.csv}; 
        \addplot [mark=*,green]     table[x expr=\coordindex,y=MSE_remote ChC,col sep=comma] {mse.csv}; 
        \addplot [mark=*,brown]     table[x expr=\coordindex,y=MSE_remote ChD,col sep=comma] {mse.csv};
        \addplot[red] (0,-17.5) -- (300,-17.5);
        \legend{ChannelA - Aux,ChannelB - Aux,ChannelC - Aux,ChannelD - Aux,Pass/Fail Limit}
      \end{axis}
    \end{tikzpicture}
    \caption{Mean Square Energy (Main Channel)}
  \end{center}
\end{figure}
\clearpage

\end{document}

我如何让 PGFPlots 只读取 301 行,并在该处显示标题和停止。我知道它试图在该空白行上进行“跳跃”,然后阻塞其下方的非数字数据。我只想让它在该处停止导入。PGFPlots 的“空行”参数之一是否可以做到这一点?我无法让它工作。=( 比如,“空行 = 停止”之类的?

另外,我能否“鱼与熊掌兼得”,同时解析小于 301 但仍包含页脚部分的文件?

错误输出:

NOTE: coordinate (1Y3.0e2],) has been dropped because of a coordinate filter. (
see also unbounded coords=jump). 
NOTE: coordinate (1Y3.01e2],) has been dropped because of a coordinate filter. 
(see also unbounded coords=jump). 

! Package PGF Math Error: Could not parse input 'MSE ChA' as a floating point n
umber, sorry. The unreadable part was near 'MSE ChA'..

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.

我在 Windows 上使用 MiKTeX Portable。有哪位大师能指点我一下吗?我确信有办法,但我是新手!我尽力在这里搜索了类似的问题,但没有找到任何适用的内容。至少我希望如此。

谢谢你!

答案1

正如我在在问题下方评论目前,在读取或处理数据表时,无法忽略中间或末尾的行(在 PGFPlots 中直接地)。

但是由于您似乎熟悉 gnuplot,因此您可以使用raw gnuplotPGFPlots 的功能提取数据。

也就是说:如果您知道 gnuplot 中“附加问题”的解决方案(如果在页脚行之前绘制的行少于 301 行会怎样?),那么您应该可以轻松地应用它。我认为这every :::0::0应该可以解决问题,但似乎“逗号行”没有被检测为空行,因此块检测失败...

(对于未来,我建议将页脚行移到顶部,并通过在行前面添加注释字符(如#或 )来“注释”它们%。这样,您将能够直接绘制数据,而无需使用 gnuplot 绕道而行。)

% used PGFPlots v1.14 and gnuplot v5.0 patchlevel 3
% (data file given in the question <https://tex.stackexchange.com/questions/343513>)
\documentclass[border=5pt]{standalone}
\usepackage{siunitx}
\usepackage{pgfplots}
    \usepgfplotslibrary{units}
    \pgfplotsset{compat=1.11}
    % create custom cycle list which is later used for the "channels" in the data table
    \pgfplotscreateplotcyclelist{my colors}{
        blue\\
        orange\\
        green\\
        brown\\
    }
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            width=\linewidth,
            grid=major,
            grid style={
                dashed,
                gray!30,
            },
            xlabel=Iterations,
            ylabel=Decibels,
            y unit=\si{\decibel},
            legend style={
                at={(0.5,-0.2)},
                anchor=north,
            },
            x tick label style={
                rotate=90,
                anchor=east,
            },
            % use/apply custom cycle list
            cycle list name=my colors,
        ]

            % use `raw gnuplot` feature to extract the first 301 lines of the data table
            \foreach \i in {3,...,6} {
                \addplot+ [
                    mark=*,
                ] gnuplot [raw gnuplot] {
                    set datafile separator ",";
                    plot "mse.csv" using \i\space every ::1::301;
%                    % this should be the solution for the bonus question
%                    % (but it seems that there is no "empty" line in the
%                    %  data table ...)
%                    plot "mse.csv" using \i\space every :::0::0;
                };
            }
            \addplot [red] (0,-12) -- (300,-12);

            \legend{
                ChannelA -- Main,
                ChannelB -- Main,
                ChannelC -- Main,
                ChannelD -- Main,
                Pass/Fail Limit,
            }

        \end{axis}
    \end{tikzpicture}
\end{document}

该图显示了上述代码的结果

相关内容