c言語で簡単な数値計算をしたデータを(pypeで)gnuplotを用いてgifアニメを作成したいと思っています.
下記サイト
https://qiita.com/k_nitadori/items/1ea13c2ae9b32ab66912
を参考にgifアニメ作成自体は成功はしたのですが,実行時に
GD Warning: one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
というエラーが(ループ回数分だけ)出ます.同じコートでも出ないときもあり,再現性がなく困っております.どなたかアドヴァイスいただけますと幸いです.
[*] 環境
[2.1] OS : Windows 10
[2.2] cygwin gcc
[*] その他
・c言語はある程度理解しているが,pypeなどは初心者
例えば,下記のようなシンプルなコードでも同じエラーが出ることがあります:
#include <stdio.h>
#define GNUPLOT_PATH "C:/PROGRA~1/gnuplot/bin/gnuplot.exe"
int main(){
FILE *fp;
fp = popen(GNUPLOT_PATH, "w");
double x,dx;
int i;
x=0.1;
dx=0.01;
fprintf(fp, "set terminal gif animate optimize delay 10 size 400,800\n");
fprintf(fp, "set output 'test.gif'\n");
fprintf(fp, "set xr [0:3]\n");
fprintf(fp, "set yr [0:3]\n");
for(i=1;i<=10;i++){
fprintf(fp, "plot '-' pt 7 ps 2\n");
fprintf(fp, "%f, 0\n", x);
fprintf(fp, "e\n");
x=x+dx;
}
pclose(fp);
return 0;
}