Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

line 0: warning: Skipping data file with no valid points(gnuplot)

2,159 views
Skip to first unread message

Marcello Chiurazzi

unread,
Oct 11, 2015, 6:11:24 AM10/11/15
to
I have a problem using gnupolot from a c++ source code.
The error is this:line 0: warning: Skipping data file with no valid points

The code is this:
char * commandsForGnuplot[] = {"set title \"ThumbRest\"","plot [0:6][-8.0:8.0] 'Thumb_R_1' with linespoints lc rgb 'black', 'Thumb_R_2' with linespoints lc rgb 'green', 'Thumb_R_3' with linespoints lc rgb 'blue', 'Thumb_R_4' with linespoints lc rgb 'red'"};

for (int l=0;l<NUM_POINTS;l++)
{
xvals[l]=((6)*(l+1))/(double)NUM_POINTS;
}
FILE * temp1 = fopen("Thumb_R_1", "w");
FILE * temp2 = fopen("Thumb_R_2", "w");
FILE * temp3 = fopen("Thumb_R_3", "w");
FILE * temp4 = fopen("Thumb_R_4", "w");
/*Opens an interface that one can use to send commands as if they were typing into the
* gnuplot command line. "The -persistent" keeps the plot open even after your
* C program terminates.
*/
FILE * gnuplotPipe = popen ("gnuplot -persistent", "w");
int i;
for (i=0; i < NUM_POINTS; i++)
{
fprintf(temp1, "%g %g \n", xvals[i] , position_4f[4*i]); //Write the data to a temporary file
fprintf(temp2, "%g %g \n", xvals[i] , position_4f[1+4*i]); //Write the data to a temporary file
fprintf(temp3, "%g %g \n", xvals[i] , position_4f[2+4*i]); //Write the data to a temporary file
fprintf(temp4, "%g %g \n", xvals[i] , position_4f[3+4*i]); //Write the data to a temporary file
}
for (i=0; i < NUM_COMMANDS; i++)
{
fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]); //Send commands to gnuplot one by one.
}

The plot is a traiectory followed by a robot,this traiectory is randomic because i set the pose to reach and the system define the traiectory,so the error is randomic too(sometimes i have it,sometimes no).
I would like to understand what is this error(warning).

Karl-Friedrich Ratzsch

unread,
Oct 11, 2015, 7:01:54 AM10/11/15
to
Am 11.10.2015 um 12:11 schrieb Marcello Chiurazzi:
> I have a problem using gnupolot from a c++ source code.
> The error is this:line 0: warning: Skipping data file with no valid points
>
> The code is this:
> char * commandsForGnuplot[] = {"set title \"ThumbRest\"","plot [0:6][-8.0:8.0] 'Thumb_R_1' with linespoints lc rgb 'black', 'Thumb_R_2' with linespoints lc rgb 'green', 'Thumb_R_3' with linespoints lc rgb 'blue', 'Thumb_R_4' with linespoints lc rgb 'red'"};

The warning means that one of your temporary data files has nothing
to do for "plot [0:6][-8.0:8.0]". Why, I cannot tell.

It's very hard to see the source of the problem with everything
wrapped in your C code. It could be a bug in gnuplot, an error in
the commands you use, an error in your data processing, a problem
with your original data, or anything else.

You should test your gnuplot commands in a plain gnuplot script, and
only then transfer them to your C code. Check if your temp files
really contain what you think they should, etc.

Karl

Marcello Chiurazzi

unread,
Oct 12, 2015, 6:38:52 PM10/12/15
to
I do an example:
This is the code without problems:
int main(int argc, char **argv)
{
const char * commandsForGnuplot[] = {"set title \"A\"","plot [0:3][0:10] 'data1.temp' with linespoints lc rgb 'red'"};
double x1vals[NUM_POINTS] = {0.2 , 0.4 , 0.6 , 0.8, 1.0};
double y1vals[NUM_POINTS] = {1.0 , 1.0 , 1.0 , 1.0 , 1.0};
FILE * temp1 = fopen("data1.temp", "w");
/*Opens an interface that one can use to send commands as if they were typing into the
* gnuplot command line. "The -persistent" keeps the plot open even after your
* C program terminates.
*/
FILE * gnuplotPipe = popen ("gnuplot -persistent", "w");
int i;
for (i=0; i < NUM_POINTS; i++)
{
fprintf(temp1, "%lf %lf \n", x1vals[i] , y1vals[i]); //Write the data to a temporary file
}
for (i=0; i < NUM_COMMANDS; i++)
{
fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]); //Send commands to gnuplot one by one.
}
return 0;
}


If i add a line to plot immediately the points instead of wait for the end of the execution i have this warning:
int main(int argc, char **argv)
{
const char * commandsForGnuplot[] = {"set title \"A\"","plot [0:3][0:10] 'data1.temp' with linespoints lc rgb 'red'"};
double x1vals[NUM_POINTS] = {0.2 , 0.4 , 0.6 , 0.8, 1.0};
double y1vals[NUM_POINTS] = {1.0 , 1.0 , 1.0 , 1.0 , 1.0};
FILE * temp1 = fopen("data1.temp", "w");
/*Opens an interface that one can use to send commands as if they were typing into the
* gnuplot command line. "The -persistent" keeps the plot open even after your
* C program terminates.
*/
FILE * gnuplotPipe = popen ("gnuplot -persistent", "w");
int i;
for (i=0; i < NUM_POINTS; i++)
{
fprintf(temp1, "%lf %lf \n", x1vals[i] , y1vals[i]); //Write the data to a temporary file
}
for (i=0; i < NUM_COMMANDS; i++)
{
fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]); //Send commands to gnuplot one by one.
fflush(gnuplotPipe);
}
for (int i=0;i<10;i++)
{
std::cout<<i<<std::endl;
sleep(1.0);
}
return 0;

}

WARNING:
plot [0:3][0:10] 'data1.temp' with linespoints lc rgb 'red'

line 0: warning: Skipping data file with no valid points


What does it means??????

Ethan A Merritt

unread,
Oct 12, 2015, 7:30:24 PM10/12/15
to
I suspect it would be a good idea to close your temp files before trying
to read them from another program (in this case gnuplot).

On the other hand, maybe one of your files really is empty?

Ethan



Marcello Chiurazzi

unread,
Oct 13, 2015, 3:33:20 AM10/13/15
to
In this case what happen is that the plot appears during the execution but it is completely white and i have this warning,but when the program ends the points appears on the plot.So at the end of the program i can have the correct plot but during the execution the plot window is completely white.

I read your answer but how i should close my temp file?

Marcello Chiurazzi

unread,
Oct 13, 2015, 3:42:08 AM10/13/15
to
I ditit,the problem was the temp file.i closed it and now it works.thank you Ethan
0 new messages