comparison scripts/plot/private/__go_draw_axes__.m @ 12793:6f91ca83d2be

codesprint : Make many plot helper functions private. * plot/module.mk : Update where to find files for Automake *__fltk_ginput__.m, __fltk_print__.m, __gnuplot_drawnow__.m, __gnuplot_get_var__.m, __gnuplot_ginput__.m, __gnuplot_has_feature__.m, __gnuplot_open_stream__.m, __gnuplot_print__.m, __gnuplot_version__.m, __go_draw_axes__.m, __go_draw_figure__.m, __marching_cube__.m, __next_line_color__.m, __next_line_style__.m, __print_parse_opts__.m: Move helper functions into plot/private/ directory.
author Rik <octave@nomad.inbox5.com>
date Sat, 16 Jul 2011 09:28:26 -0700
parents scripts/plot/__go_draw_axes__.m@bedd0cdb3584
children cefd568ea073
comparison
equal deleted inserted replaced
12792:dc29b64668fa 12793:6f91ca83d2be
1 ## Copyright (C) 2005-2011 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 3 of the License, or (at
8 ## your option) 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, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} __go_draw_axes__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
21 ## Undocumented internal function.
22 ## @end deftypefn
23
24 ## Author: jwe
25
26 function __go_draw_axes__ (h, plot_stream, enhanced, mono,
27 bg_is_set, fg_is_set, hlgnd)
28
29 if (nargin >= 4 && nargin <= 7)
30
31 showhiddenhandles = get (0, "showhiddenhandles");
32 unwind_protect
33 set (0, "showhiddenhandles", "on");
34 axis_obj = __get__ (h);
35 unwind_protect_cleanup
36 set (0, "showhiddenhandles", showhiddenhandles);
37 end_unwind_protect
38
39 parent_figure_obj = get (axis_obj.parent);
40 gnuplot_term = __gnuplot_get_var__ (axis_obj.parent, "GPVAL_TERM");
41
42 ## Set to false for plotyy axes.
43 if (strcmp (axis_obj.tag, "plotyy"))
44 ymirror = false;
45 else
46 ymirror = true;
47 endif
48
49 nd = __calc_dimensions__ (h);
50
51 if (strcmp (axis_obj.dataaspectratiomode, "manual")
52 && strcmp (axis_obj.xlimmode, "manual")
53 && strcmp (axis_obj.ylimmode, "manual"))
54 ## All can't be "manual"
55 axis_obj.plotboxaspectratiomode = "auto";
56 endif
57
58 if (strcmp (axis_obj.dataaspectratiomode, "manual")
59 && strcmp (axis_obj.xlimmode, "manual")
60 && strcmp (axis_obj.ylimmode, "manual")
61 && (nd == 2 || all (mod (axis_obj.view, 90) == 0)))
62 ## FIXME - adjust plotboxaspectratio to respect other
63 fpos = get (axis_obj.parent, "position");
64 apos = axis_obj.position;
65 endif
66
67 pos = __actual_axis_position__ (h);
68
69 if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
70 dr = axis_obj.dataaspectratio;
71 if (nd == 2 || all (mod (axis_obj.view, 90) == 0))
72 dr = dr(1) / dr(2);
73 else
74 ## FIXME - need to properly implement 3D
75 dr = mean (dr(1:2)) / dr(3);
76 endif
77 else
78 dr = 1;
79 endif
80
81 if (strcmp (axis_obj.activepositionproperty, "position"))
82 if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
83 if (nd == 2 || all (mod (axis_obj.view, 90) == 0))
84 x = [1, 1];
85 else
86 ## 3D plots need to be sized down to fit in the window.
87 x = 1.0 ./ sqrt([2, 2.5]);
88 endif
89 fprintf (plot_stream, "set tmargin screen %.15g;\n",
90 pos(2)+pos(4)/2+x(2)*pos(4)/2);
91 fprintf (plot_stream, "set bmargin screen %.15g;\n",
92 pos(2)+pos(4)/2-x(2)*pos(4)/2);
93 fprintf (plot_stream, "set lmargin screen %.15g;\n",
94 pos(1)+pos(3)/2-x(1)*pos(3)/2);
95 fprintf (plot_stream, "set rmargin screen %.15g;\n",
96 pos(1)+pos(3)/2+x(1)*pos(3)/2);
97 sz_str = "";
98 else
99 fprintf (plot_stream, "set tmargin 0;\n");
100 fprintf (plot_stream, "set bmargin 0;\n");
101 fprintf (plot_stream, "set lmargin 0;\n");
102 fprintf (plot_stream, "set rmargin 0;\n");
103
104 if (nd == 3 && all (axis_obj.view == [0, 90]))
105 ## FIXME -- Kludge to allow colorbar to be added to a pcolor() plot
106 pos(3:4) = pos(3:4) * 1.4;
107 pos(1:2) = pos(1:2) - pos(3:4) * 0.125;
108 endif
109
110 fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
111
112 if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
113 sz_str = sprintf ("set size ratio %.15g", -dr);
114 else
115 sz_str = "set size noratio";
116 endif
117 sz_str = sprintf ("%s %.15g, %.15g;\n", sz_str, pos(3), pos(4));
118 endif
119 else ## activepositionproperty == outerposition
120 fprintf (plot_stream, "unset tmargin;\n");
121 fprintf (plot_stream, "unset bmargin;\n");
122 fprintf (plot_stream, "unset lmargin;\n");
123 fprintf (plot_stream, "unset rmargin;\n");
124 fprintf (plot_stream, "set origin %g, %g;\n", pos(1:2));
125 sz_str = "";
126 if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
127 sz_str = sprintf ("ratio %g", -dr);
128 else
129 sz_str = "noratio";
130 endif
131 sz_str = sprintf ("set size %s %g, %g;\n", sz_str, pos(3:4));
132 endif
133 if (! isempty (sz_str))
134 fputs (plot_stream, sz_str);
135 endif
136
137 ## Reset all labels, axis-labels, tick-labels, and title
138 ## FIXME - We should have an function to initialize the axis.
139 ## Presently, this is dispersed in this function.
140 fputs (plot_stream, "unset label;\n");
141 fputs (plot_stream, "unset xtics;\n");
142 fputs (plot_stream, "unset ytics;\n");
143 fputs (plot_stream, "unset ztics;\n");
144 fputs (plot_stream, "unset x2tics;\n");
145 fputs (plot_stream, "unset x2tics;\n");
146
147 if (! isempty (axis_obj.title))
148 t = get (axis_obj.title);
149 if (isempty (t.string))
150 fputs (plot_stream, "unset title;\n");
151 else
152 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
153 fontspec = create_fontspec (f, s, gnuplot_term);
154 fprintf (plot_stream, "set title \"%s\" %s %s;\n",
155 undo_string_escapes (tt), fontspec,
156 __do_enhanced_option__ (enhanced, t));
157 endif
158 endif
159
160 if (! isempty (axis_obj.xlabel))
161 t = get (axis_obj.xlabel);
162 angle = t.rotation;
163 colorspec = get_text_colorspec (axis_obj.xcolor, mono);
164 if (isempty (t.string))
165 fprintf (plot_stream, "unset xlabel;\n");
166 fprintf (plot_stream, "unset x2label;\n");
167 else
168 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
169 fontspec = create_fontspec (f, s, gnuplot_term);
170 if (strcmpi (axis_obj.xaxislocation, "top"))
171 fprintf (plot_stream, "set x2label \"%s\" %s %s %s",
172 undo_string_escapes (tt), colorspec, fontspec,
173 __do_enhanced_option__ (enhanced, t));
174 else
175 fprintf (plot_stream, "set xlabel \"%s\" %s %s %s",
176 undo_string_escapes (tt), colorspec, fontspec,
177 __do_enhanced_option__ (enhanced, t));
178 endif
179 fprintf (plot_stream, " rotate by %f;\n", angle);
180 if (strcmpi (axis_obj.xaxislocation, "top"))
181 fprintf (plot_stream, "unset xlabel;\n");
182 else
183 fprintf (plot_stream, "unset x2label;\n");
184 endif
185 endif
186 endif
187
188 if (! isempty (axis_obj.ylabel))
189 t = get (axis_obj.ylabel);
190 angle = t.rotation;
191 colorspec = get_text_colorspec (axis_obj.ycolor, mono);
192 if (isempty (t.string))
193 fprintf (plot_stream, "unset ylabel;\n");
194 fprintf (plot_stream, "unset y2label;\n");
195 else
196 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
197 fontspec = create_fontspec (f, s, gnuplot_term);
198 if (strcmpi (axis_obj.yaxislocation, "right"))
199 fprintf (plot_stream, "set y2label \"%s\" %s %s %s",
200 undo_string_escapes (tt), colorspec, fontspec,
201 __do_enhanced_option__ (enhanced, t));
202 else
203 fprintf (plot_stream, "set ylabel \"%s\" %s %s %s",
204 undo_string_escapes (tt), colorspec, fontspec,
205 __do_enhanced_option__ (enhanced, t));
206 endif
207 fprintf (plot_stream, " rotate by %f;\n", angle);
208 if (strcmpi (axis_obj.yaxislocation, "right"))
209 fprintf (plot_stream, "unset ylabel;\n");
210 else
211 fprintf (plot_stream, "unset y2label;\n");
212 endif
213 endif
214 endif
215
216 if (! isempty (axis_obj.zlabel))
217 t = get (axis_obj.zlabel);
218 angle = t.rotation;
219 colorspec = get_text_colorspec (axis_obj.zcolor, mono);
220 if (isempty (t.string))
221 fputs (plot_stream, "unset zlabel;\n");
222 else
223 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
224 fontspec = create_fontspec (f, s, gnuplot_term);
225 fprintf (plot_stream, "set zlabel \"%s\" %s %s %s",
226 undo_string_escapes (tt), colorspec, fontspec,
227 __do_enhanced_option__ (enhanced, t));
228 fprintf (plot_stream, " rotate by %f;\n", angle);
229 endif
230 endif
231
232 if (strcmpi (axis_obj.xaxislocation, "top"))
233 xaxisloc = "x2";
234 xaxisloc_using = "x2";
235 else
236 xaxisloc = "x";
237 xaxisloc_using = "x1";
238 if (strcmpi (axis_obj.xaxislocation, "zero"))
239 fputs (plot_stream, "set xzeroaxis;\n");
240 endif
241 endif
242 if (strcmpi (axis_obj.yaxislocation, "right"))
243 yaxisloc = "y2";
244 yaxisloc_using = "y2";
245 else
246 yaxisloc = "y";
247 yaxisloc_using = "y1";
248 if (strcmpi (axis_obj.yaxislocation, "zero"))
249 fputs (plot_stream, "set yzeroaxis;\n");
250 endif
251 endif
252
253 have_grid = false;
254
255 if (strcmpi (axis_obj.xgrid, "on"))
256 have_grid = true;
257 fprintf (plot_stream, "set grid %stics;\n", xaxisloc);
258 else
259 fprintf (plot_stream, "set grid no%stics;\n", xaxisloc);
260 endif
261
262 if (strcmpi (axis_obj.ygrid, "on"))
263 have_grid = true;
264 fprintf (plot_stream, "set grid %stics;\n", yaxisloc);
265 else
266 fprintf (plot_stream, "set grid no%stics;\n", yaxisloc);
267 endif
268
269 if (strcmpi (axis_obj.zgrid, "on"))
270 have_grid = true;
271 fputs (plot_stream, "set grid ztics;\n");
272 else
273 fputs (plot_stream, "set grid noztics;\n");
274 endif
275
276 if (strcmpi (axis_obj.xminorgrid, "on"))
277 have_grid = true;
278 if (strcmp (axis_obj.xscale, "log"))
279 m = 10;
280 else
281 m = 5;
282 endif
283 fprintf (plot_stream, "set m%stics %d;\n", xaxisloc, m);
284 fprintf (plot_stream, "set grid m%stics;\n", xaxisloc);
285 else
286 fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc);
287 endif
288
289 if (strcmpi (axis_obj.yminorgrid, "on"))
290 have_grid = true;
291 if (strcmp (axis_obj.yscale, "log"))
292 m = 10;
293 else
294 m = 5;
295 endif
296 fprintf (plot_stream, "set m%stics %d;\n", yaxisloc, m);
297 fprintf (plot_stream, "set grid m%stics;\n", yaxisloc);
298 else
299 fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc);
300 endif
301
302 if (strcmpi (axis_obj.zminorgrid, "on"))
303 have_grid = true;
304 if (strcmp (axis_obj.zscale, "log"))
305 m = 10;
306 else
307 m = 5;
308 endif
309 fprintf (plot_stream, "set mztics %d;\n", m);
310 fputs (plot_stream, "set grid mztics;\n");
311 else
312 fputs (plot_stream, "set grid nomztics;\n");
313 endif
314
315 ## The grid front/back/layerdefault option also controls the
316 ## appearance of tics, so it is used even if the grid is absent.
317 if (strcmpi (axis_obj.layer, "top"))
318 fputs (plot_stream, "set grid front;\n");
319 fputs (plot_stream, "set border front;\n");
320 else
321 fputs (plot_stream, "set grid layerdefault;\n");
322 ## FIXME -- the gnuplot help says that "layerdefault" should work
323 ## for set border too, but it fails for me with gnuplot 4.2.5. So
324 ## use "back" instead.
325 fputs (plot_stream, "set border back;\n");
326 endif
327
328 fprintf (plot_stream, "set grid linewidth %f, linewidth %f;\n",
329 axis_obj.linewidth, axis_obj.linewidth);
330
331 if (! have_grid)
332 fputs (plot_stream, "unset grid;\n");
333 endif
334
335 do_tics (axis_obj, plot_stream, ymirror, mono, gnuplot_term);
336
337 fputs (plot_stream, "unset logscale;\n");
338 xlogscale = strcmpi (axis_obj.xscale, "log");
339 ylogscale = strcmpi (axis_obj.yscale, "log");
340 zlogscale = strcmpi (axis_obj.zscale, "log");
341 if (xlogscale)
342 fprintf (plot_stream, "set logscale %s;\n", xaxisloc);
343 endif
344 if (ylogscale)
345 fprintf (plot_stream, "set logscale %s;\n", yaxisloc);
346 endif
347 if (zlogscale)
348 fputs (plot_stream, "set logscale z;\n");
349 endif
350
351 xautoscale = strcmpi (axis_obj.xlimmode, "auto");
352 yautoscale = strcmpi (axis_obj.ylimmode, "auto");
353 zautoscale = strcmpi (axis_obj.zlimmode, "auto");
354 cautoscale = strcmpi (axis_obj.climmode, "auto");
355 cdatadirect = false;
356 truecolor = false;
357
358 fputs (plot_stream, "set clip two;\n");
359
360 kids = axis_obj.children;
361 ## Remove the axis labels and title from the children, and
362 ## preserved the original order.
363 [jnk, k] = setdiff (kids, [axis_obj.xlabel; axis_obj.ylabel; ...
364 axis_obj.zlabel; axis_obj.title]);
365 kids = kids (sort (k));
366
367 if (nd == 3)
368 fputs (plot_stream, "set parametric;\n");
369 fputs (plot_stream, "set style data lines;\n");
370 fputs (plot_stream, "set surface;\n");
371 fputs (plot_stream, "unset contour;\n");
372 endif
373
374 data_idx = 0;
375 data = cell ();
376 is_image_data = [];
377 hidden_removal = NaN;
378 view_map = false;
379
380 xlim = axis_obj.xlim;
381 ylim = axis_obj.ylim;
382 zlim = axis_obj.zlim;
383 clim = axis_obj.clim;
384
385 if (! cautoscale && clim(1) == clim(2))
386 clim(2)++;
387 endif
388 addedcmap = [];
389
390 ximg_data = {};
391 ximg_data_idx = 0;
392
393 while (! isempty (kids))
394
395 obj = get (kids(end));
396 if (isfield (obj, "units"))
397 units = obj.units;
398 unwind_protect
399 set (kids(end), "units", "data");
400 obj = get (kids(end));
401 unwind_protect_cleanup
402 set (kids(end), "units", units);
403 end_unwind_protect
404 endif
405 kids = kids(1:(end-1));
406
407 if (strcmpi (obj.visible, "off"))
408 continue;
409 endif
410
411 if (xlogscale && isfield (obj, "xdata"))
412 obj.xdata(obj.xdata<=0) = NaN;
413 endif
414 if (ylogscale && isfield (obj, "ydata"))
415 obj.ydata(obj.ydata<=0) = NaN;
416 endif
417 if (zlogscale && isfield (obj, "zdata"))
418 obj.zdata(obj.zdata<=0) = NaN;
419 endif
420
421 ## Check for facecolor interpolation for surfaces.
422 doing_interp_color = ...
423 isfield (obj, "facecolor") && strncmp (obj.facecolor, "interp", 6);
424
425 switch (obj.type)
426 case "image"
427 img_data = obj.cdata;
428 img_xdata = obj.xdata;
429 img_ydata = obj.ydata;
430
431 if (ndims (img_data) == 3)
432 truecolor = true;
433 elseif (strcmpi (obj.cdatamapping, "direct"))
434 cdatadirect = true;
435 endif
436 data_idx++;
437 is_image_data(data_idx) = true;
438 parametric(data_idx) = false;
439 have_cdata(data_idx) = false;
440 have_3d_patch(data_idx) = false;
441
442 if (img_xdata(2) < img_xdata(1))
443 img_xdata = img_xdata(2:-1:1);
444 img_data = img_data(:,end:-1:1,:);
445 elseif (img_xdata(1) == img_xdata(2))
446 img_xdata = img_xdata(1) + [0, size(img_data,2)-1];
447 endif
448 if (img_ydata(2) < img_ydata(1))
449 img_ydata = img_ydata(2:-1:1);
450 img_data = img_data(end:-1:1,:,:);
451 elseif (img_ydata(1) == img_ydata(2))
452 img_ydata = img_ydata(1) + [0, size(img_data,1)-1];
453 endif
454
455 [y_dim, x_dim] = size (img_data(:,:,1));
456 if (x_dim > 1)
457 dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1);
458 else
459 x_dim = 2;
460 img_data = [img_data, img_data];
461 dx = abs (img_xdata(2)-img_xdata(1));
462 endif
463 if (y_dim > 1)
464 dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1);
465 else
466 y_dim = 2;
467 img_data = [img_data; img_data];
468 dy = abs (img_ydata(2)-img_ydata(1));
469 endif
470
471 x_origin = min (img_xdata);
472 y_origin = min (img_ydata);
473
474 if (ndims (img_data) == 3)
475 data{data_idx} = permute (img_data, [3, 1, 2])(:);
476 format = "1:2:3";
477 imagetype = "rgbimage";
478 else
479 data{data_idx} = img_data(:);
480 format = "1";
481 imagetype = "image";
482 endif
483
484 titlespec{data_idx} = "title \"\"";
485 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s",
486 x_dim, y_dim, x_origin, y_origin, dx, dy, format);
487 withclause{data_idx} = sprintf ("with %s;", imagetype);
488
489 case "line"
490 if (strncmp (obj.linestyle, "none", 4)
491 && (! isfield (obj, "marker")
492 || (isfield (obj, "marker")
493 && strncmp (obj.marker, "none", 4))))
494 continue;
495 endif
496 data_idx++;
497 is_image_data(data_idx) = false;
498 parametric(data_idx) = true;
499 have_cdata(data_idx) = false;
500 have_3d_patch(data_idx) = false;
501 if (isempty (obj.displayname))
502 titlespec{data_idx} = "title \"\"";
503 else
504 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "displayname"));
505 titlespec{data_idx} = cstrcat ("title \"", tmp, "\"");
506 endif
507 usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
508 errbars = "";
509 if (nd == 3)
510 xdat = obj.xdata(:);
511 ydat = obj.ydata(:);
512 if (! isempty (obj.zdata))
513 zdat = obj.zdata(:);
514 else
515 zdat = zeros (size (xdat));
516 endif
517 data{data_idx} = [xdat, ydat, zdat]';
518 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", numel (xdat));
519 ## fputs (plot_stream, "set parametric;\n");
520 else
521 xdat = obj.xdata(:);
522 ydat = obj.ydata(:);
523 data{data_idx} = [xdat, ydat]';
524 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s",
525 rows(xdat), xaxisloc_using, yaxisloc_using);
526 endif
527
528 style = do_linestyle_command (obj, obj.color, data_idx, mono,
529 plot_stream, errbars);
530
531 withclause{data_idx} = sprintf ("with %s linestyle %d",
532 style{1}, data_idx);
533
534 if (length (style) > 1)
535 data_idx++;
536 is_image_data(data_idx) = is_image_data(data_idx - 1);
537 parametric(data_idx) = parametric(data_idx - 1);
538 have_cdata(data_idx) = have_cdata(data_idx - 1);
539 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
540 titlespec{data_idx} = "title \"\"";
541 usingclause{data_idx} = usingclause{data_idx - 1};
542 data{data_idx} = data{data_idx - 1};
543 withclause{data_idx} = sprintf ("with %s linestyle %d",
544 style{2}, data_idx);
545 endif
546 if (length (style) > 2)
547 data_idx++;
548 is_image_data(data_idx) = is_image_data(data_idx - 1);
549 parametric(data_idx) = parametric(data_idx - 1);
550 have_cdata(data_idx) = have_cdata(data_idx - 1);
551 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
552 titlespec{data_idx} = "title \"\"";
553 usingclause{data_idx} = usingclause{data_idx - 1};
554 data{data_idx} = data{data_idx - 1};
555 withclause{data_idx} = sprintf ("with %s linestyle %d",
556 style{3}, data_idx);
557 endif
558
559 case "patch"
560 cmap = parent_figure_obj.colormap;
561 [nr, nc] = size (obj.xdata);
562
563 if (! isempty (obj.cdata))
564 cdat = obj.cdata;
565 if (strcmpi (obj.cdatamapping, "direct"))
566 cdatadirect = true;
567 endif
568 else
569 cdat = [];
570 endif
571
572 data_3d_idx = NaN;
573 for i = 1:nc
574 xcol = obj.xdata(:,i);
575 ycol = obj.ydata(:,i);
576 if (nd == 3)
577 if (! isempty (obj.zdata))
578 zcol = obj.zdata(:,i);
579 else
580 zcol = zeros (size (xcol));
581 endif
582 endif
583
584 if (! isnan (xcol) && ! isnan (ycol))
585 ## Is the patch closed or not
586 if (strncmp (obj.facecolor, "none", 4))
587 hidden_removal = false;
588 else
589
590 if (isnan (hidden_removal))
591 hidden_removal = true;
592 endif
593 if (nd == 3)
594 if (numel (xcol) > 3)
595 error ("__go_draw_axes__: gnuplot (as of v4.2) only supports 3D filled triangular patches");
596 else
597 if (isnan (data_3d_idx))
598 data_idx++;
599 data_3d_idx = data_idx;
600 is_image_data(data_idx) = false;
601 parametric(data_idx) = false;
602 have_cdata(data_idx) = true;
603 have_3d_patch(data_idx) = true;
604 withclause{data_3d_idx} = sprintf ("with pm3d");
605 usingclause{data_3d_idx} = "using 1:2:3:4";
606 data{data_3d_idx} = [];
607 endif
608 local_idx = data_3d_idx;
609 ccdat = NaN;
610 endif
611 else
612 data_idx++;
613 local_idx = data_idx;
614 is_image_data(data_idx) = false;
615 parametric(data_idx) = false;
616 have_cdata(data_idx) = false;
617 have_3d_patch(data_idx) = false;
618 endif
619
620 if (i > 1 || isempty (obj.displayname))
621 titlespec{local_idx} = "title \"\"";
622 else
623 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "displayname"));
624 titlespec{local_idx} = cstrcat ("title \"", tmp, "\"");
625 endif
626 if (isfield (obj, "facecolor"))
627 if ((strncmp (obj.facecolor, "flat", 4)
628 || strncmp (obj.facecolor, "interp", 6))
629 && isfield (obj, "cdata"))
630 if (ndims (obj.cdata) == 2
631 && (size (obj.cdata, 2) == nc
632 && (size (obj.cdata, 1) == 1
633 || size (obj.cdata, 1) == 3)))
634 ccol = cdat (:, i);
635 elseif (ndims (obj.cdata) == 2
636 && (size (obj.cdata, 1) == nc
637 && (size (obj.cdata, 2) == 1
638 || size (obj.cdata, 2) == 3)))
639 ccol = cdat (i, :);
640 elseif (ndims (obj.cdata) == 3)
641 ccol = permute (cdat (:, i, :), [1, 3, 2]);
642 else
643 ccol = cdat;
644 endif
645 if (strncmp (obj.facecolor, "flat", 4))
646 if (numel(ccol) == 3)
647 color = ccol;
648 elseif (nd == 3 && numel (xcol) == 3)
649 ccdat = ccol * ones (3,1);
650 else
651 r = 1 + round ((size (cmap, 1) - 1)
652 * (ccol - clim(1))/(clim(2) - clim(1)));
653 r = max (1, min (r, size (cmap, 1)));
654 color = cmap(r, :);
655 endif
656 elseif (strncmp (obj.facecolor, "interp", 6))
657 if (nd == 3 && numel (xcol) == 3)
658 ccdat = ccol;
659 if (! isvector (ccdat))
660 tmp = rows(cmap) + rows(addedcmap) + ...
661 [1 : rows(ccdat)];
662 addedcmap = [addedcmap; ccdat];
663 ccdat = tmp(:);
664 else
665 ccdat = ccdat(:);
666 endif
667 else
668 warning ("\"interp\" not supported, using 1st entry of cdata");
669 r = 1 + round ((size (cmap, 1) - 1) * ccol(1));
670 r = max (1, min (r, size (cmap, 1)));
671 color = cmap(r,:);
672 endif
673 endif
674 elseif (isnumeric (obj.facecolor))
675 color = obj.facecolor;
676 else
677 color = [0, 1, 0];
678 endif
679 else
680 color = [0, 1, 0];
681 endif
682
683 if (nd == 3 && numel (xcol) == 3)
684 if (isnan (ccdat))
685 ccdat = (rows (cmap) + rows(addedcmap) + 1) * ones(3, 1);
686 addedcmap = [addedcmap; reshape(color, 1, 3)];
687 endif
688 data{data_3d_idx} = [data{data_3d_idx}, ...
689 [[xcol; xcol(end)], [ycol; ycol(end)], ...
690 [zcol; zcol(end)], [ccdat; ccdat(end)]]'];
691 else
692 if (mono)
693 colorspec = "";
694 elseif (__gnuplot_has_feature__ ("transparent_patches")
695 && isscalar (obj.facealpha))
696 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\" fillstyle transparent solid %f",
697 round (255*color), obj.facealpha);
698 else
699 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
700 round (255*color));
701 endif
702
703 withclause{data_idx} = sprintf ("with filledcurve %s",
704 colorspec);
705 data{data_idx} = [xcol, ycol]';
706 usingclause{data_idx} = sprintf ("record=%d using ($1):($2)",
707 numel (xcol));
708 endif
709 endif
710 endif
711
712 ## patch outline
713 if (!(strncmp (obj.edgecolor, "none", 4)
714 && (strncmp (obj.marker, "none", 4)
715 || (strncmp (obj.markeredgecolor, "none", 4)
716 && strncmp (obj.markerfacecolor, "none", 4)))))
717
718 data_idx++;
719 is_image_data(data_idx) = false;
720 parametric(data_idx) = false;
721 have_cdata(data_idx) = false;
722 have_3d_patch(data_idx) = false;
723 titlespec{data_idx} = "title \"\"";
724 usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
725
726 if (isfield (obj, "markersize"))
727 mdat = obj.markersize / 3;
728 endif
729
730 if (isfield (obj, "edgecolor"))
731 ## FIXME
732 ## This is the wrong thing to do as edgecolor, markeredgecolor
733 ## and markerfacecolor can have different values and we should
734 ## treat them seperately. However, the below allow the scatter
735 ## functions to work as expected, where only one of these values
736 ## is set
737 if (strncmp (obj.edgecolor, "none", 4))
738 if (strncmp (obj.markeredgecolor, "none", 4))
739 ec = obj.markerfacecolor;
740 else
741 ec = obj.markeredgecolor;
742 endif
743 else
744 ec = obj.edgecolor;
745 endif
746
747 if ((strncmp (ec, "flat", 4)
748 || strncmp (ec, "interp", 6))
749 && isfield (obj, "cdata"))
750 if (ndims (obj.cdata) == 2
751 && (size (obj.cdata, 2) == nc
752 && (size (obj.cdata, 1) == 1
753 || size (obj.cdata, 1) == 3)))
754 ccol = cdat (:, i);
755 elseif (ndims (obj.cdata) == 2
756 && (size (obj.cdata, 1) == nc
757 && (size (obj.cdata, 2) == 1
758 || size (obj.cdata, 2) == 3)))
759 ccol = cdat (i, :);
760 elseif (ndims (obj.cdata) == 3)
761 ccol = permute (cdat (:, i, :), [1, 3, 2]);
762 else
763 ccol = cdat;
764 endif
765 if (strncmp (ec, "flat", 4))
766 if (numel(ccol) == 3)
767 color = ccol;
768 else
769 if (isscalar (ccol))
770 ccol = repmat(ccol, numel (xcol), 1);
771 endif
772 color = "flat";
773 have_cdata(data_idx) = true;
774 endif
775 elseif (strncmp (ec, "interp", 6))
776 if (numel(ccol) == 3)
777 warning ("\"interp\" not supported, using 1st entry of cdata");
778 color = ccol(1,:);
779 else
780 if (isscalar (ccol))
781 ccol = repmat(ccol, numel (xcol), 1);
782 endif
783 color = "interp";
784 have_cdata(data_idx) = true;
785 endif
786 endif
787 elseif (isnumeric (ec))
788 color = ec;
789 else
790 color = [0, 0, 0];
791 endif
792 else
793 color = [0, 0, 0];
794 endif
795
796 if (isfield (obj, "linestyle"))
797 switch (obj.linestyle)
798 case "-"
799 lt = "lt 1";
800 case "--"
801 lt = "lt 2";
802 case ":"
803 lt = "lt 3";
804 case "-."
805 lt = "lt 6";
806 case "none"
807 lt = "";
808 otherwise
809 lt = "";
810 endswitch
811 else
812 lt = "";
813 endif
814
815 if (isfield (obj, "linewidth"))
816 lw = sprintf("linewidth %f", obj.linewidth);
817 else
818 lw = "";
819 endif
820
821 [pt, pt2, obj] = gnuplot_pointtype (obj);
822 if (! isempty (pt))
823 pt = sprintf ("pointtype %s", pt);
824 endif
825 if (! isempty (pt2))
826 pt2 = sprintf ("pointtype %s", pt2);
827 endif
828
829 if (mono)
830 colorspec = "";
831 else
832 if (ischar (color))
833 colorspec = "palette";
834 else
835 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
836 round (255*color));
837 endif
838 endif
839
840 sidx = 1;
841 if (isempty (lt))
842 style = "";
843 else
844 style = "lines";
845 endif
846 tmpwith = {};
847
848 facesame = true;
849 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
850 && !strncmp (obj.markerfacecolor, "none", 4))
851 if (strncmp (obj.markerfacecolor, "auto", 4)
852 || ! isnumeric (obj.markerfacecolor)
853 || (isnumeric (obj.markerfacecolor)
854 && isequal (color, obj.markerfacecolor)))
855 style = strcat (style, "points");
856 if (isfield (obj, "markersize"))
857 if (length (mdat) == nc)
858 m = mdat(i);
859 else
860 m = mdat;
861 endif
862 ps = sprintf("pointsize %f", m / 3);
863 else
864 ps = "";
865 endif
866
867 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
868 style, lw, pt2, lt, ps,
869 colorspec);
870 else
871 facesame = false;
872 if (! isempty (style))
873 tmpwith{sidx} = sprintf ("with %s %s %s %s",
874 style, lw, lt,
875 colorspec);
876 sidx ++;
877 endif
878 if (isnumeric (obj.markerfacecolor) && ! mono)
879 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
880 round (255*obj.markerfacecolor));
881 endif
882 style = "points";
883 if (isfield (obj, "markersize"))
884 if (length (mdat) == nc)
885 m = mdat(i);
886 else
887 m = mdat;
888 endif
889 ps = sprintf("pointsize %f", m / 3);
890 else
891 ps = "";
892 endif
893 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
894 style, lw, pt2, lt, ps,
895 colorspec);
896 endif
897 endif
898
899 if (isfield (obj, "markeredgecolor")
900 && !strncmp (obj.markeredgecolor, "none", 4))
901 if (facesame && !isempty (pt)
902 && (strncmp (obj.markeredgecolor, "auto", 4)
903 || ! isnumeric (obj.markeredgecolor)
904 || (isnumeric (obj.markeredgecolor)
905 && isequal (color, obj.markeredgecolor))))
906 if (sidx == 1 && ((length (style) == 5
907 && strncmp (style, "lines", 5))
908 || isempty (style)))
909 style = strcat (style, "points");
910 if (isfield (obj, "markersize"))
911 if (length (mdat) == nc)
912 m = mdat(i);
913 else
914 m = mdat;
915 endif
916 ps = sprintf("pointsize %f", m / 3);
917 else
918 ps = "";
919 endif
920 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
921 style, lw, pt, lt, ps,
922 colorspec);
923 endif
924 else
925 if (!isempty (style))
926 if (length(tmpwith) < sidx || isempty (tmpwith{sidx}))
927 tmpwith{sidx} = sprintf ("with %s %s %s %s",
928 style, lw, lt,
929 colorspec);
930 endif
931 sidx ++;
932 endif
933
934 if (!isempty (pt))
935 if (! mono)
936 if (strncmp (obj.markeredgecolor, "auto", 4))
937 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
938 round (255*color));
939 elseif (isnumeric (obj.markeredgecolor) && ! mono)
940 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
941 round (255*obj.markeredgecolor));
942 endif
943 endif
944 style = "points";
945 if (isfield (obj, "markersize"))
946 if (length (mdat) == nc)
947 m = mdat(i);
948 else
949 m = mdat;
950 endif
951 ps = sprintf("pointsize %f", m / 3);
952 else
953 ps = "";
954 endif
955 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
956 style, lw, pt, lt, ps,
957 colorspec);
958 endif
959 endif
960 endif
961
962 if (isempty (tmpwith))
963 withclause{data_idx} = sprintf ("with %s %s %s %s %s",
964 style, lw, pt, lt,
965 colorspec);
966 else
967 withclause{data_idx} = tmpwith{1};
968 endif
969 if (nd == 3)
970 if (ischar (color))
971 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
972 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
973 [zcol; zcol(1)], [ccol; ccol(1)]]';
974 else
975 data{data_idx} = [xcol, ycol, zcol, ccol]';
976 endif
977 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", columns (data{data_idx}));
978 else
979 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
980 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
981 [zcol; zcol(1)]]';
982 else
983 data{data_idx} = [xcol, ycol, zcol]';
984 endif
985 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
986 endif
987 else
988 if (ischar (color))
989 if (! isnan (xcol) && ! isnan (ycol))
990 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
991 [ccol; ccol(1)]]';
992 else
993 data{data_idx} = [xcol, ycol, ccol]';
994 endif
995 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
996 else
997 if (! isnan (xcol) && ! isnan (ycol))
998 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]';
999 else
1000 data{data_idx} = [xcol, ycol]';
1001 endif
1002 usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx}));
1003 endif
1004 endif
1005
1006 if (length (tmpwith) > 1)
1007 data_idx++;
1008 is_image_data(data_idx) = is_image_data(data_idx - 1);
1009 parametric(data_idx) = parametric(data_idx - 1);
1010 have_cdata(data_idx) = have_cdata(data_idx - 1);
1011 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1012 titlespec{data_idx} = "title \"\"";
1013 usingclause{data_idx} = usingclause{data_idx - 1};
1014 data{data_idx} = data{data_idx - 1};
1015 withclause{data_idx} = tmpwith{2};
1016 endif
1017 if (length (tmpwith) > 2)
1018 data_idx++;
1019 is_image_data(data_idx) = is_image_data(data_idx - 1);
1020 parametric(data_idx) = parametric(data_idx - 1);
1021 have_cdata(data_idx) = have_cdata(data_idx - 1);
1022 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1023 titlespec{data_idx} = "title \"\"";
1024 usingclause{data_idx} = usingclause{data_idx - 1};
1025 data{data_idx} = data{data_idx - 1};
1026 withclause{data_idx} = tmpwith{3};
1027 endif
1028 endif
1029 endfor
1030
1031 case "surface"
1032 view_map = true;
1033 if (! (strncmp (obj.edgecolor, "none", 4)
1034 && strncmp (obj.facecolor, "none", 4)))
1035 data_idx++;
1036 is_image_data(data_idx) = false;
1037 parametric(data_idx) = false;
1038 have_cdata(data_idx) = true;
1039 have_3d_patch(data_idx) = false;
1040 style = do_linestyle_command (obj, obj.edgecolor,
1041 data_idx, mono,
1042 plot_stream);
1043
1044 if (isempty (obj.displayname))
1045 titlespec{data_idx} = "title \"\"";
1046 else
1047 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "displayname"));
1048 titlespec{data_idx} = cstrcat ("title \"", tmp, "\"");
1049 endif
1050 withclause{data_idx} = sprintf ("with pm3d linestyle %d",
1051 data_idx);
1052 withpm3d = true;
1053 pm3didx = data_idx;
1054
1055 xdat = obj.xdata;
1056 ydat = obj.ydata;
1057 zdat = obj.zdata;
1058 cdat = obj.cdata;
1059
1060 err = false;
1061 if (! size_equal(zdat, cdat))
1062 err = true;
1063 endif
1064 if (isvector (xdat) && isvector (ydat) && ismatrix (zdat))
1065 if (rows (zdat) == length (ydat)
1066 && columns (zdat) == length (xdat))
1067 [xdat, ydat] = meshgrid (xdat, ydat);
1068 else
1069 err = true;
1070 endif
1071 elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat))
1072 if (! size_equal (xdat, ydat, zdat))
1073 err = true;
1074 endif
1075 else
1076 err = true;
1077 endif
1078 if (err)
1079 error ("__go_draw_axes__: invalid grid data");
1080 endif
1081 xlen = columns (zdat);
1082 ylen = rows (zdat);
1083 if (xlen == columns (xdat) && xlen == columns (ydat)
1084 && ylen == rows (xdat) && ylen == rows (ydat))
1085 len = 4 * xlen;
1086 zz = zeros (ylen, len);
1087 k = 1;
1088 for kk = 1:4:len
1089 zz(:,kk) = xdat(:,k);
1090 zz(:,kk+1) = ydat(:,k);
1091 zz(:,kk+2) = zdat(:,k);
1092 zz(:,kk+3) = cdat(:,k);
1093 k++;
1094 endfor
1095 data{data_idx} = zz.';
1096 endif
1097
1098 if (doing_interp_color)
1099 interp_str = "interpolate 0, 0";
1100 else
1101 ## No interpolation of facecolors.
1102 interp_str = "";
1103 endif
1104 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3):($4)", ylen, xlen);
1105
1106 flat_interp_face = (strncmp (obj.facecolor, "flat", 4)
1107 || strncmp (obj.facecolor, "interp", 6));
1108 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4)
1109 || strncmp (obj.edgecolor, "interp", 6));
1110
1111 facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4)
1112 || (isnumeric (obj.facecolor)
1113 && all (obj.facecolor == 1)));
1114 hidden_removal = false;
1115 fputs (plot_stream, "set style increment default;\n");
1116 if (flat_interp_edge && facecolor_none_or_white)
1117 withpm3d = false;
1118 withclause{data_idx} = sprintf ("with %s palette", style {1});
1119 fputs (plot_stream, "unset pm3d\n");
1120 if (all (obj.facecolor == 1))
1121 hidden_removal = true;
1122 endif
1123 elseif (facecolor_none_or_white)
1124 if (all (obj.facecolor == 1))
1125 hidden_removal = true;
1126 endif
1127 fputs(plot_stream,"unset pm3d;\n");
1128 fputs(plot_stream,"set style increment user;\n");
1129 withpm3d = false;
1130 withclause{data_idx} = sprintf("with %s linestyle %d",
1131 style{1}, data_idx);
1132 fputs (plot_stream, "unset pm3d\n");
1133 endif
1134
1135 if (doing_interp_color)
1136 ## "depthorder" interferes with interpolation of colors.
1137 dord = "scansautomatic";
1138 else
1139 dord = "depthorder";
1140 endif
1141
1142 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4))
1143 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n",
1144 interp_str, dord);
1145 elseif (!facecolor_none_or_white)
1146 if (strncmp (obj.edgecolor, "none", 4))
1147 if (__gnuplot_has_feature__ ("transparent_surface")
1148 && isscalar (obj.facealpha))
1149 fprintf (plot_stream,
1150 "set style fill transparent solid %f;\n",
1151 obj.facealpha);
1152 endif
1153 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n",
1154 interp_str, dord);
1155 else
1156 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n",
1157 data_idx, interp_str, dord);
1158
1159 if (__gnuplot_has_feature__ ("transparent_surface")
1160 && isscalar (obj.facealpha))
1161 fprintf (plot_stream,
1162 "set style fill transparent solid %f;\n",
1163 obj.facealpha);
1164 endif
1165 endif
1166 endif
1167
1168 zz = [];
1169 if (length (style) > 1)
1170 len = 3 * xlen;
1171 zz = zeros (ylen, len);
1172 k = 1;
1173 for kk = 1:3:len
1174 zz(:,kk) = xdat(:,k);
1175 zz(:,kk+1) = ydat(:,k);
1176 zz(:,kk+2) = zdat(:,k);
1177 k++;
1178 endfor
1179 zz = zz.';
1180
1181 data_idx++;
1182 is_image_data(data_idx) = is_image_data(data_idx - 1);
1183 parametric(data_idx) = parametric(data_idx - 1);
1184 have_cdata(data_idx) = false;
1185 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1186 titlespec{data_idx} = "title \"\"";
1187 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
1188 data{data_idx} = zz;
1189 withclause{data_idx} = sprintf ("with %s linestyle %d",
1190 style{2}, data_idx);
1191
1192 endif
1193 if (length (style) > 2)
1194 data_idx++;
1195 is_image_data(data_idx) = is_image_data(data_idx - 1);
1196 parametric(data_idx) = parametric(data_idx - 1);
1197 have_cdata(data_idx) = false;
1198 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1199 titlespec{data_idx} = "title \"\"";
1200 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
1201 data{data_idx} = zz;
1202 withclause{data_idx} = sprintf ("with %s linestyle %d",
1203 style{3}, data_idx);
1204 endif
1205 if (withpm3d && strncmp (style {1}, "linespoints", 11))
1206 if (isempty(zz))
1207 len = 3 * xlen;
1208 zz = zeros (ylen, len);
1209 k = 1;
1210 for kk = 1:3:len
1211 zz(:,kk) = xdat(:,k);
1212 zz(:,kk+1) = ydat(:,k);
1213 zz(:,kk+2) = zdat(:,k);
1214 k++;
1215 endfor
1216 zz = zz.';
1217 endif
1218 data_idx++;
1219 is_image_data(data_idx) = is_image_data(data_idx - 1);
1220 parametric(data_idx) = parametric(data_idx - 1);
1221 have_cdata(data_idx) = false;
1222 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
1223 titlespec{data_idx} = "title \"\"";
1224 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
1225 data{data_idx} = zz;
1226 withclause{data_idx} = sprintf ("with points linestyle %d",
1227 pm3didx);
1228 endif
1229 endif
1230
1231 case "text"
1232 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string");
1233 fontspec = create_fontspec (f, s, gnuplot_term);
1234 lpos = obj.position;
1235 halign = obj.horizontalalignment;
1236 valign = obj.verticalalignment;
1237 angle = obj.rotation;
1238 units = obj.units;
1239 color = obj.color;
1240 if (strcmpi (units, "normalized"))
1241 units = "graph";
1242 elseif (strcmp (axis_obj.yaxislocation, "right")
1243 && strcmp (units, "data"))
1244 units = "second";
1245 else
1246 units = "";
1247 endif
1248
1249 if (isnumeric (color))
1250 colorspec = get_text_colorspec (color, mono);
1251 endif
1252
1253 switch valign
1254 ## Text offset in characters. This relies on gnuplot for font metrics.
1255 case "top"
1256 dy = -0.5;
1257 case "cap"
1258 dy = -0.5;
1259 case "middle"
1260 dy = 0;
1261 case "baseline"
1262 dy = 0.5;
1263 case "bottom"
1264 dy = 0.5;
1265 endswitch
1266 ## Gnuplot's Character units are different for x/y and vary with fontsize. The aspect ratio
1267 ## of 1:1.7 was determined by experiment to work for eps/ps/etc. For the MacOS aqua terminal
1268 ## a value of 2.5 is needed. However, the difference is barely noticable.
1269 dx_and_dy = [(-dy * sind (angle)), (dy * cosd(angle))] .* [1.7 1];
1270
1271 if (nd == 3)
1272 ## This produces the desired vertical alignment in 3D.
1273 fprintf (plot_stream,
1274 "set label \"%s\" at %s %.15e,%.15e,%.15e %s rotate by %f offset character %f,%f %s %s front %s;\n",
1275 undo_string_escapes (label), units, lpos(1),
1276 lpos(2), lpos(3), halign, angle, dx_and_dy, fontspec,
1277 __do_enhanced_option__ (enhanced, obj), colorspec);
1278 else
1279 fprintf (plot_stream,
1280 "set label \"%s\" at %s %.15e,%.15e %s rotate by %f offset character %f,%f %s %s front %s;\n",
1281 undo_string_escapes (label), units,
1282 lpos(1), lpos(2), halign, angle, dx_and_dy, fontspec,
1283 __do_enhanced_option__ (enhanced, obj), colorspec);
1284 endif
1285
1286 case "hggroup"
1287 ## Push group children into the kid list.
1288 if (isempty (kids))
1289 kids = obj.children;
1290 elseif (! isempty (obj.children))
1291 kids = [kids; obj.children];
1292 endif
1293
1294 otherwise
1295 error ("__go_draw_axes__: unknown object class, %s",
1296 obj.type);
1297 endswitch
1298
1299 endwhile
1300
1301 ## This is need to prevent warnings for rotations in 3D plots, while
1302 ## allowing colorbars with contours.
1303 if (nd == 2 || (data_idx > 1 && !view_map))
1304 fputs (plot_stream, "set pm3d implicit;\n");
1305 else
1306 fputs (plot_stream, "set pm3d explicit;\n");
1307 endif
1308
1309 if (isnan(hidden_removal) || hidden_removal)
1310 fputs (plot_stream, "set hidden3d;\n");
1311 else
1312 fputs (plot_stream, "unset hidden3d;\n");
1313 endif
1314
1315 have_data = (! (isempty (data) || all (cellfun (@isempty, data))));
1316
1317 ## Note we don't use the [xy]2range of gnuplot as we don't use the
1318 ## dual axis plotting features of gnuplot.
1319 if (isempty (xlim))
1320 return;
1321 endif
1322 if (strcmpi (axis_obj.xdir, "reverse"))
1323 xdir = "reverse";
1324 else
1325 xdir = "noreverse";
1326 endif
1327 fprintf (plot_stream, "set xrange [%.15e:%.15e] %s;\n", xlim, xdir);
1328 if (strcmpi (axis_obj.xaxislocation, "top"))
1329 fprintf (plot_stream, "set x2range [%.15e:%.15e] %s;\n", xlim, xdir);
1330 endif
1331
1332 if (isempty (ylim))
1333 return;
1334 endif
1335 if (strcmpi (axis_obj.ydir, "reverse"))
1336 ydir = "reverse";
1337 else
1338 ydir = "noreverse";
1339 endif
1340 fprintf (plot_stream, "set yrange [%.15e:%.15e] %s;\n", ylim, ydir);
1341 if (strcmpi (axis_obj.yaxislocation, "right"))
1342 fprintf (plot_stream, "set y2range [%.15e:%.15e] %s;\n", ylim, ydir);
1343 endif
1344
1345 if (nd == 3)
1346 if (isempty (zlim))
1347 return;
1348 endif
1349 if (strcmpi (axis_obj.zdir, "reverse"))
1350 zdir = "reverse";
1351 else
1352 zdir = "noreverse";
1353 endif
1354 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir);
1355 endif
1356
1357 cmap = parent_figure_obj.colormap;
1358 cmap_sz = rows(cmap);
1359 if (! any (isinf (clim)))
1360 if (truecolor || ! cdatadirect)
1361 if (rows(addedcmap) > 0)
1362 for i = 1:data_idx
1363 if (have_3d_patch(i))
1364 data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz;
1365 endif
1366 endfor
1367 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim(1), clim(2) *
1368 (cmap_sz + rows(addedcmap)) / cmap_sz);
1369 else
1370 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim);
1371 endif
1372 else
1373 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz +
1374 rows (addedcmap));
1375 endif
1376 endif
1377
1378 if (strcmpi (axis_obj.box, "on"))
1379 if (nd == 3)
1380 fputs (plot_stream, "set border 4095;\n");
1381 else
1382 fputs (plot_stream, "set border 431;\n");
1383 endif
1384 else
1385 if (nd == 3)
1386 fputs (plot_stream, "set border 895;\n");
1387 elseif (! isempty (axis_obj.ytick))
1388 if (strcmpi (axis_obj.yaxislocation, "right"))
1389 fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n",
1390 axis_obj.tickdir);
1391 if (strcmpi (axis_obj.xaxislocation, "top"))
1392 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n",
1393 axis_obj.tickdir);
1394 fputs (plot_stream, "set border 12;\n");
1395 else
1396 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
1397 axis_obj.tickdir);
1398 fputs (plot_stream, "set border 9;\n");
1399 endif
1400 else
1401 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
1402 axis_obj.tickdir);
1403 if (strcmpi (axis_obj.xaxislocation, "top"))
1404 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n",
1405 axis_obj.tickdir);
1406 fputs (plot_stream, "set border 6;\n");
1407 else
1408 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
1409 axis_obj.tickdir);
1410 fputs (plot_stream, "set border 3;\n");
1411 endif
1412 endif
1413 endif
1414 endif
1415
1416 if (strcmpi (axis_obj.visible, "off"))
1417 fputs (plot_stream, "unset border; unset tics\n");
1418 else
1419 fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth);
1420 endif
1421
1422 if (! isempty (hlgnd) && ! isempty (hlgnd.children)
1423 && any (strcmpi (get (hlgnd.children, "visible"), "on")))
1424 if (strcmpi (hlgnd.box, "on"))
1425 box = "box";
1426 else
1427 box = "nobox";
1428 endif
1429 if (strcmpi (hlgnd.orientation, "vertical"))
1430 horzvert = "vertical";
1431 else
1432 horzvert = "horizontal";
1433 endif
1434 if (strcmpi (hlgnd.textposition, "right"))
1435 reverse = "reverse";
1436 else
1437 reverse = "noreverse";
1438 endif
1439 inout = "inside";
1440 keypos = hlgnd.location;
1441 if (ischar (keypos))
1442 keypos = lower (keypos);
1443 keyout = findstr (keypos, "outside");
1444 if (! isempty (keyout))
1445 inout = "outside";
1446 keypos = keypos(1:keyout-1);
1447 endif
1448 endif
1449 switch (keypos)
1450 case "north"
1451 pos = "center top";
1452 case "south"
1453 pos = "center bottom";
1454 case "east"
1455 pos = "right center";
1456 case "west"
1457 pos = "left center";
1458 case "northeast"
1459 pos = "right top";
1460 case "northwest"
1461 pos = "left top";
1462 case "southeast"
1463 pos = "right bottom";
1464 case "southwest"
1465 pos = "left bottom";
1466 case "best"
1467 pos = "";
1468 warning ("legend: 'Best' not yet implemented for location specifier.\n");
1469 ## Least conflict with data in plot.
1470 ## Least unused space outside plot.
1471 otherwise
1472 pos = "";
1473 endswitch
1474 if (__gnuplot_has_feature__ ("key_has_font_properties"))
1475 [fontname, fontsize] = get_fontname_and_size (hlgnd);
1476 fontspec = create_fontspec (fontname, fontsize, gnuplot_term);
1477 else
1478 fontspec = "";
1479 endif
1480 fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s;\n",
1481 inout, pos, box, reverse, horzvert, fontspec);
1482 else
1483 fputs (plot_stream, "unset key;\n");
1484 endif
1485 fputs (plot_stream, "set style data lines;\n");
1486
1487 cmap = [cmap; addedcmap];
1488 cmap_sz = cmap_sz + rows(addedcmap);
1489 if (length(cmap) > 0)
1490 fprintf (plot_stream,
1491 "set palette positive color model RGB maxcolors %i;\n",
1492 cmap_sz);
1493 fprintf (plot_stream,
1494 "set palette file \"-\" binary record=%d using 1:2:3:4;\n",
1495 cmap_sz);
1496 fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32");
1497 fwrite (plot_stream, "\n");
1498 endif
1499
1500 fputs (plot_stream, "unset colorbox;\n");
1501
1502 if (have_data)
1503 if (nd == 2)
1504 plot_cmd = "plot";
1505 else
1506 plot_cmd = "splot";
1507 rot_x = 90 - axis_obj.view(2);
1508 rot_z = axis_obj.view(1);
1509 while (rot_z < 0)
1510 rot_z += 360;
1511 endwhile
1512 fputs (plot_stream, "set ticslevel 0;\n");
1513 if (view_map && rot_x == 0 && rot_z == 0)
1514 fputs (plot_stream, "set view map;\n");
1515 else
1516 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z);
1517 endif
1518 endif
1519 if (have_3d_patch (1))
1520 fputs (plot_stream, "set pm3d depthorder\n");
1521 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
1522 usingclause{1}, titlespec{1}, withclause{1});
1523 elseif (is_image_data (1))
1524 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
1525 usingclause{1}, titlespec{1}, withclause{1});
1526 else
1527 fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n", plot_cmd,
1528 usingclause{1}, titlespec{1}, withclause{1});
1529 endif
1530 for i = 2:data_idx
1531 if (have_3d_patch (i))
1532 fprintf (plot_stream, ", \"-\" %s %s %s \\\n",
1533 usingclause{i}, titlespec{i}, withclause{i});
1534 elseif (is_image_data (i))
1535 if (! is_image_data (i-1))
1536 fputs (plot_stream, "; ");
1537 if (bg_is_set)
1538 fputs (plot_stream, "unset obj 1; \\\n");
1539 bg_is_set = false;
1540 endif
1541 if (fg_is_set)
1542 fputs (plot_stream, "unset obj 2; \\\n");
1543 fg_is_set = false;
1544 endif
1545 endif
1546 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
1547 usingclause{i}, titlespec{i}, withclause{i});
1548 elseif (is_image_data (i-1))
1549 if (bg_is_set)
1550 fputs (plot_stream, "unset obj 1; \\\n");
1551 bg_is_set = false;
1552 endif
1553 if (fg_is_set)
1554 fputs (plot_stream, "unset obj 2; \\\n");
1555 fg_is_set = false;
1556 endif
1557 fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n", plot_cmd,
1558 usingclause{i}, titlespec{i}, withclause{i});
1559 else
1560 fprintf (plot_stream, ", \"-\" binary format='%%float64' %s %s %s \\\n",
1561 usingclause{i}, titlespec{i}, withclause{i});
1562 endif
1563 endfor
1564 fputs (plot_stream, ";\n");
1565 for i = 1:data_idx
1566 if (have_3d_patch (i))
1567 ## Can't write 3d patch data as binary as can't plot more than
1568 ## a single patch at a time and have to plot all patches together
1569 ## so that the gnuplot depth ordering is done correctly
1570 for j = 1 : 4 : columns(data{i})
1571 if (j != 1)
1572 fputs (plot_stream, "\n\n");
1573 endif
1574 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j).');
1575 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n\n", data{i}(:,j+1).');
1576 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+2).');
1577 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+3).');
1578 endfor
1579 fputs (plot_stream, "e\n");
1580 elseif (is_image_data(i))
1581 fwrite (plot_stream, data{i}, "float32");
1582 else
1583 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i),
1584 have_cdata(i));
1585 endif
1586 endfor
1587 else
1588 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n");
1589 endif
1590
1591 ## Needed to allow mouse rotation with pcolor.
1592 if (view_map)
1593 fputs (plot_stream, "unset view;\n");
1594 endif
1595
1596 if (bg_is_set)
1597 fputs (plot_stream, "unset obj 1;\n");
1598 bg_is_set = false;
1599 endif
1600
1601 fflush (plot_stream);
1602
1603 else
1604 print_usage ();
1605 endif
1606
1607 endfunction
1608
1609 function fontspec = create_fontspec (f, s, gp_term)
1610 if (strcmp (f, "*") || strcmp (gp_term, "tikz"))
1611 fontspec = sprintf ("font \",%d\"", s);
1612 else
1613 fontspec = sprintf ("font \"%s,%d\"", f, s);
1614 endif
1615 endfunction
1616
1617 function style = do_linestyle_command (obj, linecolor, idx, mono,
1618 plot_stream, errbars = "")
1619 style = {};
1620
1621 fprintf (plot_stream, "set style line %d default;\n", idx);
1622 fprintf (plot_stream, "set style line %d", idx);
1623
1624 found_style = false;
1625 if (isnumeric (linecolor))
1626 color = linecolor;
1627 if (! mono)
1628 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
1629 round (255*color));
1630 endif
1631 else
1632 color = [0, 0, 0];
1633 endif
1634
1635 if (isfield (obj, "linestyle"))
1636 switch (obj.linestyle)
1637 case "-"
1638 lt = "1";
1639 case "--"
1640 lt = "2";
1641 case ":"
1642 lt = "3";
1643 case "-."
1644 lt = "6";
1645 case "none"
1646 lt = "";
1647 otherwise
1648 lt = "";
1649 endswitch
1650
1651 if (! isempty (lt))
1652 fprintf (plot_stream, " linetype %s", lt);
1653 endif
1654
1655 else
1656 lt = "";
1657 endif
1658 if (! isempty (errbars))
1659 found_style = true;
1660 endif
1661
1662 if (isfield (obj, "linewidth"))
1663 fprintf (plot_stream, " linewidth %f", obj.linewidth);
1664 found_style = true;
1665 endif
1666
1667 [pt, pt2, obj] = gnuplot_pointtype (obj);
1668
1669 if (! isempty (pt))
1670 found_style = true;
1671 endif
1672
1673 sidx = 1;
1674 if (isempty (errbars))
1675 if (isempty (lt))
1676 style {sidx} = "";
1677 else
1678 style {sidx} = "lines";
1679 endif
1680
1681 facesame = true;
1682 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
1683 && !strncmp (obj.markerfacecolor, "none", 4))
1684 if (strncmp (obj.markerfacecolor, "auto", 4)
1685 || ! isnumeric (obj.markerfacecolor)
1686 || (isnumeric (obj.markerfacecolor)
1687 && isequal (color, obj.markerfacecolor)))
1688 if (! isempty (pt2))
1689 fprintf (plot_stream, " pointtype %s", pt2);
1690 style {sidx} = strcat (style{sidx}, "points");
1691 endif
1692 if (isfield (obj, "markersize"))
1693 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1694 endif
1695 else
1696 facesame = false;
1697 if (! found_style)
1698 fputs (plot_stream, " default");
1699 endif
1700 fputs (plot_stream, ";\n");
1701 if (! isempty (style {sidx}))
1702 sidx ++;
1703 idx ++;
1704 else
1705 fputs (plot_stream, ";\n");
1706 endif
1707 fprintf (plot_stream, "set style line %d default;\n", idx);
1708 fprintf (plot_stream, "set style line %d", idx);
1709 if (isnumeric (obj.markerfacecolor) && ! mono)
1710 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
1711 round (255*obj.markerfacecolor));
1712 endif
1713 if (! isempty (pt2))
1714 style {sidx} = "points";
1715 fprintf (plot_stream, " pointtype %s", pt2);
1716 endif
1717 if (isfield (obj, "markersize"))
1718 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1719 endif
1720 endif
1721 endif
1722 if (isfield (obj, "markeredgecolor")
1723 && !strncmp (obj.markeredgecolor, "none", 4))
1724 if (facesame && !isempty (pt)
1725 && (strncmp (obj.markeredgecolor, "auto", 4)
1726 || ! isnumeric (obj.markeredgecolor)
1727 || (isnumeric (obj.markeredgecolor)
1728 && isequal (color, obj.markeredgecolor))))
1729 if (sidx == 1 && ((length (style {sidx}) == 5
1730 && strncmp (style {sidx}, "lines", 5)) || isempty (style {sidx})))
1731 if (! isempty (pt))
1732 style {sidx} = strcat (style{sidx}, "points");
1733 fprintf (plot_stream, " pointtype %s", pt);
1734 endif
1735 if (isfield (obj, "markersize"))
1736 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1737 endif
1738 endif
1739 else
1740 if (! found_style)
1741 fputs (plot_stream, " default");
1742 endif
1743 fputs (plot_stream, ";\n");
1744 if (!isempty (style {sidx}))
1745 sidx ++;
1746 idx ++;
1747 else
1748 fputs (plot_stream, ";\n");
1749 endif
1750 fprintf (plot_stream, "set style line %d default;\n", idx);
1751 fprintf (plot_stream, "set style line %d", idx);
1752 if (! mono)
1753 if (strncmp (obj.markeredgecolor, "auto", 4))
1754 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
1755 round (255*color));
1756 elseif (isnumeric (obj.markeredgecolor) && ! mono)
1757 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
1758 round (255*obj.markeredgecolor));
1759 endif
1760 endif
1761 if (! isempty (pt))
1762 style {sidx} = "points";
1763 fprintf (plot_stream, " pointtype %s", pt);
1764 endif
1765 if (isfield (obj, "markersize"))
1766 fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
1767 endif
1768 endif
1769 endif
1770 else
1771 style{1} = errbars;
1772 fputs (plot_stream, " pointtype 0");
1773 endif
1774
1775 if (! found_style && isempty (style {1}))
1776 fputs (plot_stream, " default");
1777 endif
1778
1779 fputs (plot_stream, ";\n");
1780
1781 endfunction
1782
1783 function [pt, pt2, obj] = gnuplot_pointtype (obj)
1784 if (isfield (obj, "marker"))
1785 switch (obj.marker)
1786 case "+"
1787 pt = pt2 = "1";
1788 case "o"
1789 pt = "6";
1790 pt2 = "7";
1791 case "*"
1792 pt = pt2 = "3";
1793 case "."
1794 pt = "6";
1795 pt2 = "7";
1796 if (isfield (obj, "markerfacecolor")
1797 || strncmp (obj.markerfacecolor, "none", 4))
1798 obj.markerfacecolor = "auto";
1799 endif
1800 if (isfield (obj, "markersize"))
1801 obj.markersize /= 3;
1802 else
1803 obj.markersize = 5;
1804 endif
1805 case "x"
1806 pt = pt2 = "2";
1807 case {"square", "s"}
1808 pt = "4";
1809 pt2 = "5";
1810 case {"diamond", "d"}
1811 pt = "12";
1812 pt2 = "13";
1813 case "^"
1814 pt = "8";
1815 pt2 = "9";
1816 case "v"
1817 pt = "10";
1818 pt2 = "11";
1819 case ">"
1820 ## FIXME -- should be triangle pointing right, use triangle pointing up
1821 pt = "8";
1822 pt2 = "9";
1823 case "<"
1824 ## FIXME -- should be triangle pointing left, use triangle pointing down
1825 pt = "10";
1826 pt2 = "11";
1827 case {"pentagram", "p"}
1828 ## FIXME -- should be pentagram, using pentagon
1829 pt = "14";
1830 pt2 = "15";
1831 case {"hexagram", "h"}
1832 ## FIXME -- should be 6 pt start, using "*" instead
1833 pt = pt2 = "3";
1834 case "none"
1835 pt = pt2 = "";
1836 otherwise
1837 pt = pt2 = "";
1838 endswitch
1839 else
1840 pt = pt2 = "";
1841 endif
1842 endfunction
1843
1844 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata)
1845
1846 ## DATA is already transposed.
1847
1848 ## FIXME -- this may need to be converted to C++ for speed.
1849
1850 ## Convert NA elements to normal NaN values because fprintf writes
1851 ## "NA" and that confuses gnuplot.
1852 idx = find (isna (data));
1853 if (any (idx))
1854 data(idx) = NaN;
1855 endif
1856
1857 if (nd == 2)
1858 fwrite (plot_stream, data, "float64");
1859 elseif (nd == 3)
1860 if (parametric)
1861 fwrite (plot_stream, data, "float64");
1862 else
1863 nr = rows (data);
1864 if (cdata)
1865 for j = 1:4:nr
1866 fwrite (plot_stream, data(j:j+3,:), "float64");
1867 endfor
1868 else
1869 for j = 1:3:nr
1870 fwrite (plot_stream, data(j:j+2,:), "float64");
1871 endfor
1872 endif
1873 endif
1874 endif
1875
1876 endfunction
1877
1878 function do_tics (obj, plot_stream, ymirror, mono, gnuplot_term)
1879
1880 obj.xticklabel = ticklabel_to_cell (obj.xticklabel);
1881 obj.yticklabel = ticklabel_to_cell (obj.yticklabel);
1882 obj.zticklabel = ticklabel_to_cell (obj.zticklabel);
1883
1884 if (strcmp (obj.xminorgrid, "on"))
1885 obj.xminortick = "on";
1886 endif
1887 if (strcmp (obj.yminorgrid, "on"))
1888 obj.yminortick = "on";
1889 endif
1890 if (strcmp (obj.zminorgrid, "on"))
1891 obj.zminortick = "on";
1892 endif
1893
1894 [fontname, fontsize] = get_fontname_and_size (obj);
1895 fontspec = create_fontspec (fontname, fontsize, gnuplot_term);
1896
1897 ## A Gnuplot tic scale of 69 is equivalent to Octave's 0.5.
1898 ticklength = sprintf ("scale %4.1f", (69/0.5)*obj.ticklength(1));
1899
1900 if (strcmpi (obj.xaxislocation, "top"))
1901 do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
1902 obj.xticklabel, obj.xcolor, "x2", plot_stream, true, mono,
1903 "border", obj.tickdir, ticklength, fontname, fontspec,
1904 obj.interpreter, obj.xscale);
1905 do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
1906 obj.xcolor, "x", plot_stream, true, mono, "border",
1907 "", "", fontname, fontspec, obj.interpreter, obj.xscale);
1908 elseif (strcmpi (obj.xaxislocation, "zero"))
1909 do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
1910 obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
1911 "axis", obj.tickdir, ticklength, fontname, fontspec,
1912 obj.interpreter, obj.xscale);
1913 do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
1914 obj.xcolor, "x2", plot_stream, true, mono, "axis",
1915 "", "", fontname, fontspec, obj.interpreter, obj.xscale);
1916 else
1917 do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
1918 obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
1919 "border", obj.tickdir, ticklength, fontname, fontspec,
1920 obj.interpreter, obj.xscale);
1921 do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
1922 obj.xcolor, "x2", plot_stream, true, mono, "border",
1923 "", "", fontname, fontspec, obj.interpreter, obj.xscale);
1924 endif
1925 if (strcmpi (obj.yaxislocation, "right"))
1926 do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
1927 obj.yticklabel, obj.ycolor, "y2", plot_stream, ymirror, mono,
1928 "border", obj.tickdir, ticklength, fontname, fontspec,
1929 obj.interpreter, obj.yscale);
1930 do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
1931 obj.ycolor, "y", plot_stream, ymirror, mono, "border",
1932 "", "", fontname, fontspec, obj.interpreter, obj.yscale);
1933 elseif (strcmpi (obj.yaxislocation, "zero"))
1934 do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
1935 obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
1936 "axis", obj.tickdir, ticklength, fontname, fontspec,
1937 obj.interpreter, obj.yscale);
1938 do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
1939 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis",
1940 "", "", fontname, fontspec, obj.interpreter, obj.yscale);
1941 else
1942 do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
1943 obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
1944 "border", obj.tickdir, ticklength, fontname, fontspec,
1945 obj.interpreter, obj.yscale);
1946 do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
1947 obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
1948 "", "", fontname, fontspec, obj.interpreter, obj.yscale);
1949 endif
1950 do_tics_1 (obj.ztickmode, obj.ztick, obj.zminortick, obj.zticklabelmode,
1951 obj.zticklabel, obj.zcolor, "z", plot_stream, true, mono,
1952 "border", obj.tickdir, ticklength, fontname, fontspec,
1953 obj.interpreter, obj.zscale);
1954 endfunction
1955
1956 function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax,
1957 plot_stream, mirror, mono, axispos, tickdir, ticklength,
1958 fontname, fontspec, interpreter, scale)
1959 persistent warned_latex = false;
1960 if (strcmpi (interpreter, "tex"))
1961 for n = 1 : numel(labels)
1962 labels{n} = __tex2enhanced__ (labels{n}, fontname, false, false);
1963 endfor
1964 elseif (strcmpi (interpreter, "latex"))
1965 if (! warned_latex)
1966 warning ("latex markup not supported for tick marks");
1967 warned_latex = true;
1968 endif
1969 endif
1970 if (strcmp (scale, "log"))
1971 fmt = "10^{%T}";
1972 num_mtics = 10;
1973 else
1974 fmt = "%g";
1975 num_mtics = 5;
1976 endif
1977 colorspec = get_text_colorspec (color, mono);
1978 if (strcmpi (ticmode, "manual") || strcmpi (labelmode, "manual"))
1979 if (isempty (tics))
1980 fprintf (plot_stream, "unset %stics;\nunset m%stics;\n", ax, ax);
1981 elseif (strcmpi (labelmode, "manual"))
1982 if (ischar (labels))
1983 labels = cellstr (labels);
1984 endif
1985 if (isnumeric (labels))
1986 labels = num2str (real (labels(:)));
1987 endif
1988 if (ischar (labels))
1989 labels = permute (cellstr (labels), [2, 1]);
1990 endif
1991 if (iscellstr (labels))
1992 k = 1;
1993 ntics = numel (tics);
1994 nlabels = numel (labels);
1995 fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
1996 if (mirror)
1997 fprintf (plot_stream, "set %stics %s %s %s mirror (", ax,
1998 tickdir, ticklength, axispos);
1999 else
2000 fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax,
2001 tickdir, ticklength, axispos);
2002 endif
2003
2004 labels = regexprep(labels, '%', "%%");
2005 for i = 1:ntics
2006 fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i));
2007 if (i < ntics)
2008 fputs (plot_stream, ", ");
2009 endif
2010 if (k > nlabels)
2011 k = 1;
2012 endif
2013 endfor
2014 fprintf (plot_stream, ") %s %s;\n", colorspec, fontspec);
2015 if (strcmp (mtics, "on"))
2016 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics);
2017 else
2018 fprintf (plot_stream, "unset m%stics;\n", ax);
2019 endif
2020 else
2021 error ("__go_draw_axes__: unsupported type of ticklabel");
2022 endif
2023 else
2024 fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt);
2025 if (mirror)
2026 fprintf (plot_stream, "set %stics %s %s %s mirror (", ax, tickdir,
2027 ticklength, axispos);
2028 else
2029 fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax, tickdir,
2030 ticklength, axispos);
2031 endif
2032 fprintf (plot_stream, " %.15g,", tics(1:end-1));
2033 fprintf (plot_stream, " %.15g) %s;\n", tics(end), fontspec);
2034 if (strcmp (mtics, "on"))
2035 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics);
2036 else
2037 fprintf (plot_stream, "unset m%stics;\n", ax);
2038 endif
2039 endif
2040 else
2041 fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt);
2042 if (mirror)
2043 fprintf (plot_stream, "set %stics %s %s %s mirror %s %s;\n", ax,
2044 axispos, tickdir, ticklength, colorspec, fontspec);
2045 else
2046 fprintf (plot_stream, "set %stics %s %s %s nomirror %s %s;\n", ax,
2047 tickdir, ticklength, axispos, colorspec, fontspec);
2048 endif
2049 if (strcmp (mtics, "on"))
2050 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics);
2051 else
2052 fprintf (plot_stream, "unset m%stics;\n", ax);
2053 endif
2054 endif
2055 endfunction
2056
2057 function ticklabel = ticklabel_to_cell (ticklabel)
2058 if (isnumeric (ticklabel))
2059 ## Use upto 5 significant digits
2060 ticklabel = num2str (ticklabel(:), 5);
2061 endif
2062 if (ischar (ticklabel))
2063 if (size (ticklabel, 1) == 1 && any (ticklabel == "|"))
2064 n = setdiff (findstr (ticklabel, "|"), findstr (ticklabel, '\|'));
2065 ticklabel = strsplit (ticklabel, "|");
2066 else
2067 ticklabel = cellstr (ticklabel);
2068 endif
2069 elseif (isempty (ticklabel))
2070 ticklabel = {""};
2071 else
2072 ticklabel = ticklabel;
2073 endif
2074 endfunction
2075
2076 function colorspec = get_text_colorspec (color, mono)
2077 if (mono)
2078 colorspec = "";
2079 else
2080 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"",
2081 round (255*color));
2082 endif
2083 endfunction
2084
2085 function [f, s, fnt, it, bld] = get_fontname_and_size (t)
2086 if (isempty (t.fontname) || strcmp (t.fontname, "*"))
2087 fnt = "{}";
2088 else
2089 fnt = t.fontname;
2090 endif
2091 f = fnt;
2092 it = false;
2093 bld = false;
2094 if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold"))
2095 if (! isempty(t.fontangle)
2096 && (strcmpi (t.fontangle, "italic")
2097 || strcmpi (t.fontangle, "oblique")))
2098 f = cstrcat (f, "-bolditalic");
2099 it = true;
2100 bld = true;
2101 else
2102 f = cstrcat (f, "-bold");
2103 bld = true;
2104 endif
2105 elseif (! isempty(t.fontangle)
2106 && (strcmpi (t.fontangle, "italic")
2107 || strcmpi (t.fontangle, "oblique")))
2108 f = cstrcat (f, "-italic");
2109 it = true;
2110 endif
2111 if (isempty (t.fontsize))
2112 s = 10;
2113 else
2114 s = t.fontsize;
2115 endif
2116 endfunction
2117
2118 function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld)
2119
2120 persistent warned_latex = false;
2121
2122 if (strcmp (fld, "string"))
2123 [f, s, fnt, it, bld] = get_fontname_and_size (obj);
2124 else
2125 f = "Helvetica";
2126 s = 10;
2127 fnt = f;
2128 it = false;
2129 bld = false;
2130 endif
2131
2132 str = getfield (obj, fld);
2133 if (enhanced)
2134 if (strcmpi (obj.interpreter, "tex"))
2135 str = __tex2enhanced__ (str, fnt, it, bld);
2136 elseif (strcmpi (obj.interpreter, "latex"))
2137 if (! warned_latex)
2138 warning ("latex markup not supported for text objects");
2139 warned_latex = true;
2140 endif
2141 endif
2142 endif
2143 endfunction
2144
2145 function str = __tex2enhanced__ (str, fnt, it, bld)
2146 persistent sym = __setup_sym_table__ ();
2147 persistent flds = fieldnames (sym);
2148
2149 [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches');
2150
2151 for i = length (s) : -1 : 1
2152 ## special case for "\0" and replace with "{/Symbol \306}'
2153 if (strncmp (m{i}, '\0', 2))
2154 str = cstrcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end));
2155 else
2156 f = m{i}(2:end);
2157 if (isfield (sym, f))
2158 g = getfield(sym, f);
2159 ## FIXME The symbol font doesn't seem to support bold or italic
2160 ##if (bld)
2161 ## if (it)
2162 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic');
2163 ## else
2164 ## g = regexprep (g, '/Symbol', '/Symbol-bold');
2165 ## endif
2166 ##elseif (it)
2167 ## g = regexprep (g, '/Symbol', '/Symbol-italic');
2168 ##endif
2169 str = cstrcat (str(1:s(i) - 1), g, str(e(i) + 1:end));
2170 elseif (strncmp (f, "rm", 2))
2171 bld = false;
2172 it = false;
2173 str = cstrcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end));
2174 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2))
2175 it = true;
2176 if (bld)
2177 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ',
2178 str(s(i) + 3:end));
2179 else
2180 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ',
2181 str(s(i) + 3:end));
2182 endif
2183 elseif (strncmp (f, "bf", 2))
2184 bld = true;
2185 if (it)
2186 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ',
2187 str(2(i) + 3:end));
2188 else
2189 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ',
2190 str(s(i) + 3:end));
2191 endif
2192 elseif (strcmpi (f, "color"))
2193 ## FIXME Ignore \color but remove trailing {} block as well
2194 d = strfind(str(e(i) + 1:end),'}');
2195 if (isempty (d))
2196 warning ('syntax error in \color argument');
2197 else
2198 str = cstrcat (str(1:s(i) - 1), str(e(i) + d + 1:end));
2199 endif
2200 elseif(strcmpi (f, "fontname"))
2201 b1 = strfind(str(e(i) + 1:end),'{');
2202 b2 = strfind(str(e(i) + 1:end),'}');
2203 if (isempty(b1) || isempty(b2))
2204 warning ('syntax error in \fontname argument');
2205 else
2206 str = cstrcat (str(1:s(i) - 1), '/',
2207 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
2208 str(e(i) + b2(1) + 1:end));
2209 endif
2210 elseif(strcmpi (f, "fontsize"))
2211 b1 = strfind(str(e(i) + 1:end),'{');
2212 b2 = strfind(str(e(i) + 1:end),'}');
2213 if (isempty(b1) || isempty(b2))
2214 warning ('syntax error in \fontname argument');
2215 else
2216 str = cstrcat (str(1:s(i) - 1), '/=',
2217 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}',
2218 str(e(i) + b2(1) + 1:end));
2219 endif
2220 else
2221 ## Last desperate attempt to treat the symbol. Look for things
2222 ## like \pix, that should be translated to the symbol Pi and x
2223 for j = 1 : length (flds)
2224 if (strncmp (flds{j}, f, length (flds{j})))
2225 g = getfield(sym, flds{j});
2226 ## FIXME The symbol font doesn't seem to support bold or italic
2227 ##if (bld)
2228 ## if (it)
2229 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic');
2230 ## else
2231 ## g = regexprep (g, '/Symbol', '/Symbol-bold');
2232 ## endif
2233 ##elseif (it)
2234 ## g = regexprep (g, '/Symbol', '/Symbol-italic');
2235 ##endif
2236 str = cstrcat (str(1:s(i) - 1), g,
2237 str(s(i) + length (flds{j}) + 1:end));
2238 break;
2239 endif
2240 endfor
2241 endif
2242 endif
2243 endfor
2244
2245 ## Prepend @ to things things like _0^x or _{-100}^{100} for
2246 ## alignment But need to put the shorter of the two arguments first.
2247 ## Carful of nested {} and unprinted characters when defining
2248 ## shortest.. Don't have to worry about things like ^\theta as they
2249 ## are already converted to ^{/Symbol q}.
2250
2251 ## FIXME -- This is a mess... Is it worth it just for a "@" character?
2252
2253 [s, m] = regexp(str,'[_\^]','start','matches');
2254 i = 1;
2255 p = 0;
2256 while (i < length (s))
2257 if (i < length(s))
2258 if (str(s(i) + p + 1) == "{")
2259 s1 = strfind(str(s(i) + p + 2:end),'{');
2260 si = 1;
2261 l1 = strfind(str(s(i) + p + 1:end),'}');
2262 li = 1;
2263 while (li <= length (l1) && si <= length (s1))
2264 if (l1(li) < s1(si))
2265 if (li == si)
2266 break;
2267 endif
2268 li++;
2269 else
2270 si++;
2271 endif
2272 endwhile
2273 l1 = l1 (min (length(l1), si));
2274 if (s(i) + l1 + 1 == s(i+1))
2275 if (str(s(i + 1) + p + 1) == "{")
2276 s2 = strfind(str(s(i + 1) + p + 2:end),'{');
2277 si = 1;
2278 l2 = strfind(str(s(i + 1) + p + 1:end),'}');
2279 li = 1;
2280 while (li <= length (l2) && si <= length (s2))
2281 if (l2(li) < s2(si))
2282 if (li == si)
2283 break;
2284 endif
2285 li++;
2286 else
2287 si++;
2288 endif
2289 endwhile
2290 l2 = l2 (min (length(l2), si));
2291 if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <=
2292 length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1)))
2293 ## Shortest already first!
2294 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end));
2295 else
2296 ## Have to swap sub/super-script to get shortest first.
2297 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2),
2298 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end));
2299 endif
2300 else
2301 ## Have to swap sub/super-script to get shortest first.
2302 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1),
2303 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end));
2304 endif
2305 i += 2;
2306 p ++;
2307 else
2308 i++;
2309 endif
2310 else
2311 if (s(i+1) == s(i) + 2)
2312 ## Shortest already first!
2313 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end));
2314 p ++;
2315 i += 2;
2316 else
2317 i ++;
2318 endif
2319 endif
2320 else
2321 i ++;
2322 endif
2323 endwhile
2324
2325 endfunction
2326
2327 function l = length_string (s)
2328 l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}'));
2329 m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches');
2330 if (!isempty (m))
2331 l = l - sum (cellfun (@length, m));
2332 endif
2333 endfunction
2334
2335 function sym = __setup_sym_table__ ()
2336 ## Setup the translation table for TeX to gnuplot enhanced mode.
2337 sym.forall = '{/Symbol \042}';
2338 sym.exists = '{/Symbol \044}';
2339 sym.ni = '{/Symbol \047}';
2340 sym.cong = '{/Symbol \100}';
2341 sym.Delta = '{/Symbol D}';
2342 sym.Phi = '{/Symbol F}';
2343 sym.Gamma = '{/Symbol G}';
2344 sym.vartheta = '{/Symbol J}';
2345 sym.Lambda = '{/Symbol L}';
2346 sym.Pi = '{/Symbol P}';
2347 sym.Theta = '{/Symbol Q}';
2348 sym.Sigma = '{/Symbol S}';
2349 sym.varsigma = '{/Symbol V}';
2350 sym.Omega = '{/Symbol W}';
2351 sym.Xi = '{/Symbol X}';
2352 sym.Psi = '{/Symbol Y}';
2353 sym.perp = '{/Symbol \136}';
2354 sym.alpha = '{/Symbol a}';
2355 sym.beta = '{/Symbol b}';
2356 sym.chi = '{/Symbol c}';
2357 sym.delta = '{/Symbol d}';
2358 sym.epsilon = '{/Symbol e}';
2359 sym.phi = '{/Symbol f}';
2360 sym.gamma = '{/Symbol g}';
2361 sym.eta = '{/Symbol h}';
2362 sym.iota = '{/Symbol i}';
2363 sym.varphi = '{/Symbol j}';
2364 sym.kappa = '{/Symbol k}';
2365 sym.lambda = '{/Symbol l}';
2366 sym.mu = '{/Symbol m}';
2367 sym.nu = '{/Symbol n}';
2368 sym.o = '{/Symbol o}';
2369 sym.pi = '{/Symbol p}';
2370 sym.theta = '{/Symbol q}';
2371 sym.rho = '{/Symbol r}';
2372 sym.sigma = '{/Symbol s}';
2373 sym.tau = '{/Symbol t}';
2374 sym.upsilon = '{/Symbol u}';
2375 sym.varpi = '{/Symbol v}';
2376 sym.omega = '{/Symbol w}';
2377 sym.xi = '{/Symbol x}';
2378 sym.psi = '{/Symbol y}';
2379 sym.zeta = '{/Symbol z}';
2380 sym.sim = '{/Symbol \176}';
2381 sym.Upsilon = '{/Symbol \241}';
2382 sym.prime = '{/Symbol \242}';
2383 sym.leq = '{/Symbol \243}';
2384 sym.infty = '{/Symbol \245}';
2385 sym.clubsuit = '{/Symbol \247}';
2386 sym.diamondsuit = '{/Symbol \250}';
2387 sym.heartsuit = '{/Symbol \251}';
2388 sym.spadesuit = '{/Symbol \252}';
2389 sym.leftrightarrow = '{/Symbol \253}';
2390 sym.leftarrow = '{/Symbol \254}';
2391 sym.uparrow = '{/Symbol \255}';
2392 sym.rightarrow = '{/Symbol \256}';
2393 sym.downarrow = '{/Symbol \257}';
2394 sym.circ = '{/Symbol \260}';
2395 sym.pm = '{/Symbol \261}';
2396 sym.geq = '{/Symbol \263}';
2397 sym.times = '{/Symbol \264}';
2398 sym.propto = '{/Symbol \265}';
2399 sym.partial = '{/Symbol \266}';
2400 sym.bullet = '{/Symbol \267}';
2401 sym.div = '{/Symbol \270}';
2402 sym.neq = '{/Symbol \271}';
2403 sym.equiv = '{/Symbol \272}';
2404 sym.approx = '{/Symbol \273}';
2405 sym.ldots = '{/Symbol \274}';
2406 sym.mid = '{/Symbol \275}';
2407 sym.aleph = '{/Symbol \300}';
2408 sym.Im = '{/Symbol \301}';
2409 sym.Re = '{/Symbol \302}';
2410 sym.wp = '{/Symbol \303}';
2411 sym.otimes = '{/Symbol \304}';
2412 sym.oplus = '{/Symbol \305}';
2413 sym.oslash = '{/Symbol \306}';
2414 sym.cap = '{/Symbol \307}';
2415 sym.cup = '{/Symbol \310}';
2416 sym.supset = '{/Symbol \311}';
2417 sym.supseteq = '{/Symbol \312}';
2418 sym.subset = '{/Symbol \314}';
2419 sym.subseteq = '{/Symbol \315}';
2420 sym.in = '{/Symbol \316}';
2421 sym.notin = '{/Symbol \317}';
2422 sym.angle = '{/Symbol \320}';
2423 sym.bigtriangledown = '{/Symbol \321}';
2424 sym.langle = '{/Symbol \341}';
2425 sym.rangle = '{/Symbol \361}';
2426 sym.nabla = '{/Symbol \321}';
2427 sym.prod = '{/Symbol \325}';
2428 sym.surd = '{/Symbol \326}';
2429 sym.cdot = '{/Symbol \327}';
2430 sym.neg = '{/Symbol \330}';
2431 sym.wedge = '{/Symbol \331}';
2432 sym.vee = '{/Symbol \332}';
2433 sym.Leftrightarrow = '{/Symbol \333}';
2434 sym.Leftarrow = '{/Symbol \334}';
2435 sym.Uparrow = '{/Symbol \335}';
2436 sym.Rightarrow = '{/Symbol \336}';
2437 sym.Downarrow = '{/Symbol \337}';
2438 sym.diamond = '{/Symbol \340}';
2439 sym.copyright = '{/Symbol \343}';
2440 sym.lfloor = '{/Symbol \353}';
2441 sym.lceil = '{/Symbol \351}';
2442 sym.rfloor = '{/Symbol \373}';
2443 sym.rceil = '{/Symbol \371}';
2444 sym.int = '{/Symbol \362}';
2445 endfunction
2446
2447 function retval = __do_enhanced_option__ (enhanced, obj)
2448 retval = "";
2449 if (enhanced)
2450 if (strcmpi (obj.interpreter, "none"))
2451 retval = "noenhanced";
2452 else
2453 retval = "enhanced";
2454 endif
2455 endif
2456 endfunction