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", ¤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;
}
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With