[Top][All Lists]

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

Re: gnuplot image code

From: John W. Eaton
Subject: Re: gnuplot image code
Date: Wed, 25 Oct 2006 15:02:33 -0400

On 25-Oct-2006, I wrote:

| On 25-Oct-2006, Quentin Spencer wrote:
| | Good point. I assumed it was something that would not likely be changed 
| | during an octave session, and that calling gnuplot just to get the 
| | version would be slow and undesirable to repeat. However, I suppose 
| | plotting is not ususally done in speed critical sections of code, so 
| | maybe this isn't necessary.
| Or, maybe we should arrange for the code that actually invokes the
| gnuplot process to run "gnuplot --version" to extract the version
| number, then restart gnuplot to actually do the plotting.  The version
| number could then be stored for each figure, so doing
|   gnuplot_binary ("gnuplot-4.2");
|   figure (1)
|   image (...)
|   gnuplot_binary ("gnuplot-4.0");
|   figure (2)
|   image (...)
|   figure (1)  # switch back to figure 1, which already has gnuplot running
|   image (...)
| would work.
| Even on the slowest system I could find (230MHz Pentium MMX), running
| "gnuplot --version" only takes .3s the first time, and about .025s
| after that, so the overhead should not be too big.  How long does it
| take on a typical system using Cygwin, where process creation is known
| to be slow?
| The __gnuplot_version__ function could return the version for the
| current figure, or -1 if there is no figure currently open.

After looking at this for a bit, I think it is too tricky to do it
correctly, so I checked in the following version of



## Copyright (C) 2006 Daniel Sebald
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, write to the Free
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.

## -*- texinfo -*-
## @deftypefn {Function File} address@hidden =} __gnuplot_version__ 
## Return the version of gnuplot we are using.  Note that we do not
## attempt to handle the case of the user switching to different
## versions of gnuplot during the same session.
## @end deftypefn

function version = __gnuplot_version__ ()

  persistent __version__ = "";

  if (isempty (__version__))
    [status, output] = system (sprintf ("%s --version", gnuplot_binary ()));
    pattern = "^[^\\s]*\\s*([0-9]+\\.[0-9]+)\\s*[^\\s]*\\s*([^\\s]*)";
    [d1, d2, d3, d4, matches] = regexp (output, pattern);
    if (iscell (matches) && numel (matches) > 0 && iscellstr (matches{1}))
      __version__ = matches{1}{1};

  version = __version__;


reply via email to

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