3

I've been wanting to plot some data with gnuplot. What I've written compiles fine, and also executes. The plot itself even seems to work in gnuplot.

However, I'm getting an warning that I want to understand:

Warning: slow font initializationqt_processTermEvent received a GE_fontprops event. This should not have happened

What does this error mean, and how can I avoid it? Does this even have any effect on the plot?

I've included my code below, which is a crude population simulation to see chaotic behavior.

#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;
}

Also, a bonus question: How do I make gnuplot draw a line between the points it plots, so that it's easier for me to visualise?

4
  • 1
    Have you checked the manual and the plotting styles, e.g. plot 'data.tmp' with lines or plot 'data.tmp' with linespoints? Commented Dec 7, 2021 at 12:52
  • @theozh I have not, I downloaded gnuplot 15 minutes ago and have never used it before. I've realised that I can probably find a tutorial on Youtube about how to plot lines. Still curious about that warning though. Commented Dec 7, 2021 at 13:06
  • It's a warning not an error. But, I'm sorry, I don't know what this means. Try to change to wxt terminal set term wxt. Maybe you will find some more explanations (in the future) here: sourceforge.net/p/gnuplot/bugs/2316 Commented Dec 7, 2021 at 15:45
  • 2
    Unrelated: fclose(fp); before sending commands through the pipe (or even before opening the pipe). Commented Dec 7, 2021 at 18:09

1 Answer 1

4

Gnuplot does not do its own font handling. Depending on what output mode (gnuplot calls it "terminal") is being used it queries various system libraries or subsystems to estimate how much space will be occupied by a particular string of characters that will be placed on the graph. If the response to the query is an error, or is too slow, it prints that warning and continues with a best-guess estimate of the space required.

As I understand it, the most common underlying cause for this is that the font being requested is not currently in the system font cache so the response to the first query is very slow. After that the font is in the cache so the response is quick and you don't see the message again, at least not from the same gnuplot session.

There is a command-line option that tells the program to wait longer for the system to respond:

 gnuplot --slow

That will probably avoid the warning message, and possibly improve text layout on the first plot, but it may result in a noticeable delay in producing that first plot while the system font cache is updated.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.