【发布时间】:2021-12-07 12:47:30
【问题描述】:
我一直想用 gnuplot 绘制一些数据。我写的编译很好,也可以执行。情节本身甚至似乎可以在 gnuplot 中运行。
但是,我收到了一个我想了解的警告:
警告:字体初始化缓慢qt_processTermEvent 收到一个 GE_fontprops 事件。这不应该发生
这个错误是什么意思,我该如何避免它?这对剧情有影响吗?
我在下面包含了我的代码,这是一个粗略的人口模拟,用于查看混乱行为。
#include <stdio.h>
int main(int argc, char const *argv[]) {
float currentPop;
float nextPop = 0;
float growthRate;
FILE *fp = NULL;
FILE *gnupipe = NULL;
char *GnuCommands [] = {"set title \"Popsim\"", "plot 'data.tmp'"};
fp = fopen("data.tmp", "w");
gnupipe = _popen("gnuplot -persistent", "w");
printf("Enter current population and growth rate:\n");
scanf("%f %f", ¤tPop, &growthRate);
for (int counter = 0; counter < 30; counter++) {
nextPop = growthRate * currentPop * (1 - currentPop);
fprintf(fp, "%d %f\n", counter, nextPop);
currentPop = nextPop;
}
for (int i = 0; i < 2; i++) {
fprintf(gnupipe, "%s\n", GnuCommands[i]);
}
return 0;
}
另外,一个额外的问题:我如何让 gnuplot 在它绘制的点之间画一条线,以便我更容易可视化?
【问题讨论】:
-
您是否检查过手册和绘图样式,例如
plot 'data.tmp' with lines或plot 'data.tmp' with linespoints? -
@theozh 我没有,我在 15 分钟前下载了 gnuplot,之前从未使用过。我意识到我可能可以在 Youtube 上找到有关如何绘制线条的教程。不过仍然对这个警告感到好奇。
-
这是警告而不是错误。但是,对不起,我不知道这是什么意思。尝试更改为
wxt终端set term wxt。也许您会在这里找到更多解释(将来):sourceforge.net/p/gnuplot/bugs/2316 -
无关:
fclose(fp);在通过管道发送命令之前(甚至在打开管道之前)。