diff scripts/plot/gnuplot_drawnow.m @ 9113:4bb94a71913b

__gnuplot_open_stream__.m: New function and its application.
author Ben Abbott <bpabbott@mac.com>
date Sun, 12 Apr 2009 20:40:53 -0400
parents d0d507cbd123
children 406ed43c0233
line wrap: on
line diff
--- a/scripts/plot/gnuplot_drawnow.m	Sun Apr 12 22:30:00 2009 +0200
+++ b/scripts/plot/gnuplot_drawnow.m	Sun Apr 12 20:40:53 2009 -0400
@@ -41,7 +41,7 @@
     printing = ! output_to_screen (gnuplot_trim_term (term));
     default_plot_stream = get (h, "__plot_stream__");
     unwind_protect
-      plot_stream = open_gnuplot_stream (2, h);
+      plot_stream = __gnuplot_open_stream__ (2, h);
       if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS"))
         available_terminals = __gnuplot_get_var__ (plot_stream, "GPVAL_TERMINALS");
         available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match");
@@ -79,7 +79,7 @@
     ##  Graphics terminal for display.
     plot_stream = get (h, "__plot_stream__");
     if (isempty (plot_stream))
-      plot_stream = open_gnuplot_stream (2, h);
+      plot_stream = __gnuplot_open_stream__ (2, h);
       new_stream = true;
     else
       new_stream = false;
@@ -108,24 +108,6 @@
   endif
 endfunction
 
-function plot_stream = open_gnuplot_stream (npipes, h)
-  cmd = gnuplot_binary ();
-  if (npipes > 1)
-    [plot_stream(1), plot_stream(2), pid] = popen2 (cmd);
-    if (pid < 0)
-      error ("drawnow: failed to open connection to gnuplot");
-    endif
-  else
-    plot_stream = popen (cmd, "w");
-    if (plot_stream < 0)
-      error ("drawnow: failed to open connection to gnuplot");
-    endif
-  endif
-  if (! isempty (h))
-    set (h, "__plot_stream__", plot_stream);
-  endif
-endfunction
-
 function [enhanced, implicit_margin] = gnuplot_set_term (plot_stream, new_stream, h, term, file)
   ## Generate the gnuplot "set terminal <term> ..." command.  Include
   ## the subset of properties "position", "units", "paperposition",