Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
9112:f5b51f54f44e | 9113:4bb94a71913b |
---|---|
39 plot_stream = []; | 39 plot_stream = []; |
40 fid = []; | 40 fid = []; |
41 printing = ! output_to_screen (gnuplot_trim_term (term)); | 41 printing = ! output_to_screen (gnuplot_trim_term (term)); |
42 default_plot_stream = get (h, "__plot_stream__"); | 42 default_plot_stream = get (h, "__plot_stream__"); |
43 unwind_protect | 43 unwind_protect |
44 plot_stream = open_gnuplot_stream (2, h); | 44 plot_stream = __gnuplot_open_stream__ (2, h); |
45 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) | 45 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS")) |
46 available_terminals = __gnuplot_get_var__ (plot_stream, "GPVAL_TERMINALS"); | 46 available_terminals = __gnuplot_get_var__ (plot_stream, "GPVAL_TERMINALS"); |
47 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); | 47 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match"); |
48 gnuplot_supports_term = any (strcmpi (available_terminals, | 48 gnuplot_supports_term = any (strcmpi (available_terminals, |
49 gnuplot_trim_term (term))); | 49 gnuplot_trim_term (term))); |
77 end_unwind_protect | 77 end_unwind_protect |
78 elseif (nargin == 1) | 78 elseif (nargin == 1) |
79 ## Graphics terminal for display. | 79 ## Graphics terminal for display. |
80 plot_stream = get (h, "__plot_stream__"); | 80 plot_stream = get (h, "__plot_stream__"); |
81 if (isempty (plot_stream)) | 81 if (isempty (plot_stream)) |
82 plot_stream = open_gnuplot_stream (2, h); | 82 plot_stream = __gnuplot_open_stream__ (2, h); |
83 new_stream = true; | 83 new_stream = true; |
84 else | 84 else |
85 new_stream = false; | 85 new_stream = false; |
86 endif | 86 endif |
87 enhanced = gnuplot_set_term (plot_stream (1), new_stream, h); | 87 enhanced = gnuplot_set_term (plot_stream (1), new_stream, h); |
103 ## When zero, the behavior of gnuplot changes. | 103 ## When zero, the behavior of gnuplot changes. |
104 implicit_margin = 1/72; | 104 implicit_margin = 1/72; |
105 endif | 105 endif |
106 else | 106 else |
107 implicit_margin = 0.0; | 107 implicit_margin = 0.0; |
108 endif | |
109 endfunction | |
110 | |
111 function plot_stream = open_gnuplot_stream (npipes, h) | |
112 cmd = gnuplot_binary (); | |
113 if (npipes > 1) | |
114 [plot_stream(1), plot_stream(2), pid] = popen2 (cmd); | |
115 if (pid < 0) | |
116 error ("drawnow: failed to open connection to gnuplot"); | |
117 endif | |
118 else | |
119 plot_stream = popen (cmd, "w"); | |
120 if (plot_stream < 0) | |
121 error ("drawnow: failed to open connection to gnuplot"); | |
122 endif | |
123 endif | |
124 if (! isempty (h)) | |
125 set (h, "__plot_stream__", plot_stream); | |
126 endif | 108 endif |
127 endfunction | 109 endfunction |
128 | 110 |
129 function [enhanced, implicit_margin] = gnuplot_set_term (plot_stream, new_stream, h, term, file) | 111 function [enhanced, implicit_margin] = gnuplot_set_term (plot_stream, new_stream, h, term, file) |
130 ## Generate the gnuplot "set terminal <term> ..." command. Include | 112 ## Generate the gnuplot "set terminal <term> ..." command. Include |