[Top][All Lists]

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

Problems trying to fix contour script

From: Victor Munoz
Subject: Problems trying to fix contour script
Date: Tue, 4 Jun 2002 19:47:58 -0400 (CLT)

  This seems to be a very strange problem. Maybe someone there has a clue,
but I've given up after several days of trying. Let me bother you with the

  I don't really like gnuplot for octave figures, specially now that I
need to superimpose 2d lines on a contour map. I understand this is not
possible in principle, since gnuplot treats contour maps as 3d graphs, and
is confused if one tries to add further lines (I read this in the
gnuplot info; anyway, I've tried and it hasn't worked for me... maybe
someone has, by the way?). 
  My way to solve this (following gnuplot info suggestion) is to change
terminal to table, which writes contour lines as x,y points in table form,
and then plot these lines with the usual plot function. Thus I can add any
further line because everything is 2d.
  Now I wanted to write a function to do this, to be called from octave  
instead of contour wherever I need. The file also tries to be more similar
to the Matlab contour function, and to avoid gnuplot complaint when one
calls it with a number of levels after calling it with a discrete set of
levels. Anyway, this is the file:

----------file contorno.m-------------
function contorno(x,y,Z,n)

if (~is_vector(x) || ~is_vector(y) || ~is_matrix(Z)),
  error("Argumentos incorrectos");
archivo = "/tmp/tabla_contorno.txt";
gset term table;
eval(["gset output \"" archivo "\""]);
gset term x11;
gset noparametric;

eval(["gplot \"" archivo "\""]);
system(["rm " archivo]);
-----------end of file-------------

 I've done several trials, executing the following two lines of code:


  However, I sometimes get the following message:

gnuplot> pl /tmp/tabla_contorno.txt t "line 1"
         line 0: invalid expression 

I've done three types of trials:

Trial 1:
 Commenting the 'system(["rm " archivo])' line in contorno.m
 This executes both lines without errors, except sometimes, when I get the 
error message above.

Trial 2: 
 Uncommenting the 'system' line. This deletes the temporary file,
and I always get the error, and cannot plot two succesive contours with
my function.

Trial 3:
 Uncommenting the 'system' line *and* uncommenting the various
'disp/keyboard' lines I inserted to try to catch the
error. This forces me to type many 'returns', of course. Surprisingly,
I get *no error*.

 So, I first thought this had to do with the previous existence or not
of the temporary file when contorno.m is called, but the evidence is quite 

  I would be really glad if someone had a comment. I also expect this
does not turn out to be a triviality.
                                            Victor Munoz
                                            Departamento de Fisica
                                            Facultad de Ciencias
                                            Universidad de Chile

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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