comparison scripts/plot/__go_draw_axes__.m @ 8217:f74cb5e3a6c1

send binary data to gnuplot
author Daniel J. Sebald <daniel.sebald@ieee.org>
date Tue, 14 Oct 2008 14:59:09 -0400
parents 5d6b9311be38
children 8a5fbd656f55
comparison
equal deleted inserted replaced
8216:5d6b9311be38 8217:f74cb5e3a6c1
1142 fputs (plot_stream, "set view map;\n"); 1142 fputs (plot_stream, "set view map;\n");
1143 else 1143 else
1144 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); 1144 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z);
1145 endif 1145 endif
1146 endif 1146 endif
1147 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, 1147 fprintf (plot_stream, "%s \"-\" binary record=%d format='%%float64' %s %s %s \\\n", plot_cmd,
1148 usingclause{1}, titlespec{1}, withclause{1}); 1148 columns(data{1}), usingclause{1}, titlespec{1}, withclause{1});
1149 for i = 2:data_idx 1149 for i = 2:data_idx
1150 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", 1150 fprintf (plot_stream, ", \"-\" binary record=%d format='%%float64' %s %s %s \\\n",
1151 usingclause{i}, titlespec{i}, withclause{i}); 1151 columns(data{i}), usingclause{i}, titlespec{i}, withclause{i});
1152 endfor 1152 endfor
1153 fputs (plot_stream, ";\n"); 1153 fputs (plot_stream, ";\n");
1154 for i = 1:data_idx 1154 for i = 1:data_idx
1155 if (is_image_data(i)) 1155 if (is_image_data(i))
1156 fwrite (plot_stream, data{i}, "float32"); 1156 fwrite (plot_stream, data{i}, "float32");
1339 if (any (idx)) 1339 if (any (idx))
1340 data(idx) = NaN; 1340 data(idx) = NaN;
1341 endif 1341 endif
1342 1342
1343 if (nd == 2) 1343 if (nd == 2)
1344 nan_elts = find (sum (isnan (data))); 1344 fwrite (plot_stream, data, "float64");
1345 fmt = cstrcat (repmat ("%.15g ", 1, rows (data)), "\n");
1346 if (isempty (nan_elts))
1347 fprintf (plot_stream, fmt, data);
1348 else
1349 n = columns (data);
1350 have_nans = true;
1351 num_nan_elts = numel (nan_elts);
1352 if (num_nan_elts == n)
1353 fputs (plot_stream, "Inf Inf\n");
1354 else
1355 k = 1;
1356 for i = 1:n
1357 if (have_nans && i == nan_elts(k))
1358 fputs (plot_stream, "\n");
1359 have_nans = ++k <= num_nan_elts;
1360 else
1361 fprintf (plot_stream, fmt, data(:,i));
1362 endif
1363 endfor
1364 endif
1365 endif
1366 elseif (nd == 3) 1345 elseif (nd == 3)
1367 ## FIXME -- handle NaNs here too?
1368 if (parametric) 1346 if (parametric)
1369 fprintf (plot_stream, "%.15g %.15g %.15g\n", data); 1347 fwrite (plot_stream, data, "float64");
1370 else 1348 else
1371 nr = rows (data); 1349 nr = rows (data);
1372 if (cdata) 1350 if (cdata)
1373 for j = 1:4:nr 1351 for j = 1:4:nr
1374 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(j:j+3,:)); 1352 fwrite (plot_stream, data(j:j+3,:), "float64");
1375 fputs (plot_stream, "\n");
1376 endfor 1353 endfor
1377 else 1354 else
1378 for j = 1:3:nr 1355 for j = 1:3:nr
1379 fprintf (plot_stream, "%.15g %.15g %.15g\n", data(j:j+2,:)); 1356 fwrite (plot_stream, data(j:j+2,:), "float64");
1380 fputs (plot_stream, "\n");
1381 endfor 1357 endfor
1382 endif 1358 endif
1383 endif 1359 endif
1384 endif 1360 endif
1385 fputs (plot_stream, "e\n");
1386 1361
1387 endfunction 1362 endfunction
1388 1363
1389 function do_tics (obj, plot_stream, ymirror, mono) 1364 function do_tics (obj, plot_stream, ymirror, mono)
1390 if (strcmpi (obj.xaxislocation, "top")) 1365 if (strcmpi (obj.xaxislocation, "top"))