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: Daniel J Sebald
Subject: Re: Getting info back from gnuplot for auto range values
Date: Wed, 20 Jun 2007 15:43:42 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

John W. Eaton wrote:
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?

Oh yeah.  (Get a slow machine, like mine.)  This problem is so commonly run 
across in so many programs, you'd think that operating systems would have come 
up with useful options by now.


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.

With all the stream features inherent with using <iostream>, can't one create a stream 
other than stdout and then configure gnuplot's print to that stream?  Even still, if there is 
no need for what is coming from stdout, just flush the buffer before issuing a gnuplot 
"print".  (Probably still has the timing issue to deal with.)


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?

I'd say require a higher version depending upon the severity of the 
ramification.  For example, checking on version 4.2 for gross differences like 
handling images as opposed to launching a different program to view images make 
sense.  But a million little checks for this and that small feature isn't worth 
it.


| 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).

True, but we don't yet know the speed of the handle-code implementing what you 
suggested before, i.e., compute the axes limits and don't send anything to 
gnuplot.  I presume you are going to go to the level of __go_draw_axes__ in 
order to access the auto-range code and not re-implement it somewhere else.  
(Could make that a separate m-file I suppose.)  Still have to retrieve and 
manipulate the data to get the auto-ranges.  It could be that the actually 
sending commands to gnuplot is a small fraction of what is now causing the 
delay.


| 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')

OK, I just wanted to confirm that.

Dan


reply via email to

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