【发布时间】:2015-01-16 19:40:35
【问题描述】:
当我编写一个 C++ 程序时,包括通过管道使用 GNU-Plot,该图被渲染,但是缺少所有 x11 交互性,例如,我采用了以下基于 HERE 的代码
int main()
{
FILE *pipe = popen("gnuplot -persist","w");
fprintf(pipe, "set samples 40\n");
fprintf(pipe, "set isosamples 40\n");
fprintf(pipe, "set hidden3d\n");
fprintf(pipe, "set xrange [-8.000:8.000]\n");
fprintf(pipe, "set yrange [-8.000:8.000]\n");
fprintf(pipe, "set zrange [-2.000:2.000]\n");
fprintf(pipe, "set terminal x11\n");
fprintf(pipe, "set title 'We are plotting from C'\n");
fprintf(pipe, "set xlabel 'Label X'\n");
fprintf(pipe, "set ylabel 'Label Y'\n");
fprintf(pipe, "splot cos(x)+cos(y)\n");
pclose(pipe);
return 0;
}
但是,如果我打开命令行,运行 gnuplot,然后手动输入所有命令,则存在完整的交互性,即缩放、旋转等...
有人知道当通过 C++ 程序调用 GNU-Plot 时如何让交互性正常工作吗?
【问题讨论】: