help-octave
[Top][All Lists]
Advanced

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

gnuplot direct drive


From: John W. Eaton
Subject: gnuplot direct drive
Date: Tue, 23 Jun 1998 15:27:38 -0500 (CDT)

On  4-Jun-1998, address@hidden <address@hidden> wrote:

| On Thu, Jun 04, 1998 at 08:51:53AM -0500, John W. Eaton wrote:
| > On  4-Jun-1998, Daniel Heiserer <address@hidden> wrote:
| > | 2) How can I talk to gnuplot. I know gset, gplot, replot. Can I pipe all
| > | the over commands as well?
| > | e.g. "save" and whatever?
| > 
| > Sorry, I don't understand what you are asking.  Can you give an
| > example of exactly what you want to do?
| 
| in octave,
| 
|       # gset xxxxx
| 
| sends xxxxx as an arg to set on the gnuplot command line, i.e., `set
| xxxxx' is sent to gnuplot.  similarly gplot drives plot.  the problem
| is that many gnuplot commands do not begin with `set'.  replot is one,
| but there a special for that.
| 
| how would i tell gnuplot to, e.g., `reset' while in octave?  perhaps
| it would be useful to have a `graw' function to directly pass strings
| to gnuplot without any prepending of set.

OK, why not?  The following patch implements graw.  You can use it to
send any string to the gnuplot subprocess.  For example, commands like

  graw ("reset\n");
  graw (sprintf ("save functions \"%s\"\n", gnuplot_function_file));

should work (note that graw does not automatically append a newline
character to its argument).

If a gnuplot subprocess does not already exist, one is started
automatically.

jwe


Tue Jun 23 15:09:54 1998  John W. Eaton  <address@hidden>

        * pt-plot.cc (Fgraw): New function.


*** octave-2.0.13/src/pt-plot.cc        Wed Apr 15 01:19:36 1998
--- octave-2.0/src/pt-plot.cc   Tue Jun 23 15:21:56 1998
***************
*** 1017,1022 ****
--- 1017,1049 ----
    return retval;
  }
  
+ DEFUN (graw, args, ,
+   "graw (string)\n\
+ \n\
+ Send STRING directly to gnuplot subprocess.")
+ {
+   octave_value_list retval;
+ 
+   if (args.length () == 1 && args(0).is_string ())
+     {
+       string cmd = args(0).string_value ();
+ 
+       if (! (plot_stream && *plot_stream))
+       open_plot_stream ();
+ 
+       if (! error_state)
+       {
+         *plot_stream << cmd;
+ 
+         plot_stream->flush ();
+       }
+     }
+   else
+     print_usage ("graw");
+ 
+   return retval;
+ }
+ 
  DEFUN_TEXT (gset, args, ,
    "gset [options]\n\
  \n\



reply via email to

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