octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting info back from gnuplot for auto range values


From: John W. Eaton
Subject: Re: Getting info back from gnuplot for auto range values
Date: Wed, 20 Jun 2007 15:11:07 -0400

On 20-Jun-2007, Daniel J Sebald wrote:

| You give up too easily.

Yeah, that's why I'm still working on Octave after more than 15 years.

| How about the attached patch that changes the terminal to "unknown"
| when the figure is off?

I tried it and I see

  octave:1> figure ('visible', 'off')
  octave:2> x = -pi:0.1:pi;
  octave:3> plot (x, sin(x))
  error: fscanf: invalid stream number = -1
  [...]

I think this happens because of a race condition here:

  fputs (plot_stream, "set print \"-\";\n");
  gpfid = fopen (__gpprintfile__);

It looks like gnuplot is not finished with the file (apparently it
doesn't even exist yet on my system as the fopen failed).  Even if we
can guarantee the existence of the file, how can we know that gnuplot
is finished writing the file before we try to open and read it?
Starting gnuplot with something like popen2 so we can read output from
gnuplot directly and then having the print command output go to stdout
opens a completely different set of problems because then we have to
somehow recognize the output from the print command in all the other
output that gnuplot can produce.

A separate issue is that printing these variables doesn't work with
gnuplot 4.0:

  octave:1> figure ('visible', 'off');
  octave:2> x = -pi:0.1:pi;
  octave:3> plot (x, sin(x));
           line 64: undefined variable: GPVAL_X_MIN

           line 64: undefined variable: GPVAL_X_MAX

  error: fscanf: invalid stream number = -1
  [...]

If we solved the race condition problem, we could make the feature
conditional on having a newer version of gnuplot, but at what point do
we want to stop doing that and just require gnuplot 4.2 or later for
things to work correctly?

| In a perfect world, extraneous computations would be avoided.  Other
| than the delay there isn't much harm,

Having plotting work slowly seems to be a big problem for some people
(I am not blaming gnuplot, but it is likely to slow down significantly
if we have to run through all of __go_draw_axes__ and send data to
gnuplot even when the plot is not visible).

| I just recall Octave/gnuplot interface in older versions using
| popen(), but that was at the C level of course.

It still uses popen, but pipe is not the same as popen.

| PS:  When doing these commands
| 
| figure ('visible', 'off');
| figure ('visible', 'on');
| figure ('visible', 'off');
| figure ('visible', 'on');
| 
| should the figure number be increasing as it currently does in CVS version?

Yes, because when it is used this way, figure is creating new figures.
If you just want to toggle the visible state for the current plot,
then use

  set (gcf (), 'visible', 'off')
  set (gcf (), 'visible', 'on')

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]