6405
|
1 ## Copyright (C) 2005 John W. Eaton |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} __go_draw_axes__ (@var{axis_obj}, @var{plot_stream}) |
|
22 ## Display the axes @var{axis_obj} on @var{plot_stream}. |
|
23 ## @end deftypefn |
|
24 |
|
25 ## Author: jwe |
|
26 |
|
27 function __go_draw_axes__ (h, plot_stream) |
|
28 |
|
29 if (nargin == 2) |
|
30 |
|
31 axis_obj = get (h); |
|
32 |
|
33 parent_figure_obj = get (axis_obj.parent); |
|
34 |
6413
|
35 persistent have_newer_gnuplot ... |
|
36 = compare_versions (__gnuplot_version__ (), "4.0", ">"); |
6405
|
37 |
|
38 ## Set axis properties here? |
|
39 |
|
40 if (! isempty (axis_obj.outerposition)) |
|
41 pos = axis_obj.outerposition; |
|
42 fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); |
|
43 fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); |
|
44 endif |
|
45 |
|
46 if (! isempty (axis_obj.position)) |
|
47 pos = axis_obj.position; |
|
48 fprintf (plot_stream, "set origin %g, %g;\n", pos(1), pos(2)); |
|
49 fprintf (plot_stream, "set size %g, %g;\n", pos(3), pos(4)); |
|
50 endif |
|
51 |
6758
|
52 if (strcmpi (axis_obj.dataaspectratiomode, "manual")) |
6405
|
53 r = axis_obj.dataaspectratio; |
|
54 fprintf (plot_stream, "set size ratio %g;\n", -r(2)/r(1)); |
|
55 else |
|
56 fputs (plot_stream, "set size noratio;\n"); |
|
57 endif |
|
58 |
6778
|
59 fputs (plot_stream, "unset label;\n"); |
|
60 |
6405
|
61 if (! isempty (axis_obj.title)) |
|
62 t = get (axis_obj.title); |
|
63 if (isempty (t.string)) |
|
64 fputs (plot_stream, "unset title;\n"); |
|
65 else |
|
66 fprintf (plot_stream, "set title \"%s\";\n", |
|
67 undo_string_escapes (t.string)); |
|
68 endif |
|
69 endif |
|
70 |
|
71 if (! isempty (axis_obj.xlabel)) |
|
72 t = get (axis_obj.xlabel); |
6737
|
73 angle = t.rotation; |
6405
|
74 if (isempty (t.string)) |
|
75 fputs (plot_stream, "unset xlabel;\n"); |
|
76 else |
6738
|
77 fprintf (plot_stream, "set xlabel \"%s\"", |
|
78 undo_string_escapes (t.string)); |
|
79 if (have_newer_gnuplot) |
|
80 ## Rotation of xlabel not yet support by gnuplot as of 4.2, but |
|
81 ## there is no message about it. |
|
82 fprintf (plot_stream, " rotate by %f", angle); |
|
83 endif |
|
84 fputs (plot_stream, ";\n"); |
6405
|
85 endif |
|
86 endif |
|
87 |
|
88 if (! isempty (axis_obj.ylabel)) |
|
89 t = get (axis_obj.ylabel); |
6737
|
90 angle = t.rotation; |
6405
|
91 if (isempty (t.string)) |
|
92 fputs (plot_stream, "unset ylabel;\n"); |
|
93 else |
6738
|
94 fprintf (plot_stream, "set ylabel \"%s\"", |
|
95 undo_string_escapes (t.string)); |
|
96 if (have_newer_gnuplot) |
6766
|
97 fprintf (plot_stream, " rotate by %f;\n", angle); |
6738
|
98 endif |
|
99 fputs (plot_stream, ";\n"); |
6405
|
100 endif |
|
101 endif |
|
102 |
|
103 if (! isempty (axis_obj.zlabel)) |
|
104 t = get (axis_obj.zlabel); |
6737
|
105 angle = t.rotation; |
6405
|
106 if (isempty (t.string)) |
|
107 fputs (plot_stream, "unset zlabel;\n"); |
|
108 else |
6738
|
109 fprintf (plot_stream, "set zlabel \"%s\"", |
|
110 undo_string_escapes (t.string)); |
|
111 if (have_newer_gnuplot) |
|
112 ## Rotation of zlabel not yet support by gnuplot as of 4.2, but |
|
113 ## there is no message about it. |
|
114 fprintf (plot_stream, " rotate by %f;\n", angle); |
|
115 endif |
|
116 fputs (plot_stream, ";\n"); |
6405
|
117 endif |
|
118 endif |
|
119 |
6809
|
120 if (strcmpi (axis_obj.xaxislocation, "top")) |
|
121 xaxisloc = "x2"; |
|
122 xaxisloc_using = "x2"; |
|
123 else |
|
124 xaxisloc = "x"; |
|
125 xaxisloc_using = "x1"; |
|
126 endif |
|
127 if (strcmpi (axis_obj.yaxislocation, "right")) |
|
128 yaxisloc = "y2"; |
|
129 yaxisloc_using = "y2"; |
|
130 else |
|
131 yaxisloc = "y"; |
|
132 yaxisloc_using = "y1"; |
|
133 endif |
|
134 |
6758
|
135 if (strcmpi (axis_obj.xgrid, "on")) |
6809
|
136 fprintf (plot_stream, "set grid %stics;\n", xaxisloc); |
6405
|
137 else |
6809
|
138 fprintf (plot_stream, "set grid no%stics;\n", xaxisloc); |
6405
|
139 endif |
|
140 |
6758
|
141 if (strcmpi (axis_obj.ygrid, "on")) |
6809
|
142 fprintf (plot_stream, "set grid %stics;\n", yaxisloc); |
6405
|
143 else |
6809
|
144 fprintf (plot_stream, "set grid no%stics;\n", yaxisloc); |
6405
|
145 endif |
|
146 |
6758
|
147 if (strcmpi (axis_obj.zgrid, "on")) |
6405
|
148 fputs (plot_stream, "set grid ztics;\n"); |
|
149 else |
|
150 fputs (plot_stream, "set grid ztics;\n"); |
|
151 endif |
|
152 |
6758
|
153 if (strcmpi (axis_obj.xminorgrid, "on")) |
6809
|
154 fprintf (plot_stream, "set m%stics 5;\n", xaxisloc); |
|
155 fprintf (plot_stream, "set grid m%stics;\n", xaxisloc); |
6405
|
156 else |
6809
|
157 fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc); |
6405
|
158 endif |
|
159 |
6758
|
160 if (strcmpi (axis_obj.yminorgrid, "on")) |
6809
|
161 fprintf (plot_stream, "set m%stics 5;\n", yaxisloc); |
|
162 fprintf (plot_stream, "set grid m%stics;\n", yaxisloc); |
6405
|
163 else |
6809
|
164 fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc); |
6405
|
165 endif |
|
166 |
6758
|
167 if (strcmpi (axis_obj.zminorgrid, "on")) |
6405
|
168 fputs (plot_stream, "set mztics 5;\n"); |
|
169 fputs (plot_stream, "set grid mztics;\n"); |
|
170 else |
|
171 fputs (plot_stream, "set grid nomztics;\n"); |
|
172 endif |
|
173 |
6745
|
174 do_tics (axis_obj, plot_stream); |
6405
|
175 |
6758
|
176 xlogscale = strcmpi (axis_obj.xscale, "log"); |
6405
|
177 if (xlogscale) |
6809
|
178 fprintf (plot_stream, "set logscale %s;\n", xaxisloc); |
6405
|
179 else |
6809
|
180 fprintf (plot_stream, "unset logscale %s;\n", xaxisloc); |
6405
|
181 endif |
|
182 |
6758
|
183 ylogscale = strcmpi (axis_obj.yscale, "log"); |
6405
|
184 if (ylogscale) |
6809
|
185 fprintf (plot_stream, "set logscale %s;\n", yaxisloc); |
6405
|
186 else |
6809
|
187 fprintf (plot_stream, "unset logscale %s;\n", yaxisloc); |
6405
|
188 endif |
|
189 |
6758
|
190 zlogscale = strcmpi (axis_obj.zscale, "log"); |
6405
|
191 if (zlogscale) |
|
192 fputs (plot_stream, "set logscale z;\n"); |
|
193 else |
|
194 fputs (plot_stream, "unset logscale z;\n"); |
|
195 endif |
|
196 |
6758
|
197 xautoscale = strcmpi (axis_obj.xlimmode, "auto"); |
|
198 yautoscale = strcmpi (axis_obj.ylimmode, "auto"); |
|
199 zautoscale = strcmpi (axis_obj.zlimmode, "auto"); |
6405
|
200 |
|
201 kids = axis_obj.children; |
|
202 |
|
203 nd = 0; |
|
204 data_idx = 0; |
|
205 data = cell (); |
6464
|
206 is_image_data = []; |
6405
|
207 |
6453
|
208 xminp = yminp = zminp = realmax (); |
|
209 xmax = ymax = zmax = -realmax (); |
|
210 xmin = ymin = zmin = realmax (); |
6405
|
211 |
|
212 [view_cmd, view_fcn, view_zoom] = image_viewer (); |
|
213 use_gnuplot_for_images = (ischar (view_fcn) |
|
214 && strcmp (view_fcn, "gnuplot_internal")); |
|
215 |
|
216 ximg_data = {}; |
|
217 ximg_data_idx = 0; |
|
218 |
|
219 for i = 1:length (kids) |
|
220 |
|
221 obj = get (kids(i)); |
|
222 |
|
223 switch (obj.type) |
|
224 case "image" |
|
225 ## FIXME - Is there a better way to determine if the plot |
|
226 ## command should be "plot" or "splot"????? Could have images |
|
227 ## projected into 3D so there is really no reason to limit |
|
228 ## this. |
|
229 if (nd == 0) |
|
230 nd = 2; |
|
231 endif |
|
232 |
|
233 img_data = obj.cdata; |
|
234 img_colormap = parent_figure_obj.colormap; |
|
235 img_xdata = obj.xdata; |
|
236 img_ydata = obj.ydata; |
|
237 |
|
238 if (use_gnuplot_for_images) |
|
239 |
|
240 data_idx++; |
6464
|
241 is_image_data(data_idx) = true; |
6405
|
242 |
|
243 [y_dim, x_dim] = size (img_data(:,:,1)); |
|
244 if (x_dim > 1) |
|
245 dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); |
|
246 else |
|
247 dx = 1; |
|
248 endif |
|
249 if (y_dim > 1) |
|
250 dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); |
|
251 else |
|
252 dy = 1; |
|
253 endif |
|
254 x_origin = min (img_xdata); |
|
255 y_origin = min (img_ydata); |
|
256 |
|
257 if (nd == 2) |
|
258 if (xautoscale) |
|
259 xmin = min (xmin, min (img_xdata) - dx/2); |
|
260 xmax = max (xmax, max (img_xdata) + dx/2); |
|
261 xminp = min (xminp, min (img_xdata((img_xdata - dx/2)>0)) - dx/2); |
|
262 endif |
|
263 if (yautoscale) |
|
264 ymin = min (ymin, min (img_ydata) - dy/2); |
|
265 ymax = max (ymax, max (img_ydata) + dy/2); |
|
266 yminp = min (yminp, min (img_ydata((img_ydata - dy/2)>0)) - dy/2); |
|
267 endif |
|
268 else |
|
269 ## Can have images in 3D, but the image routines don't seem |
|
270 ## to have a means of arbitrary projection. |
|
271 endif |
|
272 |
|
273 if (ndims (img_data) == 3) |
6464
|
274 data{data_idx} = permute (img_data, [3, 1, 2])(:); |
6405
|
275 format = "1:2:3"; |
|
276 imagetype = "rgbimage"; |
|
277 else |
6464
|
278 data{data_idx} = img_data(:); |
6405
|
279 format = "1"; |
|
280 imagetype = "image"; |
6464
|
281 |
|
282 palette_size = rows (img_colormap); |
|
283 fprintf (plot_stream, |
|
284 "set palette positive color model RGB maxcolors %i;\n", |
|
285 palette_size); |
|
286 fprintf (plot_stream, |
|
287 "set palette file \"-\" binary record=%d using 1:2:3:4;\n", |
|
288 palette_size); |
|
289 fwrite (plot_stream, [1:palette_size; img_colormap'], "float32"); |
6405
|
290 endif |
|
291 |
6579
|
292 titlespec{data_idx} = "title \"\""; |
6420
|
293 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%g,%g) dx=%g dy=%g using %s", |
6405
|
294 x_dim, y_dim, x_origin, y_origin, dx, dy, format); |
|
295 withclause{data_idx} = sprintf ("with %s", imagetype); |
|
296 |
|
297 else |
|
298 ximg_data{++ximg_data_idx} = img_data; |
|
299 endif |
|
300 |
|
301 case "line" |
|
302 data_idx++; |
6464
|
303 is_image_data(data_idx) = false; |
6405
|
304 if (isempty (obj.keylabel)) |
|
305 titlespec{data_idx} = "title \"\""; |
|
306 else |
|
307 titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\""); |
|
308 endif |
6465
|
309 [style, typ, with] = do_linestyle_command (obj, data_idx, plot_stream); |
6405
|
310 usingclause{data_idx} = ""; |
6425
|
311 if (have_newer_gnuplot || isnan (typ)) |
|
312 withclause{data_idx} = sprintf ("with %s linestyle %d", |
|
313 style, data_idx); |
|
314 else |
|
315 withclause{data_idx} = sprintf ("with %s linetype %d", |
|
316 style, typ); |
|
317 endif |
6405
|
318 parametric(i) = true; |
|
319 if (! isempty (obj.zdata)) |
|
320 nd = 3; |
|
321 xdat = obj.xdata(:); |
|
322 ydat = obj.ydata(:); |
|
323 zdat = obj.zdata(:); |
|
324 if (xautoscale) |
6453
|
325 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); |
6405
|
326 endif |
|
327 if (yautoscale) |
6453
|
328 [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); |
6405
|
329 endif |
|
330 if (zautoscale) |
6453
|
331 [zmin, zmax, zminp] = get_data_limits (zmin, zmax, zminp, zdat); |
6405
|
332 endif |
|
333 data{data_idx} = [xdat, ydat, zdat]'; |
|
334 usingclause{data_idx} = "using ($1):($2):($3)"; |
|
335 fputs (plot_stream, "set parametric;\n"); |
|
336 fputs (plot_stream, "unset hidden3d;\n"); |
|
337 fputs (plot_stream, "set style data lines;\n"); |
|
338 fputs (plot_stream, "set surface;\n"); |
|
339 fputs (plot_stream, "unset contour;\n"); |
|
340 else |
|
341 nd = 2; |
|
342 xdat = obj.xdata(:); |
|
343 ydat = obj.ydata(:); |
|
344 ldat = obj.ldata; |
|
345 yerr = xerr = false; |
|
346 if (! isempty (ldat)) |
|
347 yerr = true; |
|
348 ldat = ldat(:); |
|
349 endif |
|
350 udat = obj.udata; |
|
351 if (! isempty (udat)) |
|
352 udat = udat(:); |
|
353 endif |
|
354 xldat = obj.xldata; |
|
355 if (! isempty (xldat)) |
|
356 xerr = true; |
|
357 xldat = xldat(:); |
|
358 endif |
|
359 xudat = obj.xudata; |
|
360 if (! isempty (xudat)) |
|
361 xudat = xudat(:); |
|
362 endif |
|
363 if (yerr) |
|
364 ylo = ydat-ldat; |
|
365 yhi = ydat+udat; |
|
366 if (yautoscale) |
|
367 ty = [ydat; ylo; yhi]; |
6453
|
368 [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ty); |
6405
|
369 endif |
|
370 if (xerr) |
|
371 xlo = xdat-xldat; |
|
372 xhi = xdat+xudat; |
|
373 if (xautoscale) |
|
374 tx = [xdat; xlo; xhi]; |
6453
|
375 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); |
6405
|
376 endif |
|
377 data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; |
|
378 usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; |
|
379 withclause{data_idx} = sprintf ("with xyerrorbars linestyle %d", |
|
380 data_idx); |
|
381 else |
6736
|
382 ## Obtain the limits based on the exact x values. |
6405
|
383 if (xautoscale) |
6453
|
384 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, |
6736
|
385 xminp, xdat); |
6405
|
386 endif |
|
387 data{data_idx} = [xdat, ydat, ylo, yhi]'; |
|
388 usingclause{data_idx} = "using ($1):($2):($3):($4)"; |
|
389 withclause{data_idx} = sprintf ("with yerrorbars linestyle %d", |
|
390 data_idx); |
|
391 endif |
|
392 elseif (xerr) |
|
393 xlo = xdat-xldat; |
|
394 xhi = xdat+xudat; |
|
395 if (xautoscale) |
|
396 tx = [xdat; xlo; xhi]; |
6453
|
397 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); |
6405
|
398 endif |
|
399 if (yautoscale) |
6453
|
400 [ymin, ymax, yminp] = get_data_limits (ymin, ymax, |
|
401 yminp, ydat, ty); |
6405
|
402 endif |
|
403 data{data_idx} = [xdat, ydat, xlo, xhi]'; |
|
404 usingclause{data_idx} = "using ($1):($2):($3):($4)"; |
|
405 withclause{data_idx} = sprintf ("with xerrorbars linestyle %d", |
|
406 data_idx); |
|
407 else |
|
408 if (xautoscale) |
6453
|
409 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); |
6405
|
410 endif |
|
411 if (yautoscale) |
6453
|
412 [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); |
6405
|
413 endif |
|
414 data{data_idx} = [xdat, ydat]'; |
6809
|
415 usingclause{data_idx} = sprintf ("using ($1):($2) axes %s%s", |
|
416 xaxisloc_using, yaxisloc_using); |
6405
|
417 endif |
|
418 endif |
6465
|
419 if (! (have_newer_gnuplot || isempty (with))) |
|
420 if (isempty (withclause{data_idx})) |
6809
|
421 withclause{data_idx} = sprintf ("with %s", with); |
6465
|
422 else |
6809
|
423 withclause{data_idx} = sprintf ("%s %s", withclause{data_idx}, |
|
424 with); |
6465
|
425 endif |
|
426 endif |
6405
|
427 |
6790
|
428 case "patch" |
|
429 if (! have_newer_gnuplot) |
|
430 warning ("patch objects require gnuplot v4.2 or later!, sorry") |
|
431 else |
|
432 if (! isempty (obj.zdata)) |
|
433 warning ("gnuplot (as of v4.2) supports only 2D patches, ignoring z values") |
|
434 endif |
|
435 nd = 2; |
|
436 cmap = parent_figure_obj.colormap; |
|
437 clim = axis_obj.clim; |
|
438 data_idx++; |
|
439 is_image_data(data_idx) = false; |
|
440 titlespec{data_idx} = "title \"\""; |
|
441 usingclause{data_idx} = ""; |
|
442 if (isfield (obj, "facecolor") && isfield (obj, "cdata")) |
|
443 if (strncmp (obj.facecolor, "none", 4)) |
|
444 color = [1, 1, 1]; |
|
445 elseif (strncmp (obj.facecolor, "flat", 4)) |
|
446 r = 1 + round ((size (cmap, 1) - 1) * (obj.cdata - clim(1))/(clim(2) - clim(1))); |
|
447 r = max (1, min (r, size (cmap, 1))); |
|
448 color = cmap(r,:); |
|
449 elseif (strncmp (obj.facecolor, "interp", 6)) |
|
450 warning ("\"interp\" not supported, using 1st entry of cdata") |
|
451 r = 1 + round ((size (cmap, 1) - 1) * obj.cdata(1)); |
|
452 r = max (1, min (r, size (cmap, 1))); |
|
453 color = cmap(r,:); |
|
454 else |
|
455 color = obj.facecolor; |
|
456 endif |
|
457 else |
|
458 color = [1, 0, 0]; |
|
459 endif |
|
460 |
|
461 withclause{data_idx} = sprintf ("with filledcurve lc rgb \"#%02x%02x%02x\"",round (255*color)); |
|
462 parametric(data_idx) = true; |
|
463 |
|
464 xdat = obj.xdata(:); |
|
465 ydat = obj.ydata(:); |
|
466 |
|
467 if (xautoscale) |
|
468 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); |
|
469 endif |
|
470 if (yautoscale) |
|
471 [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); |
|
472 endif |
|
473 data{data_idx} = [xdat, ydat]'; |
|
474 usingclause{data_idx} = "using ($1):($2)"; |
|
475 endif |
|
476 |
|
477 ## patch outline |
|
478 data_idx++; |
|
479 is_image_data(data_idx) = false; |
|
480 ## I had to use data_idx instead of i here, not sure if o.k. (Kai) |
|
481 parametric(data_idx) = true; |
|
482 titlespec{data_idx} = "title \"\""; |
|
483 usingclause{data_idx} = ""; |
|
484 if (isfield (obj, "edgecolor")) |
|
485 if (strncmp (obj.edgecolor, "none", 4)) |
|
486 color = [1, 1, 1]; |
|
487 elseif (strncmp (obj.edgecolor, "flat", 4)) |
6809
|
488 warning ("\"flat\" for edgecolor not supported"); |
6790
|
489 color = [0, 0, 0]; |
|
490 elseif (strncmp (obj.edgecolor, "interp", 6)) |
6809
|
491 warning ("\"interp\" for edgecolor not supported"); |
6790
|
492 color = [0, 0, 0]; |
|
493 else |
|
494 color = obj.edgecolor; |
|
495 endif |
|
496 else |
|
497 color = [0, 0, 0]; |
|
498 endif |
|
499 withclause{data_idx} = sprintf ("with lines lc rgb \"#%02x%02x%02x\"",round (255*color)); |
|
500 |
|
501 xdat = [xdat; xdat(1)]; |
|
502 ydat = [ydat; ydat(1)]; |
|
503 data{data_idx} = [xdat, ydat]'; |
|
504 usingclause{data_idx} = "using ($1):($2)"; |
|
505 |
6405
|
506 case "surface" |
|
507 data_idx++; |
6464
|
508 is_image_data(data_idx) = false; |
6465
|
509 [style, typ, with] = do_linestyle_command (obj, data_idx, plot_stream); |
6405
|
510 if (isempty (obj.keylabel)) |
|
511 titlespec{data_idx} = "title \"\""; |
|
512 else |
|
513 titlespec{data_idx} = strcat ("title \"", obj.keylabel, "\""); |
|
514 endif |
|
515 usingclause{data_idx} = ""; |
6425
|
516 if (have_newer_gnuplot || isnan (typ)) |
|
517 withclause{data_idx} = sprintf ("with %s linestyle %d", |
|
518 style, data_idx); |
|
519 else |
6465
|
520 withclause{data_idx} = sprintf ("with %s linetype %d %s", |
|
521 style, typ, with); |
6425
|
522 endif |
6405
|
523 parametric(i) = false; |
|
524 nd = 3; |
|
525 xdat = obj.xdata; |
|
526 ydat = obj.ydata; |
|
527 zdat = obj.zdata; |
|
528 if (xautoscale) |
|
529 tx = xdat(:); |
6453
|
530 [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); |
6405
|
531 endif |
|
532 if (yautoscale) |
|
533 ty = ydat(:); |
6453
|
534 [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ty); |
6405
|
535 endif |
|
536 if (zautoscale) |
|
537 tz = zdat(:); |
6453
|
538 [zmin, zmax, zminp] = get_data_limits (zmin, zmax, zminp, tz); |
6405
|
539 endif |
|
540 err = false; |
|
541 if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) |
|
542 if (rows (zdat) == length (ydat) && columns (zdat) == length (xdat)) |
|
543 [xdat, ydat] = meshgrid (xdat, ydat); |
|
544 else |
|
545 err = true; |
|
546 endif |
|
547 elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) |
|
548 if (! (size_equal (xdat, ydat) && size_equal (xdat, zdat))) |
|
549 err = true; |
|
550 endif |
|
551 else |
|
552 err = true; |
|
553 endif |
|
554 if (err) |
|
555 error ("__go_draw_axes__: invalid grid data"); |
|
556 endif |
|
557 xlen = columns (zdat); |
|
558 ylen = rows (zdat); |
|
559 if (xlen == columns (xdat) && xlen == columns (ydat) |
|
560 && ylen == rows (xdat) && ylen == rows (ydat)) |
|
561 len = 3 * xlen; |
|
562 zz = zeros (ylen, len); |
|
563 k = 1; |
|
564 for kk = 1:3:len |
|
565 zz(:,kk) = xdat(:,k); |
|
566 zz(:,kk+1) = ydat(:,k); |
|
567 zz(:,kk+2) = zdat(:,k); |
|
568 k++; |
|
569 endfor |
|
570 data{data_idx} = zz; |
|
571 endif |
|
572 usingclause{data_idx} = "using ($1):($2):($3)"; |
|
573 withclause{data_idx} = "with line palette"; |
|
574 |
|
575 fputs (plot_stream, "unset parametric;\n"); |
|
576 fputs (plot_stream, "set hidden3d;\n"); |
|
577 fputs (plot_stream, "set style data lines;\n"); |
|
578 fputs (plot_stream, "set surface;\n"); |
|
579 fputs (plot_stream, "unset contour;\n"); |
6788
|
580 |
|
581 if (have_newer_gnuplot) |
|
582 surf_colormap = parent_figure_obj.colormap; |
|
583 palette_size = rows (surf_colormap); |
|
584 fprintf (plot_stream, |
|
585 "set palette positive color model RGB maxcolors %i;\n", |
|
586 palette_size); |
|
587 fprintf (plot_stream, |
|
588 "set palette file \"-\" binary record=%d using 1:2:3:4;\n", |
|
589 palette_size); |
|
590 fwrite (plot_stream, [1:palette_size; surf_colormap'], "float32"); |
|
591 else |
|
592 fputs (plot_stream, "set palette defined (0 \"dark-blue\", 1 \"blue\", 2 \"cyan\", 3 \"yellow\", 4 \"red\" , 5 \"dark-red\");\n"); |
|
593 endif |
6405
|
594 fputs (plot_stream, "unset colorbox;\n"); |
|
595 |
|
596 case "text" |
|
597 lpos = obj.position; |
|
598 label = obj.string; |
|
599 halign = obj.horizontalalignment; |
6724
|
600 angle = obj.rotation; |
6752
|
601 units = obj.units; |
6829
|
602 color = obj.color; |
6758
|
603 if (strcmpi (units, "normalized")) |
6752
|
604 units = "graph"; |
|
605 else |
|
606 units = ""; |
|
607 endif |
|
608 |
6829
|
609 if (isnumeric (color)) |
|
610 if (have_newer_gnuplot) |
|
611 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"", |
|
612 round (255*color)); |
|
613 else |
|
614 if (isequal (color, [0,0,0])) |
|
615 typ = -1; |
|
616 elseif (isequal (color, [1,0,0])) |
|
617 typ = 1; |
|
618 elseif (isequal (color, [0,1,0])) |
|
619 typ = 2; |
|
620 elseif (isequal (color, [0,0,1])) |
|
621 typ = 3; |
|
622 elseif (isequal (color, [1,0,1])) |
|
623 typ = 4; |
|
624 elseif (isequal (color, [0,1,1])) |
|
625 typ = 5; |
|
626 elseif (isequal (color, [1,1,1])) |
|
627 typ = -1; |
|
628 elseif (isequal (color, [1,1,0])) |
|
629 typ = 7; |
|
630 else |
|
631 typ = -1; |
|
632 endif |
|
633 colorspec = sprintf ("textcolor lt %d", typ); |
|
634 endif |
|
635 endif |
|
636 |
6405
|
637 if (nd == 3) |
6724
|
638 fprintf (plot_stream, |
6829
|
639 "set label \"%s\" at %s %g,%g,%g %s rotate by %f %s;\n", |
6752
|
640 undo_string_escapes (label), units, |
6829
|
641 lpos(1), lpos(2), lpos(3), halign, angle, colorspec); |
6405
|
642 else |
6724
|
643 fprintf (plot_stream, |
6829
|
644 "set label \"%s\" at %s %g,%g %s rotate by %f %s;\n", |
6752
|
645 undo_string_escapes (label), units, |
6829
|
646 lpos(1), lpos(2), halign, angle, colorspec); |
6405
|
647 endif |
|
648 |
|
649 otherwise |
|
650 error ("__go_draw_axes__: unknown object class, %s", |
|
651 obj.type); |
|
652 endswitch |
|
653 |
|
654 endfor |
|
655 |
|
656 have_data = ! isempty (data); |
|
657 |
|
658 if (xautoscale && have_data) |
|
659 xlim = get_axis_limits (xmin, xmax, xminp, xlogscale); |
|
660 set (h, "xlim", xlim, "xlimmode", "auto"); |
|
661 else |
|
662 xlim = axis_obj.xlim; |
|
663 endif |
6758
|
664 if (strcmpi (axis_obj.xdir, "reverse")) |
6405
|
665 xdir = "reverse"; |
|
666 else |
|
667 xdir = "noreverse"; |
|
668 endif |
6809
|
669 fprintf (plot_stream, "set %srange [%g:%g] %s;\n", xaxisloc, xlim, xdir); |
6405
|
670 |
|
671 if (yautoscale && have_data) |
|
672 ylim = get_axis_limits (ymin, ymax, yminp, ylogscale); |
|
673 set (h, "ylim", ylim, "ylimmode", "auto"); |
|
674 else |
|
675 ylim = axis_obj.ylim; |
|
676 endif |
6758
|
677 if (strcmpi (axis_obj.ydir, "reverse")) |
6405
|
678 ydir = "reverse"; |
|
679 else |
|
680 ydir = "noreverse"; |
|
681 endif |
6809
|
682 fprintf (plot_stream, "set %srange [%g:%g] %s;\n", yaxisloc, ylim, ydir); |
6405
|
683 |
|
684 if (nd == 3) |
|
685 if (zautoscale && have_data) |
|
686 zlim = get_axis_limits (zmin, zmax, zminp, zlogscale); |
|
687 set (h, "zlim", zlim, "zlimmode", "auto"); |
|
688 else |
|
689 zlim = axis_obj.zlim; |
|
690 endif |
6758
|
691 if (strcmpi (axis_obj.zdir, "reverse")) |
6405
|
692 zdir = "reverse"; |
|
693 else |
|
694 zdir = "noreverse"; |
|
695 endif |
|
696 fprintf (plot_stream, "set zrange [%g:%g] %s;\n", zlim, zdir); |
|
697 endif |
|
698 |
6758
|
699 if (strcmpi (axis_obj.box, "on")) |
6405
|
700 if (nd == 3) |
|
701 fputs (plot_stream, "set border 4095;\n"); |
|
702 else |
|
703 fputs (plot_stream, "set border 431;\n"); |
|
704 endif |
|
705 else |
|
706 if (nd == 3) |
|
707 fputs (plot_stream, "set border 895;\n"); |
|
708 else |
|
709 fputs (plot_stream, "set border 3;\n"); |
|
710 fputs (plot_stream, "set xtics nomirror; set ytics nomirror;\n"); |
|
711 endif |
|
712 endif |
|
713 |
6758
|
714 if (strcmpi (axis_obj.key, "on")) |
|
715 if (strcmpi (axis_obj.keybox, "on")) |
6405
|
716 box = "box"; |
|
717 else |
|
718 box = "nobox"; |
|
719 endif |
|
720 inout = "inside"; |
|
721 switch (axis_obj.keypos) |
|
722 case -1 |
|
723 pos = "right bottom"; |
|
724 inout = "outside"; |
|
725 case 1 |
|
726 pos = "right top"; |
|
727 case 2 |
|
728 pos = "left top"; |
|
729 case 3 |
|
730 pos = "left bottom"; |
|
731 case 4 |
|
732 pos = "right bottom"; |
|
733 otherwise |
|
734 pos = ""; |
|
735 endswitch |
|
736 if (! have_newer_gnuplot) |
|
737 inout = ""; |
|
738 endif |
|
739 fprintf (plot_stream, "set key %s %s %s;\n", inout, pos, box); |
|
740 else |
|
741 fputs (plot_stream, "unset key;\n"); |
|
742 endif |
|
743 |
|
744 fputs (plot_stream, "set style data lines;\n"); |
|
745 |
|
746 if (! use_gnuplot_for_images) |
|
747 for i = 1:ximg_data_idx |
|
748 view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd); |
|
749 endfor |
|
750 endif |
|
751 |
|
752 if (have_data) |
|
753 |
|
754 if (nd == 2) |
|
755 plot_cmd = "plot"; |
|
756 else |
|
757 plot_cmd = "splot"; |
|
758 rot_x = 90 - axis_obj.view(2); |
|
759 rot_z = axis_obj.view(1); |
|
760 while (rot_z < 0) |
|
761 rot_z += 360; |
|
762 endwhile |
6461
|
763 fputs (plot_stream, "set ticslevel 0;\n"); |
6405
|
764 fprintf (plot_stream, "set view %g, %g;\n", rot_x, rot_z); |
|
765 endif |
6611
|
766 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
6464
|
767 usingclause{1}, titlespec{1}, withclause{1}); |
6405
|
768 for i = 2:data_idx |
6611
|
769 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", |
6464
|
770 usingclause{i}, titlespec{i}, withclause{i}); |
6405
|
771 endfor |
|
772 fputs (plot_stream, ";\n"); |
|
773 for i = 1:data_idx |
6464
|
774 if (is_image_data(i)) |
|
775 fwrite (plot_stream, data{i}, "float32"); |
|
776 else |
6510
|
777 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i)); |
6405
|
778 endif |
|
779 endfor |
6431
|
780 else |
|
781 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n"); |
6405
|
782 endif |
|
783 |
|
784 fflush (plot_stream); |
|
785 |
|
786 else |
|
787 print_usage (); |
|
788 endif |
|
789 |
|
790 endfunction |
|
791 |
6453
|
792 function [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat, tx) |
|
793 xdat = xdat(! isinf (xdat)); |
|
794 xmin = min (xmin, min (xdat)); |
|
795 xmax = max (xmax, max (xdat)); |
|
796 if (nargin == 5) |
|
797 tx = tx(! isinf (xdat) & tx > 0); |
|
798 xminp = min (xminp, min (tx)); |
|
799 else |
|
800 xminp = min (xminp, min (xdat(xdat>0))); |
|
801 endif |
|
802 endfunction |
|
803 |
6405
|
804 ## Attempt to make "nice" limits from the actual max and min of the |
|
805 ## data. For log plots, we will also use the smallest strictly positive |
|
806 ## value. |
|
807 |
|
808 function lim = get_axis_limits (min_val, max_val, min_pos, logscale) |
|
809 |
|
810 if (logscale) |
|
811 if (isinf (min_pos)) |
|
812 warning ("axis: logscale with no positive values to plot"); |
|
813 endif |
6527
|
814 if (min_val <= 0) |
6405
|
815 min_val = min_pos; |
6527
|
816 if (max_val <= 0) |
6405
|
817 max_val = min_pos; |
|
818 endif |
6527
|
819 warning ("axis: omitting nonpositive data in log plot"); |
6405
|
820 endif |
6512
|
821 ## FIXME -- maybe this test should also be relative? |
|
822 if (abs (min_val - max_val) < sqrt (eps)) |
|
823 min_val *= 0.9; |
|
824 max_val *= 1.1; |
6405
|
825 endif |
|
826 min_val = 10 ^ floor (log10 (min_val)); |
|
827 max_val = 10 ^ ceil (log10 (max_val)); |
|
828 else |
|
829 if (min_val == 0 && max_val == 0) |
|
830 min_val = -1; |
|
831 max_val = 1; |
6512
|
832 ## FIXME -- maybe this test should also be relative? |
|
833 elseif (abs (min_val - max_val) < sqrt (eps)) |
|
834 min_val -= 0.1 * abs (min_val); |
|
835 max_val += 0.1 * abs (max_val); |
6405
|
836 endif |
|
837 ## FIXME -- to do a better job, we should consider the tic spacing. |
|
838 scale = 10 ^ floor (log10 (max_val - min_val) - 1); |
|
839 min_val = scale * floor (min_val / scale); |
|
840 max_val = scale * ceil (max_val / scale); |
|
841 endif |
|
842 |
|
843 lim = [min_val, max_val]; |
|
844 |
|
845 endfunction |
|
846 |
6465
|
847 function [style, typ, with] = do_linestyle_command (obj, idx, plot_stream) |
6405
|
848 |
6413
|
849 persistent have_newer_gnuplot ... |
|
850 = compare_versions (__gnuplot_version__ (), "4.0", ">"); |
6405
|
851 |
|
852 if (have_newer_gnuplot) |
|
853 fprintf (plot_stream, "set style line %d default;\n", idx); |
|
854 endif |
|
855 fprintf (plot_stream, "set style line %d", idx); |
|
856 |
|
857 found_style = false; |
6425
|
858 typ = NaN; |
6465
|
859 with = ""; |
6405
|
860 |
6425
|
861 if (isfield (obj, "color")) |
6405
|
862 color = obj.color; |
|
863 if (isnumeric (color)) |
6425
|
864 if (have_newer_gnuplot) |
|
865 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", |
|
866 round (255*color)); |
|
867 else |
|
868 if (isequal (color, [0,0,0])) |
|
869 typ = -1; |
|
870 elseif (isequal (color, [1,0,0])) |
|
871 typ = 1; |
|
872 elseif (isequal (color, [0,1,0])) |
|
873 typ = 2; |
|
874 elseif (isequal (color, [0,0,1])) |
|
875 typ = 3; |
|
876 elseif (isequal (color, [1,0,1])) |
|
877 typ = 4; |
|
878 elseif (isequal (color, [0,1,1])) |
|
879 typ = 5; |
|
880 elseif (isequal (color, [1,1,1])) |
|
881 typ = 6; |
|
882 elseif (isequal (color, [1,1,0])) |
|
883 typ = 7; |
|
884 else |
|
885 typ = 2; |
|
886 endif |
|
887 endif |
6405
|
888 endif |
|
889 found_style = true; |
|
890 endif |
|
891 |
|
892 if (isfield (obj, "linestyle")) |
|
893 switch (obj.linestyle) |
|
894 case "-" |
6415
|
895 lt = "1"; |
6405
|
896 case "--" |
6415
|
897 lt = "2"; |
6405
|
898 case ":" |
6415
|
899 lt = "3"; |
6405
|
900 case "-." |
6415
|
901 lt = "6"; |
6405
|
902 case "none" |
|
903 lt = ""; |
|
904 otherwise |
|
905 lt = ""; |
|
906 endswitch |
6843
|
907 |
|
908 ## FIXME -- linetype is currently broken, since it disables the |
|
909 ## gnuplot default dashed and solid linestyles with the only |
|
910 ## benefit of being able to specify '--' and get a single sized |
|
911 ## dashed line of identical dash pattern for all called this way. |
|
912 ## All dash patterns are a subset of "with lines" and none of the |
|
913 ## lt specifications will correctly propagate into the x11 terminal |
|
914 ## or the print command. Therefore, it is currently disabled in |
|
915 ## order to allow print (..., "-dashed") etc. to work correctly. |
|
916 |
|
917 ## if (! isempty (lt)) |
|
918 ## fprintf (plot_stream, " linetype %s", lt); |
|
919 ## found_style = true; |
|
920 ## endif |
|
921 |
6405
|
922 else |
|
923 lt = ""; |
|
924 endif |
|
925 |
|
926 if (isfield (obj, "linewidth")) |
6465
|
927 if (have_newer_gnuplot) |
|
928 fprintf (plot_stream, " linewidth %f", obj.linewidth); |
|
929 else |
|
930 with = sprintf ("%s lw %f", with, obj.linewidth); |
|
931 endif |
6405
|
932 found_style = true; |
|
933 endif |
|
934 |
|
935 if (isfield (obj, "marker")) |
|
936 switch (obj.marker) |
|
937 case "+" |
|
938 pt = "1"; |
|
939 case "o" |
6413
|
940 pt = "6"; |
6405
|
941 case "*" |
|
942 pt = "3"; |
|
943 case "." |
6413
|
944 pt = "7"; |
6405
|
945 case "x" |
|
946 pt = "2"; |
|
947 case {"square", "s"} |
|
948 pt = "5"; |
|
949 case {"diamond", "d"} |
|
950 pt = "13"; |
|
951 case "^" |
|
952 pt = "9"; |
|
953 case "v" |
|
954 pt = "11"; |
|
955 case ">" |
|
956 pt = "8"; |
|
957 case "<" |
|
958 pt = "10"; |
|
959 case {"pentagram", "p"} |
|
960 pt = "4"; |
|
961 case {"hexagram", "h"} |
6413
|
962 pt = "12"; |
6405
|
963 case "none" |
|
964 pt = ""; |
|
965 otherwise |
|
966 pt = ""; |
|
967 endswitch |
|
968 if (! isempty (pt)) |
6465
|
969 if (have_newer_gnuplot) |
|
970 fprintf (plot_stream, " pointtype %s", pt); |
|
971 else |
|
972 with = sprintf ("%s pt %s", with, pt); |
|
973 endif |
6405
|
974 found_style = true; |
|
975 endif |
|
976 else |
|
977 pt = ""; |
|
978 endif |
|
979 |
|
980 style = "lines"; |
|
981 if (isempty (lt)) |
|
982 if (! isempty (pt)) |
|
983 style = "points"; |
|
984 endif |
|
985 elseif (! isempty (pt)) |
|
986 style = "linespoints"; |
|
987 endif |
|
988 |
6465
|
989 if (isfield (obj, "markersize")) |
|
990 if (have_newer_gnuplot) |
|
991 fprintf (plot_stream, " pointsize %f", obj.markersize); |
|
992 else |
6758
|
993 if (! strcmpi (style, "lines")) |
6465
|
994 with = sprintf ("%s ps %f", with, obj.markersize); |
|
995 endif |
|
996 endif |
|
997 found_style = true; |
|
998 endif |
|
999 |
6405
|
1000 if (have_newer_gnuplot && ! found_style) |
|
1001 fputs (plot_stream, " default"); |
|
1002 endif |
|
1003 |
|
1004 fputs (plot_stream, ";\n"); |
|
1005 |
|
1006 endfunction |
6510
|
1007 |
|
1008 function __gnuplot_write_data__ (plot_stream, data, nd, parametric) |
|
1009 |
|
1010 ## DATA is already transposed. |
|
1011 |
|
1012 ## FIXME -- this may need to be converted to C++ for speed. |
|
1013 |
6605
|
1014 ## Convert NA elements to normal NaN values because fprintf writes |
|
1015 ## "NA" and that confuses gnuplot. |
|
1016 idx = find (isna (data)); |
|
1017 if (any (idx)) |
|
1018 data(idx) = NaN; |
|
1019 endif |
|
1020 |
6510
|
1021 if (nd == 2) |
|
1022 nan_elts = find (sum (isnan (data))); |
|
1023 fmt = strcat (repmat ("%g ", 1, rows (data)), "\n"); |
|
1024 if (isempty (nan_elts)) |
|
1025 fprintf (plot_stream, fmt, data); |
|
1026 else |
|
1027 n = columns (data); |
|
1028 have_nans = true; |
|
1029 num_nan_elts = numel (nan_elts); |
|
1030 k = 1; |
|
1031 for i = 1:n |
|
1032 if (have_nans && i == nan_elts(k)) |
|
1033 fputs (plot_stream, "\n"); |
|
1034 have_nans = ++k <= num_nan_elts; |
|
1035 else |
|
1036 fprintf (plot_stream, fmt, data(:,i)); |
|
1037 endif |
|
1038 endfor |
|
1039 endif |
|
1040 else |
|
1041 ## FIXME -- handle NaNs here too? |
|
1042 if (parametric) |
|
1043 fprintf (plot_stream, "%g %g %g\n", data); |
|
1044 else |
|
1045 nc = columns (data); |
|
1046 for j = 1:3:nc |
|
1047 fprintf (plot_stream, "%g %g %g\n", data(:,j:j+2)'); |
|
1048 fputs (plot_stream, "\n"); |
|
1049 endfor |
|
1050 endif |
|
1051 endif |
|
1052 fputs (plot_stream, "e\n"); |
|
1053 |
|
1054 endfunction |
6745
|
1055 |
|
1056 function do_tics (obj, plot_stream) |
6809
|
1057 if (strcmpi (obj.xaxislocation, "top")) |
|
1058 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, |
|
1059 "x2", plot_stream); |
|
1060 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
|
1061 "x", plot_stream); |
|
1062 else |
|
1063 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, |
|
1064 "x", plot_stream); |
|
1065 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
|
1066 "x2", plot_stream); |
|
1067 endif |
|
1068 if (strcmpi (obj.yaxislocation, "right")) |
|
1069 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, |
|
1070 "y2", plot_stream); |
|
1071 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
|
1072 "y", plot_stream); |
|
1073 else |
|
1074 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, |
|
1075 "y", plot_stream); |
|
1076 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
|
1077 "y2", plot_stream); |
|
1078 endif |
6745
|
1079 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, |
|
1080 "z", plot_stream); |
|
1081 endfunction |
|
1082 |
|
1083 function do_tics_1 (ticmode, tics, labelmode, labels, ax, plot_stream) |
6758
|
1084 if (strcmpi (ticmode, "manual")) |
6745
|
1085 if (isempty (tics)) |
|
1086 fprintf (plot_stream, "unset %stics;\n", ax); |
6758
|
1087 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) |
6751
|
1088 if (ischar (labels)) |
|
1089 labels = cellstr (labels); |
|
1090 endif |
6745
|
1091 if (iscellstr (labels)) |
6751
|
1092 k = 1; |
|
1093 ntics = numel (tics); |
|
1094 nlabels = numel (labels); |
6745
|
1095 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
|
1096 fprintf (plot_stream, "set %stics (", ax); |
|
1097 for i = 1:ntics |
|
1098 fprintf (plot_stream, " \"%s\" %g", labels(k++), tics(i)) |
|
1099 if (i < ntics) |
|
1100 fputs (plot_stream, ", "); |
|
1101 endif |
|
1102 if (k > nlabels) |
|
1103 k = 1; |
|
1104 endif |
|
1105 endfor |
|
1106 fputs (plot_stream, ");\n"); |
|
1107 else |
|
1108 error ("unsupported type of ticklabel"); |
|
1109 endif |
|
1110 else |
|
1111 fprintf (plot_stream, "set %stics (", ax); |
6748
|
1112 fprintf (plot_stream, " %g,", tics(1:end-1)); |
|
1113 fprintf (plot_stream, " %g);\n", tics(end)); |
6745
|
1114 endif |
|
1115 else |
|
1116 fprintf (plot_stream, "set %stics;\n", ax); |
|
1117 endif |
|
1118 endfunction |