Gnuplot:跳过最后一行/不完整的数据文件
Gnuplot: skip last/incomplete line of data file
我有一个c++程序,使用嵌入式lua脚本将数据点从程序写入文件,并且我希望能够同时运行gnuplot实例来绘制数据点。
io.output(pfile);
io.write(t, "t", p_x, "t", p_y, "t", p_z, "n");
gnuplot文件如下:
set termopt enhanced
set title "Linear Momentum Vector"
set xlabel "t (s)"
set ylabel "p (N-s)"
plot "data/plot_p.dat" using 1:2 title "p_x(t)" with lines,
"data/plot_p.dat" using 1:3 title "p_y(t)" with lines,
"data/plot_p.dat" using 1:4 title "p_z(t)" with lines
set style line 81 lt 0 lc rgb "#808080" lw 0.5
set grid xtics ytics mxtics mytics
set grid back ls 81
pause 0.25
reread
上面的gnuplot脚本适用于完整的数据文件,但我希望它在程序运行时实时绘图。当lua脚本写入文件时,gnuplot脚本有时会用不完整的最后一行捕获文件。这会产生一个错误:
"liveplot_p.gnu", line 9: x range is invalid
我如何得到gnuplot脚本的最后一行或无效的数据集?
谢谢!
我用lua解决了这个问题。在io.write(…)调用之后调用io.flush()函数似乎每次都将整行写入文件。
当然,这并不是告诉gnuplot跳过或忽略最后一行,而是确保最后一行是完整的
相关文章:
- 从 bmp 文件数据创建 MFC CBitmap
- 从存储为 Windows 资源 (c++) 的 png 中获取 png 文件数据
- 如何在 Gnuplot 中分别绘制 2 个文件数据?我有一个文件"sin.txt",另一个文件"cos.txt",我想将它们分别绘制在一个图表上
- 获取文件数据预处理器宏
- 错误的值是使用c++从CSV文件数据写入数组
- 无法在可视C++中检索资源文件数据
- 将文本文件数据读入字符数组时提取运算符的歧义
- 如何使用curl c ++源代码发布wav文件数据,如何使用c ++使用--data-binary?
- 如何在C++中读取 UTF-8 文件数据
- 如何在结构中存储二进制文件数据
- 无法从 turbo c 程序中的文件检索文件数据
- 使用 fstream 将文件数据从当前位置保存到文件末尾
- 通过Google Protobuf发送二进制文件数据
- 在通过套接字向服务器发送文件数据时,我得到了一些垃圾值?为什么
- 如何使用dlang读取二进制文件数据
- 程序使用FSCANF读取文件数据后崩溃
- 检测二进制文件数据的端性
- C++ 从文本文件数据类型读取为结构,并将数据存储在列表的向量中
- 将 FFT 应用于 WAV 文件数据的 C++
- C++内存映射的文件数据预取