【问题标题】:Errors with gnuplot after execution执行后 gnuplot 出错
【发布时间】: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", &currentPop, &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 linesplot 'data.tmp' with linespoints?
  • @theozh 我没有,我在 15 分钟前下载了 gnuplot,之前从未使用过。我意识到我可能可以在 Youtube 上找到有关如何绘制线条的教程。不过仍然对这个警告感到好奇。
  • 这是警告而不是错误。但是,对不起,我不知道这是什么意思。尝试更改为wxt 终端set term wxt。也许您会在这里找到更多解释(将来):sourceforge.net/p/gnuplot/bugs/2316
  • 无关:fclose(fp); 在通过管道发送命令之前(甚至在打开管道之前)。

标签: c gnuplot


【解决方案1】:

Gnuplot 不进行自己的字体处理。根据正在使用的输出模式(gnuplot 称之为“终端”),它会查询各种系统库或子系统,以估计将放置在图形上的特定字符串将占用多少空间。 如果对查询的响应是错误或太慢,它会打印该警告并继续对所需空间进行最佳估计。

据我了解,最常见的根本原因是所请求的字体当前不在系统字体缓存中,因此对第一个查询的响应非常慢。之后字体在缓存中,因此响应很快,您不会再次看到该消息,至少不是来自同一个 gnuplot 会话。

有一个命令行选项告诉程序等待更长的时间等待系统响应:

 gnuplot --slow

这可能会避免警告消息,并可能改善第一个绘图的文本布局,但在更新系统字体缓存时可能会导致生成第一个绘图的明显延迟。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多