Mercurial > hg > octave-lyh
annotate scripts/plot/__go_draw_axes__.m @ 7513:05eb3486f650
__stepimp__: don't call subplot for single plot
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Feb 2008 04:05:36 -0500 |
parents | f3e6ada67d9e |
children | 3422f39573b1 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 2005, 2007 John W. Eaton |
6405 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6405 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6405 | 18 |
6895 | 19 ## Undocumented internal function. |
6405 | 20 |
21 ## Author: jwe | |
22 | |
7269 | 23 function __go_draw_axes__ (h, plot_stream, enhanced, mono) |
6405 | 24 |
7269 | 25 if (nargin == 4) |
6405 | 26 |
7379 | 27 axis_obj = __get__ (h); |
6405 | 28 |
29 parent_figure_obj = get (axis_obj.parent); | |
30 | |
6413 | 31 persistent have_newer_gnuplot ... |
32 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
6405 | 33 |
34 ## Set axis properties here? | |
7191 | 35 pos = [0, 0, 1, 1]; |
7240 | 36 if (strcmp (axis_obj.activepositionproperty, "outerposition")) |
37 ymirror = true; | |
38 if (! isempty (axis_obj.outerposition)) | |
39 pos = axis_obj.outerposition; | |
40 endif | |
41 else | |
7206 | 42 ymirror = false; |
7240 | 43 if (! isempty (axis_obj.position)) |
44 pos = axis_obj.position; | |
45 fprintf (plot_stream, "set tmargin 0;\n"); | |
46 fprintf (plot_stream, "set bmargin 0;\n"); | |
47 fprintf (plot_stream, "set lmargin 0;\n"); | |
48 fprintf (plot_stream, "set rmargin 0;\n"); | |
49 endif | |
6405 | 50 endif |
51 | |
7189 | 52 if (! strcmp (axis_obj.__colorbar__, "none")) |
53 [pos, cbox_orient, cbox_size, cbox_origin, cbox_mirror] = ... | |
54 gnuplot_postion_colorbox (pos, axis_obj.__colorbar__); | |
55 endif | |
56 | |
57 fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2)); | |
58 fprintf (plot_stream, "set size %.15g, %.15g;\n", pos(3), pos(4)); | |
59 | |
6758 | 60 if (strcmpi (axis_obj.dataaspectratiomode, "manual")) |
6405 | 61 r = axis_obj.dataaspectratio; |
6914 | 62 fprintf (plot_stream, "set size ratio %.15g;\n", -r(2)/r(1)); |
6405 | 63 else |
64 fputs (plot_stream, "set size noratio;\n"); | |
65 endif | |
66 | |
7472
2d8315dcd8d2
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
7471
diff
changeset
|
67 fputs (plot_stream, "set pm3d implicit;\n"); |
6778 | 68 fputs (plot_stream, "unset label;\n"); |
69 | |
6405 | 70 if (! isempty (axis_obj.title)) |
71 t = get (axis_obj.title); | |
72 if (isempty (t.string)) | |
73 fputs (plot_stream, "unset title;\n"); | |
74 else | |
7189 | 75 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
76 have_newer_gnuplot); | |
7257 | 77 if (strcmp (f, "*")) |
78 fontspec = ""; | |
79 else | |
80 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
81 endif | |
7390 | 82 fprintf (plot_stream, "set title \"%s\" %s %s;\n", |
83 undo_string_escapes (tt), fontspec, | |
84 __do_enhanced_option__ (enhanced, t)); | |
6405 | 85 endif |
86 endif | |
87 | |
88 if (! isempty (axis_obj.xlabel)) | |
89 t = get (axis_obj.xlabel); | |
6737 | 90 angle = t.rotation; |
7269 | 91 colorspec = get_text_colorspec (axis_obj.xcolor, mono); |
6405 | 92 if (isempty (t.string)) |
7194 | 93 fprintf (plot_stream, "unset xlabel;\n"); |
94 fprintf (plot_stream, "unset x2label;\n"); | |
6405 | 95 else |
7189 | 96 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
97 have_newer_gnuplot); | |
7257 | 98 if (strcmp (f, "*")) |
99 fontspec = ""; | |
100 else | |
101 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
102 endif | |
7194 | 103 if (strcmpi (axis_obj.xaxislocation, "top")) |
7390 | 104 fprintf (plot_stream, "set x2label \"%s\" %s %s %s", |
105 undo_string_escapes (tt), colorspec, fontspec, | |
106 __do_enhanced_option__ (enhanced, t)); | |
7194 | 107 else |
7390 | 108 fprintf (plot_stream, "set xlabel \"%s\" %s %s %s", |
109 undo_string_escapes (tt), colorspec, fontspec, | |
110 __do_enhanced_option__ (enhanced, t)); | |
7194 | 111 endif |
6738 | 112 if (have_newer_gnuplot) |
113 ## Rotation of xlabel not yet support by gnuplot as of 4.2, but | |
114 ## there is no message about it. | |
115 fprintf (plot_stream, " rotate by %f", angle); | |
116 endif | |
117 fputs (plot_stream, ";\n"); | |
7194 | 118 if (strcmpi (axis_obj.xaxislocation, "top")) |
119 fprintf (plot_stream, "unset xlabel;\n"); | |
120 else | |
121 fprintf (plot_stream, "unset x2label;\n"); | |
122 endif | |
6405 | 123 endif |
124 endif | |
125 | |
126 if (! isempty (axis_obj.ylabel)) | |
127 t = get (axis_obj.ylabel); | |
6737 | 128 angle = t.rotation; |
7269 | 129 colorspec = get_text_colorspec (axis_obj.ycolor, mono); |
6405 | 130 if (isempty (t.string)) |
7194 | 131 fprintf (plot_stream, "unset ylabel;\n"); |
132 fprintf (plot_stream, "unset y2label;\n"); | |
6405 | 133 else |
7189 | 134 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
135 have_newer_gnuplot); | |
7257 | 136 if (strcmp (f, "*")) |
137 fontspec = ""; | |
138 else | |
139 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
140 endif | |
7194 | 141 if (strcmpi (axis_obj.yaxislocation, "right")) |
7390 | 142 fprintf (plot_stream, "set y2label \"%s\" %s %s %s", |
143 undo_string_escapes (tt), colorspec, fontspec, | |
144 __do_enhanced_option__ (enhanced, t)); | |
7194 | 145 else |
7390 | 146 fprintf (plot_stream, "set ylabel \"%s\" %s %s %s", |
147 undo_string_escapes (tt), colorspec, fontspec, | |
148 __do_enhanced_option__ (enhanced, t)); | |
7194 | 149 endif |
6738 | 150 if (have_newer_gnuplot) |
6766 | 151 fprintf (plot_stream, " rotate by %f;\n", angle); |
6738 | 152 endif |
153 fputs (plot_stream, ";\n"); | |
7194 | 154 if (strcmpi (axis_obj.yaxislocation, "right")) |
155 fprintf (plot_stream, "unset ylabel;\n"); | |
156 else | |
157 fprintf (plot_stream, "unset y2label;\n"); | |
158 endif | |
6405 | 159 endif |
160 endif | |
161 | |
162 if (! isempty (axis_obj.zlabel)) | |
163 t = get (axis_obj.zlabel); | |
6737 | 164 angle = t.rotation; |
7269 | 165 colorspec = get_text_colorspec (axis_obj.zcolor, mono); |
6405 | 166 if (isempty (t.string)) |
167 fputs (plot_stream, "unset zlabel;\n"); | |
168 else | |
7189 | 169 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
170 have_newer_gnuplot); | |
7257 | 171 if (strcmp (f, "*")) |
172 fontspec = ""; | |
173 else | |
174 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
175 endif | |
7390 | 176 fprintf (plot_stream, "set zlabel \"%s\" %s %s %s", |
177 undo_string_escapes (tt), colorspec, fontspec, | |
178 __do_enhanced_option__ (enhanced, t)); | |
6738 | 179 if (have_newer_gnuplot) |
180 ## Rotation of zlabel not yet support by gnuplot as of 4.2, but | |
181 ## there is no message about it. | |
182 fprintf (plot_stream, " rotate by %f;\n", angle); | |
183 endif | |
184 fputs (plot_stream, ";\n"); | |
6405 | 185 endif |
186 endif | |
187 | |
6809 | 188 if (strcmpi (axis_obj.xaxislocation, "top")) |
189 xaxisloc = "x2"; | |
190 xaxisloc_using = "x2"; | |
191 else | |
192 xaxisloc = "x"; | |
193 xaxisloc_using = "x1"; | |
7321 | 194 if (strcmpi (axis_obj.xaxislocation, "zero")) |
195 fputs (plot_stream, "set xzeroaxis;\n"); | |
196 endif | |
6809 | 197 endif |
198 if (strcmpi (axis_obj.yaxislocation, "right")) | |
199 yaxisloc = "y2"; | |
200 yaxisloc_using = "y2"; | |
201 else | |
202 yaxisloc = "y"; | |
203 yaxisloc_using = "y1"; | |
7321 | 204 if (strcmpi (axis_obj.yaxislocation, "zero")) |
205 fputs (plot_stream, "set yzeroaxis;\n"); | |
206 endif | |
6809 | 207 endif |
208 | |
7274 | 209 have_grid = false; |
210 | |
6758 | 211 if (strcmpi (axis_obj.xgrid, "on")) |
7274 | 212 have_grid = true; |
6809 | 213 fprintf (plot_stream, "set grid %stics;\n", xaxisloc); |
6405 | 214 else |
6809 | 215 fprintf (plot_stream, "set grid no%stics;\n", xaxisloc); |
6405 | 216 endif |
217 | |
6758 | 218 if (strcmpi (axis_obj.ygrid, "on")) |
7274 | 219 have_grid = true; |
6809 | 220 fprintf (plot_stream, "set grid %stics;\n", yaxisloc); |
6405 | 221 else |
6809 | 222 fprintf (plot_stream, "set grid no%stics;\n", yaxisloc); |
6405 | 223 endif |
224 | |
6758 | 225 if (strcmpi (axis_obj.zgrid, "on")) |
7274 | 226 have_grid = true; |
6405 | 227 fputs (plot_stream, "set grid ztics;\n"); |
228 else | |
7085 | 229 fputs (plot_stream, "set grid noztics;\n"); |
6405 | 230 endif |
231 | |
6758 | 232 if (strcmpi (axis_obj.xminorgrid, "on")) |
7274 | 233 have_grid = true; |
6809 | 234 fprintf (plot_stream, "set m%stics 5;\n", xaxisloc); |
235 fprintf (plot_stream, "set grid m%stics;\n", xaxisloc); | |
6405 | 236 else |
6809 | 237 fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc); |
6405 | 238 endif |
239 | |
6758 | 240 if (strcmpi (axis_obj.yminorgrid, "on")) |
7274 | 241 have_grid = true; |
6809 | 242 fprintf (plot_stream, "set m%stics 5;\n", yaxisloc); |
243 fprintf (plot_stream, "set grid m%stics;\n", yaxisloc); | |
6405 | 244 else |
6809 | 245 fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc); |
6405 | 246 endif |
247 | |
6758 | 248 if (strcmpi (axis_obj.zminorgrid, "on")) |
7274 | 249 have_grid = true; |
6405 | 250 fputs (plot_stream, "set mztics 5;\n"); |
251 fputs (plot_stream, "set grid mztics;\n"); | |
252 else | |
253 fputs (plot_stream, "set grid nomztics;\n"); | |
254 endif | |
255 | |
7307 | 256 ## The grid front/back/layerdefault option also controls the |
257 ## appearance of tics, so it is used even if the grid is absent. | |
258 if (strcmpi (axis_obj.layer, "top")) | |
259 fputs (plot_stream, "set grid front;\n"); | |
260 else | |
261 fputs (plot_stream, "set grid layerdefault;\n"); | |
262 endif | |
7297 | 263 if (! have_grid) |
264 fputs (plot_stream, "unset grid;\n"); | |
7274 | 265 endif |
266 | |
7269 | 267 do_tics (axis_obj, plot_stream, ymirror, mono); |
6405 | 268 |
6758 | 269 xlogscale = strcmpi (axis_obj.xscale, "log"); |
6405 | 270 if (xlogscale) |
6809 | 271 fprintf (plot_stream, "set logscale %s;\n", xaxisloc); |
6405 | 272 else |
6809 | 273 fprintf (plot_stream, "unset logscale %s;\n", xaxisloc); |
6405 | 274 endif |
275 | |
6758 | 276 ylogscale = strcmpi (axis_obj.yscale, "log"); |
6405 | 277 if (ylogscale) |
6809 | 278 fprintf (plot_stream, "set logscale %s;\n", yaxisloc); |
6405 | 279 else |
6809 | 280 fprintf (plot_stream, "unset logscale %s;\n", yaxisloc); |
6405 | 281 endif |
282 | |
6758 | 283 zlogscale = strcmpi (axis_obj.zscale, "log"); |
6405 | 284 if (zlogscale) |
285 fputs (plot_stream, "set logscale z;\n"); | |
286 else | |
287 fputs (plot_stream, "unset logscale z;\n"); | |
288 endif | |
289 | |
6758 | 290 xautoscale = strcmpi (axis_obj.xlimmode, "auto"); |
291 yautoscale = strcmpi (axis_obj.ylimmode, "auto"); | |
292 zautoscale = strcmpi (axis_obj.zlimmode, "auto"); | |
7109 | 293 cautoscale = strcmpi (axis_obj.climmode, "auto"); |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
294 cdatadirect = false; |
6405 | 295 |
296 kids = axis_obj.children; | |
297 | |
7316 | 298 nd = __calc_dimensions__ (axis_obj); |
299 | |
300 if (nd == 3) | |
301 fputs (plot_stream, "set parametric;\n"); | |
302 fputs (plot_stream, "set style data lines;\n"); | |
303 fputs (plot_stream, "set surface;\n"); | |
304 fputs (plot_stream, "unset contour;\n"); | |
305 endif | |
306 | |
6405 | 307 data_idx = 0; |
308 data = cell (); | |
6464 | 309 is_image_data = []; |
7175 | 310 hidden_removal = NaN; |
7271 | 311 view_map = false; |
6405 | 312 |
7223 | 313 xlim = axis_obj.xlim; |
314 ylim = axis_obj.ylim; | |
315 zlim = axis_obj.zlim; | |
316 clim = axis_obj.clim; | |
6405 | 317 |
7222 | 318 if (! cautoscale && clim(1) == clim(2)) |
319 clim(2)++; | |
7189 | 320 endif |
321 | |
6405 | 322 [view_cmd, view_fcn, view_zoom] = image_viewer (); |
323 use_gnuplot_for_images = (ischar (view_fcn) | |
324 && strcmp (view_fcn, "gnuplot_internal")); | |
325 | |
326 ximg_data = {}; | |
327 ximg_data_idx = 0; | |
328 | |
329 for i = 1:length (kids) | |
330 | |
331 obj = get (kids(i)); | |
332 | |
333 switch (obj.type) | |
334 case "image" | |
335 img_data = obj.cdata; | |
336 img_xdata = obj.xdata; | |
337 img_ydata = obj.ydata; | |
338 | |
339 if (use_gnuplot_for_images) | |
340 | |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
341 if (strcmp (obj.cdatamapping, "direct")) |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
342 cdatadirect = true; |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
343 endif |
7271 | 344 fputs (plot_stream, "set border front;\n"); |
6405 | 345 data_idx++; |
6464 | 346 is_image_data(data_idx) = true; |
6861 | 347 parametric(data_idx) = false; |
7119 | 348 have_cdata(data_idx) = false; |
6405 | 349 |
350 [y_dim, x_dim] = size (img_data(:,:,1)); | |
351 if (x_dim > 1) | |
352 dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); | |
353 else | |
354 dx = 1; | |
355 endif | |
356 if (y_dim > 1) | |
357 dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); | |
358 else | |
359 dy = 1; | |
360 endif | |
361 x_origin = min (img_xdata); | |
362 y_origin = min (img_ydata); | |
363 | |
364 if (ndims (img_data) == 3) | |
6464 | 365 data{data_idx} = permute (img_data, [3, 1, 2])(:); |
6405 | 366 format = "1:2:3"; |
367 imagetype = "rgbimage"; | |
368 else | |
6464 | 369 data{data_idx} = img_data(:); |
6405 | 370 format = "1"; |
371 imagetype = "image"; | |
372 endif | |
373 | |
6579 | 374 titlespec{data_idx} = "title \"\""; |
6914 | 375 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s", |
6405 | 376 x_dim, y_dim, x_origin, y_origin, dx, dy, format); |
377 withclause{data_idx} = sprintf ("with %s", imagetype); | |
378 | |
379 else | |
380 ximg_data{++ximg_data_idx} = img_data; | |
381 endif | |
382 | |
383 case "line" | |
7120 | 384 if (strncmp (obj.linestyle, "none", 4) |
385 && (! isfield (obj, "marker") | |
386 || (isfield (obj, "marker") | |
387 && strncmp (obj.marker, "none", 4)))) | |
388 continue; | |
389 endif | |
6405 | 390 data_idx++; |
6464 | 391 is_image_data(data_idx) = false; |
6861 | 392 parametric(data_idx) = true; |
7119 | 393 have_cdata(data_idx) = false; |
6405 | 394 if (isempty (obj.keylabel)) |
395 titlespec{data_idx} = "title \"\""; | |
396 else | |
7189 | 397 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7094 | 398 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
6405 | 399 endif |
400 usingclause{data_idx} = ""; | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
401 errbars = ""; |
7316 | 402 if (nd == 3) |
6405 | 403 xdat = obj.xdata(:); |
404 ydat = obj.ydata(:); | |
7316 | 405 if (! isempty (obj.zdata)) |
406 zdat = obj.zdata(:); | |
407 else | |
408 zdat = zeros (size (xdat)); | |
409 endif | |
6405 | 410 data{data_idx} = [xdat, ydat, zdat]'; |
411 usingclause{data_idx} = "using ($1):($2):($3)"; | |
7316 | 412 ## fputs (plot_stream, "set parametric;\n"); |
6405 | 413 else |
414 xdat = obj.xdata(:); | |
415 ydat = obj.ydata(:); | |
416 ldat = obj.ldata; | |
417 yerr = xerr = false; | |
418 if (! isempty (ldat)) | |
419 yerr = true; | |
420 ldat = ldat(:); | |
421 endif | |
422 udat = obj.udata; | |
423 if (! isempty (udat)) | |
424 udat = udat(:); | |
425 endif | |
426 xldat = obj.xldata; | |
427 if (! isempty (xldat)) | |
428 xerr = true; | |
429 xldat = xldat(:); | |
430 endif | |
431 xudat = obj.xudata; | |
432 if (! isempty (xudat)) | |
433 xudat = xudat(:); | |
434 endif | |
435 if (yerr) | |
7213 | 436 if (isempty (ldat)) |
437 ylo = ydat; | |
438 else | |
439 ylo = ydat-ldat; | |
440 endif | |
441 if (isempty (udat)) | |
442 yhi = ydat; | |
443 else | |
444 yhi = ydat+udat; | |
445 endif | |
6405 | 446 if (xerr) |
7213 | 447 if (isempty (xldat)) |
448 xlo = xdat; | |
449 else | |
450 xlo = xdat-xldat; | |
451 endif | |
452 if (isempty (xudat)) | |
453 xhi = xdat; | |
454 else | |
455 xhi = xdat+xudat; | |
456 endif | |
6405 | 457 data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; |
458 usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
459 errbars = "xyerrorbars"; |
6405 | 460 else |
461 data{data_idx} = [xdat, ydat, ylo, yhi]'; | |
462 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
463 errbars = "yerrorbars"; |
6405 | 464 endif |
465 elseif (xerr) | |
7236 | 466 if (isempty (xldat)) |
467 xlo = xdat; | |
468 else | |
469 xlo = xdat-xldat; | |
470 endif | |
471 if (isempty (xudat)) | |
472 xhi = xdat; | |
473 else | |
474 xhi = xdat+xudat; | |
475 endif | |
6405 | 476 data{data_idx} = [xdat, ydat, xlo, xhi]'; |
477 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
478 errbars = "xerrorbars"; |
6405 | 479 else |
480 data{data_idx} = [xdat, ydat]'; | |
6809 | 481 usingclause{data_idx} = sprintf ("using ($1):($2) axes %s%s", |
482 xaxisloc_using, yaxisloc_using); | |
6405 | 483 endif |
484 endif | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
485 |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
486 [style, typ, with] = do_linestyle_command (obj, data_idx, mono, |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
487 plot_stream, errbars); |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
488 |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
489 if (have_newer_gnuplot || isnan (typ)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
490 withclause{data_idx} = sprintf ("with %s linestyle %d", |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
491 style, data_idx); |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
492 else |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
493 withclause{data_idx} = sprintf ("with %s linetype %d", |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
494 style, typ); |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
495 endif |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
496 |
6465 | 497 if (! (have_newer_gnuplot || isempty (with))) |
498 if (isempty (withclause{data_idx})) | |
6809 | 499 withclause{data_idx} = sprintf ("with %s", with); |
6465 | 500 else |
6809 | 501 withclause{data_idx} = sprintf ("%s %s", withclause{data_idx}, |
502 with); | |
6465 | 503 endif |
504 endif | |
6405 | 505 |
6790 | 506 case "patch" |
6885 | 507 cmap = parent_figure_obj.colormap; |
7020 | 508 [nr, nc] = size (obj.xdata); |
509 | |
7189 | 510 if (! isempty (obj.cdata)) |
511 cdat = obj.cdata; | |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
512 if (strcmp (obj.cdatamapping, "direct")) |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
513 cdatadirect = true; |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
514 endif |
7189 | 515 else |
516 cdat = []; | |
517 endif | |
518 | |
7170 | 519 for i = 1:nc |
7020 | 520 xcol = obj.xdata(:,i); |
521 ycol = obj.ydata(:,i); | |
7316 | 522 if (nd == 3) |
523 if (! isempty (obj.zdata)) | |
524 zcol = obj.zdata(:,i); | |
525 else | |
526 zcol = zeros (size (xcol)); | |
527 endif | |
7170 | 528 endif |
7020 | 529 |
530 if (! isnan (xcol) && ! isnan (ycol)) | |
531 ## Is the patch closed or not | |
7175 | 532 if (strncmp (obj.facecolor, "none", 4)) |
7318 | 533 hidden_removal = false; |
534 else | |
7175 | 535 if (isnan (hidden_removal)) |
7318 | 536 hidden_removal = true; |
7175 | 537 endif |
7316 | 538 if (nd == 3) |
7170 | 539 error ("gnuplot (as of v4.2) only supports 2D filled patches"); |
540 endif | |
541 | |
542 data_idx++; | |
543 is_image_data(data_idx) = false; | |
544 parametric(data_idx) = false; | |
545 have_cdata(data_idx) = false; | |
546 if (i > 1 || isempty (obj.keylabel)) | |
547 titlespec{data_idx} = "title \"\""; | |
548 else | |
7189 | 549 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7170 | 550 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
551 endif | |
552 usingclause{data_idx} = ""; | |
7189 | 553 if (isfield (obj, "facecolor")) |
554 if ((strncmp (obj.facecolor, "flat", 4) | |
7284 | 555 || strncmp (obj.facecolor, "interp", 6)) |
556 && isfield (obj, "cdata")) | |
7170 | 557 if (ndims (obj.cdata) == 2 |
7189 | 558 && (size (obj.cdata, 2) == nc |
559 && (size (obj.cdata, 1) == 1 | |
560 || size (obj.cdata, 1) == 3))) | |
561 ccol = cdat (:, i); | |
562 elseif (ndims (obj.cdata) == 2 | |
563 && (size (obj.cdata, 1) == nc | |
564 && (size (obj.cdata, 2) == 1 | |
565 || size (obj.cdata, 2) == 3))) | |
566 ccol = cdat (i, :); | |
7170 | 567 elseif (ndims (obj.cdata) == 3) |
7189 | 568 ccol = permute (cdat (:, i, :), [1, 3, 2]); |
7170 | 569 else |
7189 | 570 ccol = cdat; |
7170 | 571 endif |
572 if (strncmp (obj.facecolor, "flat", 4)) | |
573 if (numel(ccol) == 3) | |
574 color = ccol; | |
575 else | |
7226 | 576 r = 1 + round ((size (cmap, 1) - 1) |
577 * (ccol - clim(1))/(clim(2) - clim(1))); | |
7170 | 578 r = max (1, min (r, size (cmap, 1))); |
579 color = cmap(r, :); | |
580 endif | |
581 elseif (strncmp (obj.facecolor, "interp", 6)) | |
582 warning ("\"interp\" not supported, using 1st entry of cdata") | |
583 r = 1 + round ((size (cmap, 1) - 1) * ccol(1)); | |
584 r = max (1, min (r, size (cmap, 1))); | |
585 color = cmap(r,:); | |
586 endif | |
7189 | 587 elseif (isnumeric (obj.facecolor)) |
588 color = obj.facecolor; | |
7170 | 589 else |
7189 | 590 color = [0, 1, 0]; |
7170 | 591 endif |
592 else | |
593 color = [0, 1, 0]; | |
594 endif | |
595 | |
596 if (have_newer_gnuplot) | |
7269 | 597 if (mono) |
598 colorspec = ""; | |
599 else | |
600 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
601 round (255*color)); | |
602 endif | |
603 withclause{data_idx} = sprintf ("with filledcurve %s", | |
604 colorspec); | |
7170 | 605 else |
606 if (isequal (color, [0,0,0])) | |
607 typ = -1; | |
608 elseif (isequal (color, [1,0,0])) | |
609 typ = 1; | |
610 elseif (isequal (color, [0,1,0])) | |
611 typ = 2; | |
612 elseif (isequal (color, [0,0,1])) | |
613 typ = 3; | |
614 elseif (isequal (color, [1,0,1])) | |
615 typ = 4; | |
616 elseif (isequal (color, [0,1,1])) | |
617 typ = 5; | |
618 elseif (isequal (color, [1,1,1])) | |
619 typ = -1; | |
620 elseif (isequal (color, [1,1,0])) | |
621 typ = 7; | |
622 else | |
623 typ = -1; | |
624 endif | |
625 withclause{data_idx} = sprintf ("with filledcurve lt %d", typ); | |
626 endif | |
627 data{data_idx} = [xcol, ycol]'; | |
628 usingclause{data_idx} = "using ($1):($2)"; | |
629 endif | |
630 endif | |
631 | |
632 ## patch outline | |
633 if (! strncmp (obj.edgecolor, "none", 4)) | |
634 | |
635 data_idx++; | |
636 is_image_data(data_idx) = false; | |
637 parametric(data_idx) = false; | |
638 have_cdata(data_idx) = false; | |
639 titlespec{data_idx} = "title \"\""; | |
7020 | 640 usingclause{data_idx} = ""; |
7189 | 641 |
642 if (isfield (obj, "markersize")) | |
643 mdat = obj.markersize; | |
644 endif | |
645 | |
646 if (isfield (obj, "edgecolor")) | |
647 if ((strncmp (obj.edgecolor, "flat", 4) | |
7284 | 648 || strncmp (obj.edgecolor, "interp", 6)) |
649 && isfield (obj, "cdata")) | |
7119 | 650 if (ndims (obj.cdata) == 2 |
7189 | 651 && (size (obj.cdata, 2) == nc |
652 && (size (obj.cdata, 1) == 1 | |
653 || size (obj.cdata, 1) == 3))) | |
654 ccol = cdat (:, i); | |
655 elseif (ndims (obj.cdata) == 2 | |
656 && (size (obj.cdata, 1) == nc | |
657 && (size (obj.cdata, 2) == 1 | |
658 || size (obj.cdata, 2) == 3))) | |
659 ccol = cdat (i, :); | |
7020 | 660 elseif (ndims (obj.cdata) == 3) |
7189 | 661 ccol = permute (cdat (:, i, :), [1, 3, 2]); |
7020 | 662 else |
7189 | 663 ccol = cdat; |
7020 | 664 endif |
7170 | 665 if (strncmp (obj.edgecolor, "flat", 4)) |
7189 | 666 if (numel(ccol) == 3) |
7020 | 667 color = ccol; |
668 else | |
7226 | 669 r = 1 + round ((size (cmap, 1) - 1) |
670 * (ccol - clim(1))/(clim(2) - clim(1))); | |
7020 | 671 r = max (1, min (r, size (cmap, 1))); |
672 color = cmap(r, :); | |
673 endif | |
7170 | 674 elseif (strncmp (obj.edgecolor, "interp", 6)) |
7020 | 675 warning ("\"interp\" not supported, using 1st entry of cdata") |
676 r = 1 + round ((size (cmap, 1) - 1) * ccol(1)); | |
677 r = max (1, min (r, size (cmap, 1))); | |
678 color = cmap(r,:); | |
679 endif | |
7189 | 680 elseif (isnumeric (obj.edgecolor)) |
681 color = obj.edgecolor; | |
682 else | |
683 color = [0, 0, 0]; | |
7020 | 684 endif |
685 else | |
7189 | 686 color = [0, 0, 0]; |
7020 | 687 endif |
7189 | 688 |
689 if (isfield (obj, "linestyle")) | |
690 switch (obj.linestyle) | |
691 case "-" | |
7317 | 692 lt = "lt 1"; |
7189 | 693 case "--" |
7317 | 694 lt = "lt 2"; |
7189 | 695 case ":" |
7317 | 696 lt = "lt 3"; |
7189 | 697 case "-." |
7317 | 698 lt = "lt 6"; |
7189 | 699 case "none" |
700 lt = ""; | |
701 otherwise | |
702 lt = ""; | |
703 endswitch | |
704 else | |
705 lt = ""; | |
706 endif | |
707 | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
708 if (isfield (obj, "linewidth")) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
709 if (have_newer_gnuplot) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
710 lw = sprintf("linewidth %f", obj.linewidth); |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
711 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
712 lw = sprintf("lw %f", obj.linewidth); |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
713 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
714 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
715 lw = ""; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
716 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
717 |
7189 | 718 if (isfield (obj, "marker")) |
719 if (isfield (obj, "marker")) | |
720 switch (obj.marker) | |
721 case "+" | |
722 pt = "pt 1"; | |
723 case "o" | |
724 pt = "pt 6"; | |
725 case "*" | |
726 pt = "pt 3"; | |
727 case "." | |
728 pt = "pt 0"; | |
729 case "x" | |
730 pt = "pt 2"; | |
731 case {"square", "s"} | |
732 pt = "pt 5"; | |
733 case {"diamond", "d"} | |
734 pt = "pt 13"; | |
735 case "^" | |
736 pt = "pt 9"; | |
737 case "v" | |
738 pt = "pt 11"; | |
739 case ">" | |
740 pt = "pt 8"; | |
741 case "<" | |
742 pt = "pt 10"; | |
743 case {"pentagram", "p"} | |
744 pt = "pt 4"; | |
745 case {"hexagram", "h"} | |
746 pt = "pt 12"; | |
747 case "none" | |
748 pt = ""; | |
749 otherwise | |
750 pt = ""; | |
751 endswitch | |
752 endif | |
753 else | |
754 pt = ""; | |
755 endif | |
756 | |
757 style = "lines"; | |
758 if (isempty (lt)) | |
759 if (! isempty (pt)) | |
760 style = "points"; | |
761 endif | |
762 elseif (! isempty (pt)) | |
763 style = "linespoints"; | |
764 endif | |
765 | |
766 if (isfield (obj, "markersize")) | |
767 if (length (mdat) == nc) | |
768 m = mdat(i); | |
769 else | |
770 m = mdat; | |
771 endif | |
772 if (! strcmpi (style, "lines")) | |
773 if (have_newer_gnuplot) | |
774 ps = sprintf("pointsize %f", m); | |
775 else | |
776 ps = sprintf("ps %f", m); | |
777 endif | |
778 else | |
779 ps = ""; | |
780 endif | |
781 else | |
782 ps = ""; | |
783 endif | |
784 | |
7020 | 785 if (have_newer_gnuplot) |
7269 | 786 if (mono) |
787 colorspec = ""; | |
788 else | |
789 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
790 round (255*color)); | |
791 endif | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
792 withclause{data_idx} = sprintf ("with %s %s %s %s %s %s", |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
793 style, lw, pt, lt, ps, |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
794 colorspec); |
7020 | 795 else |
796 if (isequal (color, [0,0,0])) | |
797 typ = -1; | |
798 elseif (isequal (color, [1,0,0])) | |
799 typ = 1; | |
800 elseif (isequal (color, [0,1,0])) | |
801 typ = 2; | |
802 elseif (isequal (color, [0,0,1])) | |
803 typ = 3; | |
804 elseif (isequal (color, [1,0,1])) | |
805 typ = 4; | |
806 elseif (isequal (color, [0,1,1])) | |
807 typ = 5; | |
808 elseif (isequal (color, [1,1,1])) | |
809 typ = -1; | |
810 elseif (isequal (color, [1,1,0])) | |
811 typ = 7; | |
812 else | |
813 typ = -1; | |
814 endif | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
815 withclause{data_idx} = sprintf ("with %s %s %s %s lt %d", |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
816 style, lw, pt, ps, typ); |
7020 | 817 endif |
6790 | 818 |
7316 | 819 if (nd == 3) |
7170 | 820 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) |
821 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... | |
822 [zcol; zcol(1)]]'; | |
823 else | |
824 data{data_idx} = [xcol, ycol, zcol]'; | |
825 endif | |
826 usingclause{data_idx} = "using ($1):($2):($3)"; | |
7020 | 827 else |
7170 | 828 if (! isnan (xcol) && ! isnan (ycol)) |
829 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; | |
830 else | |
831 data{data_idx} = [xcol, ycol]'; | |
832 endif | |
833 usingclause{data_idx} = "using ($1):($2)"; | |
7020 | 834 endif |
6885 | 835 endif |
7020 | 836 endfor |
6790 | 837 |
6405 | 838 case "surface" |
7271 | 839 view_map = true; |
7110 | 840 if (! (strncmp (obj.edgecolor, "none", 4) |
841 && strncmp (obj.facecolor, "none", 4))) | |
7109 | 842 data_idx++; |
843 is_image_data(data_idx) = false; | |
844 parametric(data_idx) = false; | |
7119 | 845 have_cdata(data_idx) = true; |
7170 | 846 [style, typ, with] = do_linestyle_command (obj, data_idx, |
7269 | 847 mono, plot_stream); |
7109 | 848 if (isempty (obj.keylabel)) |
849 titlespec{data_idx} = "title \"\""; | |
850 else | |
7189 | 851 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7109 | 852 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
853 endif | |
854 usingclause{data_idx} = ""; | |
855 if (have_newer_gnuplot || isnan (typ)) | |
7318 | 856 withclause{data_idx} = sprintf ("with pm3d linestyle %d", |
857 data_idx); | |
6405 | 858 else |
7318 | 859 withclause{data_idx} = sprintf ("with pm3d linetype %d %s", |
860 typ, with); | |
7109 | 861 endif |
862 | |
863 xdat = obj.xdata; | |
864 ydat = obj.ydata; | |
865 zdat = obj.zdata; | |
866 cdat = obj.cdata; | |
7110 | 867 |
7109 | 868 err = false; |
869 if (! size_equal(zdat, cdat)) | |
6405 | 870 err = true; |
7109 | 871 endif |
872 if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) | |
7110 | 873 if (rows (zdat) == length (ydat) |
874 && columns (zdat) == length (xdat)) | |
7109 | 875 [xdat, ydat] = meshgrid (xdat, ydat); |
876 else | |
877 err = true; | |
878 endif | |
879 elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) | |
7292 | 880 if (! size_equal (xdat, ydat, zdat)) |
7109 | 881 err = true; |
882 endif | |
883 else | |
884 err = true; | |
885 endif | |
886 if (err) | |
887 error ("__go_draw_axes__: invalid grid data"); | |
6405 | 888 endif |
7109 | 889 xlen = columns (zdat); |
890 ylen = rows (zdat); | |
891 if (xlen == columns (xdat) && xlen == columns (ydat) | |
892 && ylen == rows (xdat) && ylen == rows (ydat)) | |
893 len = 4 * xlen; | |
894 zz = zeros (ylen, len); | |
895 k = 1; | |
896 for kk = 1:4:len | |
897 zz(:,kk) = xdat(:,k); | |
898 zz(:,kk+1) = ydat(:,k); | |
899 zz(:,kk+2) = zdat(:,k); | |
900 zz(:,kk+3) = cdat(:,k); | |
901 k++; | |
902 endfor | |
7170 | 903 data{data_idx} = zz.'; |
7109 | 904 endif |
905 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
7316 | 906 ## fputs (plot_stream, "unset parametric;\n"); |
7109 | 907 |
7119 | 908 ## Interpolation does not work for flat surfaces (e.g. pcolor) |
909 ## and color mapping --> currently set empty. | |
910 interp_str = ""; | |
911 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) | |
912 || strncmp (obj.facecolor, "interp", 6)); | |
913 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) | |
914 || strncmp (obj.edgecolor, "interp", 6)); | |
7154 | 915 |
916 facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4) | |
917 || (isnumeric (obj.facecolor) | |
918 && all (obj.facecolor == 1))); | |
7149 | 919 if (strncmp (obj.facecolor, "none", 4)) |
7318 | 920 hidden_removal = false; |
7175 | 921 else |
7318 | 922 if (isnan (hidden_removal)) |
923 hidden_removal = true; | |
924 endif | |
7149 | 925 endif |
7318 | 926 |
927 if (flat_interp_edge && facecolor_none_or_white) | |
7189 | 928 withclause{data_idx} = "with line palette"; |
7119 | 929 endif |
7109 | 930 |
7189 | 931 if (have_newer_gnuplot) |
932 dord = "depthorder"; | |
933 else | |
934 dord = ""; | |
935 endif | |
7109 | 936 |
7318 | 937 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) |
938 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", | |
7189 | 939 interp_str, dord); |
7318 | 940 elseif (!facecolor_none_or_white) |
7119 | 941 if (strncmp (obj.edgecolor, "none", 4)) |
7318 | 942 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", |
7189 | 943 interp_str, dord); |
7109 | 944 else |
7119 | 945 edgecol = obj.edgecolor; |
946 if (ischar (obj.edgecolor)) | |
947 edgecol = [0,0,0]; | |
948 endif | |
7318 | 949 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", |
7189 | 950 data_idx, interp_str, dord); |
7119 | 951 |
952 if (have_newer_gnuplot) | |
7269 | 953 if (mono) |
954 colorspec = ""; | |
955 else | |
956 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", | |
957 round (255*edgecol)); | |
958 endif | |
7110 | 959 fprintf (plot_stream, |
7269 | 960 "set style line %d %s lw %f;\n", |
961 data_idx, colorspec, obj.linewidth); | |
7119 | 962 else |
963 if (isequal (edgecol, [0,0,0])) | |
964 typ = -1; | |
965 elseif (isequal (edgecol, [1,0,0])) | |
966 typ = 1; | |
967 elseif (isequal (edgecol, [0,1,0])) | |
968 typ = 2; | |
969 elseif (isequal (edgecol, [0,0,1])) | |
970 typ = 3; | |
971 elseif (isequal (edgecol, [1,0,1])) | |
972 typ = 4; | |
973 elseif (isequal (edgecol, [0,1,1])) | |
974 typ = 5; | |
975 elseif (isequal (edgecol, [1,1,1])) | |
976 typ = -1; | |
977 elseif (isequal (edgecol, [1,1,0])) | |
978 typ = 7; | |
979 else | |
980 typ = -1; | |
981 endif | |
982 fprintf (plot_stream, | |
983 "set style line %d lt %d lw %f;\n", | |
984 data_idx, typ, obj.linewidth); | |
985 endif | |
7109 | 986 endif |
7119 | 987 endif |
6405 | 988 endif |
989 | |
990 case "text" | |
7189 | 991 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string", |
992 have_newer_gnuplot); | |
7257 | 993 if (strcmp (f, "*")) |
994 fontspec = ""; | |
995 else | |
996 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
997 endif | |
6405 | 998 lpos = obj.position; |
999 halign = obj.horizontalalignment; | |
6724 | 1000 angle = obj.rotation; |
6752 | 1001 units = obj.units; |
6829 | 1002 color = obj.color; |
6758 | 1003 if (strcmpi (units, "normalized")) |
6752 | 1004 units = "graph"; |
1005 else | |
1006 units = ""; | |
1007 endif | |
1008 | |
6829 | 1009 if (isnumeric (color)) |
7269 | 1010 colorspec = get_text_colorspec (color, mono); |
6829 | 1011 endif |
1012 | |
6405 | 1013 if (nd == 3) |
6724 | 1014 fprintf (plot_stream, |
7390 | 1015 "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 1016 undo_string_escapes (label), units, lpos(1), |
7390 | 1017 lpos(2), lpos(3), halign, angle, fontspec, |
1018 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 1019 else |
7162 | 1020 fprintf (plot_stream, |
7390 | 1021 "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 1022 undo_string_escapes (label), units, |
7390 | 1023 lpos(1), lpos(2), halign, angle, fontspec, |
1024 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 1025 endif |
1026 | |
1027 otherwise | |
1028 error ("__go_draw_axes__: unknown object class, %s", | |
1029 obj.type); | |
1030 endswitch | |
1031 | |
1032 endfor | |
1033 | |
7175 | 1034 if (isnan(hidden_removal) || hidden_removal) |
7149 | 1035 fputs (plot_stream, "set hidden3d;\n"); |
1036 else | |
1037 fputs (plot_stream, "unset hidden3d;\n"); | |
1038 endif | |
1039 | |
7152 | 1040 have_data = (! (isempty (data) || any (cellfun (@isempty, data)))); |
6405 | 1041 |
7222 | 1042 if (isempty (xlim)) |
1043 return; | |
6405 | 1044 endif |
6758 | 1045 if (strcmpi (axis_obj.xdir, "reverse")) |
6405 | 1046 xdir = "reverse"; |
1047 else | |
1048 xdir = "noreverse"; | |
1049 endif | |
7115 | 1050 fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", |
1051 xaxisloc, xlim, xdir); | |
6405 | 1052 |
7222 | 1053 if (isempty (ylim)) |
1054 return; | |
6405 | 1055 endif |
6758 | 1056 if (strcmpi (axis_obj.ydir, "reverse")) |
6405 | 1057 ydir = "reverse"; |
1058 else | |
1059 ydir = "noreverse"; | |
1060 endif | |
7110 | 1061 fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", |
1062 yaxisloc, ylim, ydir); | |
6405 | 1063 |
7119 | 1064 if (nd == 3) |
7222 | 1065 if (isempty (zlim)) |
1066 return; | |
6405 | 1067 endif |
6758 | 1068 if (strcmpi (axis_obj.zdir, "reverse")) |
6405 | 1069 zdir = "reverse"; |
1070 else | |
1071 zdir = "noreverse"; | |
1072 endif | |
6942 | 1073 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); |
6405 | 1074 endif |
7110 | 1075 |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1076 cmap = parent_figure_obj.colormap; |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1077 cmap_sz = rows(cmap); |
7189 | 1078 if (! any (isinf (clim))) |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1079 if (cdatadirect) |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1080 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz); |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1081 else |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1082 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1083 endif |
7189 | 1084 endif |
1085 | |
6758 | 1086 if (strcmpi (axis_obj.box, "on")) |
7119 | 1087 if (nd == 3) |
6405 | 1088 fputs (plot_stream, "set border 4095;\n"); |
1089 else | |
1090 fputs (plot_stream, "set border 431;\n"); | |
1091 endif | |
1092 else | |
7119 | 1093 if (nd == 3) |
6405 | 1094 fputs (plot_stream, "set border 895;\n"); |
1095 else | |
7320 | 1096 if (strcmpi (axis_obj.yaxislocation, "right")) |
1097 fputs (plot_stream, "unset ytics; set y2tics nomirror\n"); | |
1098 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1099 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | |
1100 fputs (plot_stream, "set border 12;\n"); | |
1101 else | |
1102 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | |
1103 fputs (plot_stream, "set border 9;\n"); | |
1104 endif | |
1105 else | |
1106 fputs (plot_stream, "unset y2tics; set ytics nomirror\n"); | |
1107 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1108 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | |
1109 fputs (plot_stream, "set border 6;\n"); | |
1110 else | |
1111 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | |
1112 fputs (plot_stream, "set border 3;\n"); | |
1113 endif | |
1114 endif | |
6405 | 1115 endif |
1116 endif | |
1117 | |
7060 | 1118 if (strcmpi (axis_obj.visible, "off")) |
1119 fputs (plot_stream, "unset border; unset tics\n"); | |
1120 endif | |
1121 | |
6758 | 1122 if (strcmpi (axis_obj.key, "on")) |
1123 if (strcmpi (axis_obj.keybox, "on")) | |
6405 | 1124 box = "box"; |
1125 else | |
1126 box = "nobox"; | |
1127 endif | |
1128 inout = "inside"; | |
6977 | 1129 keypos = axis_obj.keypos; |
1130 if (ischar (keypos)) | |
1131 keypos = lower (keypos); | |
1132 keyout = findstr (keypos, "outside"); | |
1133 if (! isempty (keyout)) | |
1134 inout = "outside"; | |
7119 | 1135 keypos = keypos(1:keyout-1); |
6977 | 1136 endif |
1137 endif | |
1138 switch (keypos) | |
6405 | 1139 case -1 |
6977 | 1140 pos = "right top"; |
6405 | 1141 inout = "outside"; |
1142 case 1 | |
1143 pos = "right top"; | |
1144 case 2 | |
1145 pos = "left top"; | |
1146 case 3 | |
1147 pos = "left bottom"; | |
6977 | 1148 case {4, 0} |
6405 | 1149 pos = "right bottom"; |
6977 | 1150 case "north" |
1151 pos = "center top"; | |
1152 case "south" | |
1153 pos = "center bottom"; | |
1154 case "east" | |
1155 pos = "right center"; | |
1156 case "west" | |
1157 pos = "left center"; | |
1158 case "northeast" | |
1159 pos = "right top"; | |
1160 case "northwest" | |
1161 pos = "left top"; | |
1162 case "southeast" | |
1163 pos = "right bottom"; | |
1164 case "southwest" | |
1165 pos = "left bottom"; | |
1166 case "best" | |
1167 pos = ""; | |
1168 warning ("legend: 'Best' not yet implemented for location specifier.\n"); | |
1169 ## least conflict with data in plot | |
1170 ## least unused space outside plot | |
6405 | 1171 otherwise |
1172 pos = ""; | |
1173 endswitch | |
1174 if (! have_newer_gnuplot) | |
1175 inout = ""; | |
1176 endif | |
1177 fprintf (plot_stream, "set key %s %s %s;\n", inout, pos, box); | |
1178 else | |
1179 fputs (plot_stream, "unset key;\n"); | |
1180 endif | |
1181 | |
1182 fputs (plot_stream, "set style data lines;\n"); | |
1183 | |
1184 if (! use_gnuplot_for_images) | |
1185 for i = 1:ximg_data_idx | |
1186 view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd); | |
1187 endfor | |
1188 endif | |
1189 | |
7189 | 1190 if (length(cmap) > 0) |
1191 if (have_newer_gnuplot) | |
1192 fprintf (plot_stream, | |
1193 "set palette positive color model RGB maxcolors %i;\n", | |
1194 cmap_sz); | |
1195 fprintf (plot_stream, | |
1196 "set palette file \"-\" binary record=%d using 1:2:3:4;\n", | |
1197 cmap_sz); | |
1198 fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32"); | |
7472
2d8315dcd8d2
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
7471
diff
changeset
|
1199 fwrite (plot_stream, "\n"); |
7189 | 1200 else |
1201 fputs (plot_stream, "set palette defined ("); | |
1202 for i = 1: cmap_sz | |
1203 col = floor(cmap(i, :) * 255); | |
1204 if (i == 1) | |
1205 fputs (plot_stream, sprintf("%d \"#%02X%02X%02X\"", i - 1, | |
1206 col(1), col(2), col(3))); | |
1207 else | |
1208 fputs (plot_stream, sprintf(", %d \"#%02X%02X%02X\"", i - 1, | |
1209 col(1), col(2), col(3))); | |
1210 endif | |
1211 endfor | |
1212 fputs (plot_stream, ");\n"); | |
1213 endif | |
1214 endif | |
1215 | |
1216 if (strcmp (axis_obj.__colorbar__, "none")) | |
1217 fputs (plot_stream, "unset colorbox;\n"); | |
1218 else | |
1219 ## FIXME If cbox_mirror is true we want to invert the tic labels | |
1220 ## but gnuplot doesn't allow that | |
1221 fputs (plot_stream, | |
1222 sprintf ("set colorbox %s user origin %f,%f size %f,%f;\n", | |
1223 cbox_orient, cbox_origin, cbox_size)); | |
1224 endif | |
1225 | |
6405 | 1226 if (have_data) |
1227 if (nd == 2) | |
1228 plot_cmd = "plot"; | |
1229 else | |
1230 plot_cmd = "splot"; | |
1231 rot_x = 90 - axis_obj.view(2); | |
1232 rot_z = axis_obj.view(1); | |
1233 while (rot_z < 0) | |
1234 rot_z += 360; | |
1235 endwhile | |
6461 | 1236 fputs (plot_stream, "set ticslevel 0;\n"); |
7271 | 1237 if (view_map && rot_x == 0 && rot_z == 0) |
1238 fputs (plot_stream, "set view map;\n"); | |
1239 else | |
1240 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); | |
1241 endif | |
6405 | 1242 endif |
6611 | 1243 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
6464 | 1244 usingclause{1}, titlespec{1}, withclause{1}); |
6405 | 1245 for i = 2:data_idx |
6611 | 1246 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", |
6464 | 1247 usingclause{i}, titlespec{i}, withclause{i}); |
6405 | 1248 endfor |
1249 fputs (plot_stream, ";\n"); | |
1250 for i = 1:data_idx | |
6464 | 1251 if (is_image_data(i)) |
1252 fwrite (plot_stream, data{i}, "float32"); | |
1253 else | |
7119 | 1254 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i), |
1255 have_cdata(i)); | |
6405 | 1256 endif |
1257 endfor | |
6431 | 1258 else |
1259 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n"); | |
6405 | 1260 endif |
1261 | |
7271 | 1262 ## Needed to allow mouse rotation with pcolor |
1263 if (view_map) | |
1264 fputs (plot_stream, "unset view;\n"); | |
1265 endif | |
1266 | |
6405 | 1267 fflush (plot_stream); |
1268 | |
1269 else | |
1270 print_usage (); | |
7109 | 1271 endif |
6405 | 1272 |
1273 endfunction | |
1274 | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1275 function [style, typ, with] = do_linestyle_command (obj, idx, mono, |
7513
05eb3486f650
__stepimp__: don't call subplot for single plot
John W. Eaton <jwe@octave.org>
parents:
7510
diff
changeset
|
1276 plot_stream, errbars = "") |
6405 | 1277 |
6413 | 1278 persistent have_newer_gnuplot ... |
1279 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
6405 | 1280 |
1281 if (have_newer_gnuplot) | |
1282 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1283 endif | |
1284 fprintf (plot_stream, "set style line %d", idx); | |
1285 | |
1286 found_style = false; | |
6425 | 1287 typ = NaN; |
6465 | 1288 with = ""; |
6405 | 1289 |
6425 | 1290 if (isfield (obj, "color")) |
6405 | 1291 color = obj.color; |
1292 if (isnumeric (color)) | |
6425 | 1293 if (have_newer_gnuplot) |
7269 | 1294 if (! mono) |
1295 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1296 round (255*color)); | |
1297 endif | |
6425 | 1298 else |
1299 if (isequal (color, [0,0,0])) | |
1300 typ = -1; | |
1301 elseif (isequal (color, [1,0,0])) | |
1302 typ = 1; | |
1303 elseif (isequal (color, [0,1,0])) | |
1304 typ = 2; | |
1305 elseif (isequal (color, [0,0,1])) | |
1306 typ = 3; | |
1307 elseif (isequal (color, [1,0,1])) | |
1308 typ = 4; | |
1309 elseif (isequal (color, [0,1,1])) | |
1310 typ = 5; | |
1311 elseif (isequal (color, [1,1,1])) | |
1312 typ = 6; | |
1313 elseif (isequal (color, [1,1,0])) | |
1314 typ = 7; | |
1315 else | |
1316 typ = 2; | |
1317 endif | |
1318 endif | |
6405 | 1319 endif |
1320 found_style = true; | |
1321 endif | |
1322 | |
1323 if (isfield (obj, "linestyle")) | |
1324 switch (obj.linestyle) | |
1325 case "-" | |
6415 | 1326 lt = "1"; |
6405 | 1327 case "--" |
6415 | 1328 lt = "2"; |
6405 | 1329 case ":" |
6415 | 1330 lt = "3"; |
6405 | 1331 case "-." |
6415 | 1332 lt = "6"; |
6405 | 1333 case "none" |
1334 lt = ""; | |
1335 otherwise | |
1336 lt = ""; | |
1337 endswitch | |
6843 | 1338 |
1339 ## FIXME -- linetype is currently broken, since it disables the | |
1340 ## gnuplot default dashed and solid linestyles with the only | |
1341 ## benefit of being able to specify '--' and get a single sized | |
1342 ## dashed line of identical dash pattern for all called this way. | |
1343 ## All dash patterns are a subset of "with lines" and none of the | |
1344 ## lt specifications will correctly propagate into the x11 terminal | |
1345 ## or the print command. Therefore, it is currently disabled in | |
1346 ## order to allow print (..., "-dashed") etc. to work correctly. | |
1347 | |
1348 ## if (! isempty (lt)) | |
1349 ## fprintf (plot_stream, " linetype %s", lt); | |
1350 ## found_style = true; | |
1351 ## endif | |
1352 | |
6405 | 1353 else |
1354 lt = ""; | |
1355 endif | |
1356 | |
1357 if (isfield (obj, "linewidth")) | |
6465 | 1358 if (have_newer_gnuplot) |
1359 fprintf (plot_stream, " linewidth %f", obj.linewidth); | |
1360 else | |
1361 with = sprintf ("%s lw %f", with, obj.linewidth); | |
1362 endif | |
6405 | 1363 found_style = true; |
1364 endif | |
1365 | |
1366 if (isfield (obj, "marker")) | |
1367 switch (obj.marker) | |
1368 case "+" | |
1369 pt = "1"; | |
1370 case "o" | |
6413 | 1371 pt = "6"; |
6405 | 1372 case "*" |
1373 pt = "3"; | |
1374 case "." | |
7078 | 1375 pt = "0"; |
6405 | 1376 case "x" |
1377 pt = "2"; | |
1378 case {"square", "s"} | |
1379 pt = "5"; | |
1380 case {"diamond", "d"} | |
1381 pt = "13"; | |
1382 case "^" | |
1383 pt = "9"; | |
1384 case "v" | |
1385 pt = "11"; | |
1386 case ">" | |
1387 pt = "8"; | |
1388 case "<" | |
1389 pt = "10"; | |
1390 case {"pentagram", "p"} | |
1391 pt = "4"; | |
1392 case {"hexagram", "h"} | |
6413 | 1393 pt = "12"; |
6405 | 1394 case "none" |
1395 pt = ""; | |
1396 otherwise | |
1397 pt = ""; | |
1398 endswitch | |
1399 if (! isempty (pt)) | |
6465 | 1400 if (have_newer_gnuplot) |
1401 fprintf (plot_stream, " pointtype %s", pt); | |
1402 else | |
1403 with = sprintf ("%s pt %s", with, pt); | |
1404 endif | |
6405 | 1405 found_style = true; |
1406 endif | |
1407 else | |
1408 pt = ""; | |
1409 endif | |
1410 | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1411 if (isempty (errbars)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1412 style = "lines"; |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1413 if (isempty (lt)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1414 if (! isempty (pt)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1415 style = "points"; |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1416 endif |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1417 elseif (! isempty (pt)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1418 style = "linespoints"; |
6405 | 1419 endif |
1420 | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1421 if (isfield (obj, "markersize")) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1422 if (have_newer_gnuplot) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1423 fprintf (plot_stream, " pointsize %f", obj.markersize); |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1424 else |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1425 if (! strcmpi (style, "lines")) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1426 with = sprintf ("%s ps %f", with, obj.markersize); |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1427 endif |
6465 | 1428 endif |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1429 found_style = true; |
6465 | 1430 endif |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1431 else |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1432 style = errbars; |
6465 | 1433 found_style = true; |
1434 endif | |
1435 | |
6405 | 1436 if (have_newer_gnuplot && ! found_style) |
1437 fputs (plot_stream, " default"); | |
1438 endif | |
1439 | |
1440 fputs (plot_stream, ";\n"); | |
1441 | |
1442 endfunction | |
6510 | 1443 |
7316 | 1444 function nd = __calc_dimensions__ (obj) |
1445 kids = obj.children; | |
1446 nd = 2; | |
1447 for i = 1:length (kids) | |
1448 obj = get (kids(i)); | |
1449 switch (obj.type) | |
1450 case {"image", "text"} | |
1451 ## ignore as they | |
1452 case {"line", "patch"} | |
1453 if (! isempty (obj.zdata)) | |
1454 nd = 3; | |
1455 endif | |
1456 case "surface" | |
1457 nd = 3; | |
1458 endswitch | |
1459 endfor | |
1460 endfunction | |
1461 | |
7119 | 1462 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) |
6510 | 1463 |
1464 ## DATA is already transposed. | |
1465 | |
1466 ## FIXME -- this may need to be converted to C++ for speed. | |
1467 | |
6605 | 1468 ## Convert NA elements to normal NaN values because fprintf writes |
1469 ## "NA" and that confuses gnuplot. | |
1470 idx = find (isna (data)); | |
1471 if (any (idx)) | |
1472 data(idx) = NaN; | |
1473 endif | |
1474 | |
6510 | 1475 if (nd == 2) |
1476 nan_elts = find (sum (isnan (data))); | |
6914 | 1477 fmt = strcat (repmat ("%.15g ", 1, rows (data)), "\n"); |
6510 | 1478 if (isempty (nan_elts)) |
1479 fprintf (plot_stream, fmt, data); | |
1480 else | |
1481 n = columns (data); | |
1482 have_nans = true; | |
1483 num_nan_elts = numel (nan_elts); | |
1484 k = 1; | |
1485 for i = 1:n | |
1486 if (have_nans && i == nan_elts(k)) | |
1487 fputs (plot_stream, "\n"); | |
1488 have_nans = ++k <= num_nan_elts; | |
1489 else | |
1490 fprintf (plot_stream, fmt, data(:,i)); | |
1491 endif | |
1492 endfor | |
1493 endif | |
7109 | 1494 elseif (nd == 3) |
6510 | 1495 ## FIXME -- handle NaNs here too? |
1496 if (parametric) | |
6914 | 1497 fprintf (plot_stream, "%.15g %.15g %.15g\n", data); |
6510 | 1498 else |
7170 | 1499 nr = rows (data); |
7119 | 1500 if (cdata) |
7170 | 1501 for j = 1:4:nr |
1502 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(j:j+3,:)); | |
7119 | 1503 fputs (plot_stream, "\n"); |
1504 endfor | |
1505 else | |
7170 | 1506 for j = 1:3:nr |
1507 fprintf (plot_stream, "%.15g %.15g %.15g\n", data(j:j+2,:)); | |
7119 | 1508 fputs (plot_stream, "\n"); |
1509 endfor | |
1510 endif | |
7109 | 1511 endif |
6510 | 1512 endif |
1513 fputs (plot_stream, "e\n"); | |
1514 | |
1515 endfunction | |
6745 | 1516 |
7269 | 1517 function do_tics (obj, plot_stream, ymirror, mono) |
6809 | 1518 if (strcmpi (obj.xaxislocation, "top")) |
1519 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7321 | 1520 obj.xcolor, "x2", plot_stream, true, mono, "border"); |
6809 | 1521 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7321 | 1522 obj.xcolor, "x", plot_stream, true, mono, "border"); |
1523 elseif (strcmpi (obj.xaxislocation, "zero")) | |
1524 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
1525 obj.xcolor, "x", plot_stream, true, mono, "axis"); | |
1526 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, | |
1527 obj.xcolor, "x2", plot_stream, true, mono, "axis"); | |
6809 | 1528 else |
1529 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7321 | 1530 obj.xcolor, "x", plot_stream, true, mono, "border"); |
6809 | 1531 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7321 | 1532 obj.xcolor, "x2", plot_stream, true, mono, "border"); |
6809 | 1533 endif |
1534 if (strcmpi (obj.yaxislocation, "right")) | |
1535 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7321 | 1536 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); |
6809 | 1537 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7321 | 1538 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); |
1539 elseif (strcmpi (obj.xaxislocation, "zero")) | |
1540 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
1541 obj.ycolor, "y", plot_stream, ymirror, mono, "axis"); | |
1542 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, | |
1543 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis"); | |
6809 | 1544 else |
1545 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7321 | 1546 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); |
6809 | 1547 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7321 | 1548 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); |
6809 | 1549 endif |
6745 | 1550 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, |
7321 | 1551 obj.zcolor, "z", plot_stream, true, mono, "border"); |
6745 | 1552 endfunction |
1553 | |
7269 | 1554 function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, |
7321 | 1555 plot_stream, mirror, mono, axispos) |
7269 | 1556 colorspec = get_text_colorspec (color, mono); |
6758 | 1557 if (strcmpi (ticmode, "manual")) |
6745 | 1558 if (isempty (tics)) |
1559 fprintf (plot_stream, "unset %stics;\n", ax); | |
6758 | 1560 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) |
6751 | 1561 if (ischar (labels)) |
1562 labels = cellstr (labels); | |
1563 endif | |
6745 | 1564 if (iscellstr (labels)) |
6751 | 1565 k = 1; |
1566 ntics = numel (tics); | |
1567 nlabels = numel (labels); | |
6745 | 1568 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
7206 | 1569 if (mirror) |
7321 | 1570 fprintf (plot_stream, "set %stics %s (", ax, axispos); |
7206 | 1571 else |
7321 | 1572 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); |
7206 | 1573 endif |
7228 | 1574 labels = regexprep(labels, "%", "%%"); |
6745 | 1575 for i = 1:ntics |
7228 | 1576 fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i)) |
6745 | 1577 if (i < ntics) |
1578 fputs (plot_stream, ", "); | |
1579 endif | |
1580 if (k > nlabels) | |
1581 k = 1; | |
1582 endif | |
1583 endfor | |
7220 | 1584 fprintf (plot_stream, ") %s;\n", colorspec); |
6745 | 1585 else |
1586 error ("unsupported type of ticklabel"); | |
1587 endif | |
1588 else | |
6920 | 1589 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1590 if (mirror) |
7321 | 1591 fprintf (plot_stream, "set %stics %s (", ax, axispos ); |
7206 | 1592 else |
7321 | 1593 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); |
7206 | 1594 endif |
6920 | 1595 fprintf (plot_stream, " %g,", tics(1:end-1)); |
1596 fprintf (plot_stream, " %g);\n", tics(end)); | |
6745 | 1597 endif |
1598 else | |
6920 | 1599 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1600 if (mirror) |
7321 | 1601 fprintf (plot_stream, "set %stics %s %s;\n", ax, axispos, colorspec); |
7206 | 1602 else |
7321 | 1603 fprintf (plot_stream, "set %stics %s nomirror %s;\n", ax, |
1604 axispos, colorspec); | |
7206 | 1605 endif |
7194 | 1606 endif |
1607 endfunction | |
1608 | |
7269 | 1609 function colorspec = get_text_colorspec (color, mono) |
7194 | 1610 persistent have_newer_gnuplot ... |
1611 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
1612 | |
1613 if (have_newer_gnuplot) | |
7269 | 1614 if (mono) |
1615 colorspec = ""; | |
1616 else | |
1617 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"", | |
1618 round (255*color)); | |
1619 endif | |
7194 | 1620 else |
1621 if (isequal (color, [0,0,0])) | |
1622 typ = -1; | |
1623 elseif (isequal (color, [1,0,0])) | |
1624 typ = 1; | |
1625 elseif (isequal (color, [0,1,0])) | |
1626 typ = 2; | |
1627 elseif (isequal (color, [0,0,1])) | |
1628 typ = 3; | |
1629 elseif (isequal (color, [1,0,1])) | |
1630 typ = 4; | |
1631 elseif (isequal (color, [0,1,1])) | |
1632 typ = 5; | |
1633 elseif (isequal (color, [1,1,1])) | |
1634 typ = -1; | |
1635 elseif (isequal (color, [1,1,0])) | |
1636 typ = 7; | |
1637 else | |
1638 typ = -1; | |
1639 endif | |
1640 colorspec = sprintf ("textcolor lt %d", typ); | |
6745 | 1641 endif |
1642 endfunction | |
7163 | 1643 |
7189 | 1644 function [f, s, fnt, it, bld] = get_fontname_and_size (t) |
7163 | 1645 if (isempty (t.fontname)) |
7372 | 1646 fnt = "Helvetica"; |
7163 | 1647 else |
7372 | 1648 fnt = t.fontname; |
7168 | 1649 endif |
7189 | 1650 f = fnt; |
1651 it = false; | |
1652 bld = false; | |
7372 | 1653 if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold")) |
7168 | 1654 if (! isempty(t.fontangle) |
7372 | 1655 && (strcmpi (t.fontangle, "italic") |
1656 || strcmpi (t.fontangle, "oblique"))) | |
7168 | 1657 f = strcat (f, "-bolditalic"); |
7189 | 1658 it = true; |
1659 bld = true; | |
7168 | 1660 else |
1661 f = strcat (f, "-bold"); | |
7189 | 1662 bld = true; |
7168 | 1663 endif |
1664 elseif (! isempty(t.fontangle) | |
7372 | 1665 && (strcmpi (t.fontangle, "italic") |
1666 || strcmpi (t.fontangle, "oblique"))) | |
7168 | 1667 f = strcat (f, "-italic"); |
7189 | 1668 it = true; |
7163 | 1669 endif |
1670 if (isempty (t.fontsize)) | |
1671 s = 10; | |
1672 else | |
1673 s = t.fontsize; | |
1674 endif | |
1675 endfunction | |
7189 | 1676 |
1677 function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld, | |
1678 have_newer_gnuplot) | |
1679 persistent warned_latex = false; | |
1680 | |
1681 if (strcmp (fld, "string")) | |
1682 [f, s, fnt, it, bld] = get_fontname_and_size (obj); | |
1683 else | |
7372 | 1684 f = "Helvetica"; |
7189 | 1685 s = 10; |
1686 fnt = f; | |
1687 it = false; | |
1688 bld = false; | |
1689 endif | |
1690 | |
1691 str = getfield (obj, fld); | |
1692 if (enhanced) | |
1693 if (strcmp (obj.interpreter, "tex")) | |
1694 str = __tex2enhanced__ (str, fnt, it, bld); | |
1695 if (! have_newer_gnuplot) | |
1696 ## Set the font to work around gnuplot 4.0 X11 enhanced terminal bug | |
1697 str = strcat ('{/', f, ' ', str, ' }'); | |
1698 endif | |
1699 elseif (strcmp (obj.interpreter, "latex")) | |
1700 if (! warned_latex) | |
1701 warning ("latex text objects not supported"); | |
1702 warned_latex = true; | |
1703 endif | |
1704 endif | |
1705 endif | |
1706 endfunction | |
1707 | |
1708 function str = __tex2enhanced__ (str, fnt, it, bld) | |
1709 persistent sym = __setup_sym_table__ (); | |
1710 persistent flds = fieldnames (sym); | |
1711 | |
1712 [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches'); | |
1713 | |
1714 for i = length (s) : -1 : 1 | |
1715 ## special case for "\0" and replace with "{/Symbol \306}' | |
1716 if (strncmp (m{i}, '\0', 2)) | |
7190 | 1717 str = strcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); |
7189 | 1718 else |
1719 f = m{i}(2:end); | |
1720 if (isfield (sym, f)) | |
1721 g = getfield(sym, f); | |
1722 ## FIXME The symbol font doesn't seem to support bold or italic | |
1723 ##if (bld) | |
1724 ## if (it) | |
1725 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1726 ## else | |
1727 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1728 ## endif | |
1729 ##elseif (it) | |
1730 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1731 ##endif | |
1732 str = strcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); | |
1733 elseif (strncmp (f, "rm", 2)) | |
1734 bld = false; | |
1735 it = false; | |
1736 str = strcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); | |
1737 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) | |
1738 it = true; | |
1739 if (bld) | |
1740 str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', | |
1741 str(s(i) + 3:end)); | |
1742 else | |
1743 str = strcat (str(1:s(i) - 1), '/', fnt, '-italic ', | |
1744 str(s(i) + 3:end)); | |
1745 endif | |
1746 elseif (strncmp (f, "bf", 2)) | |
1747 bld = true; | |
1748 if (it) | |
1749 str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', | |
1750 str(2(i) + 3:end)); | |
1751 else | |
1752 str = strcat (str(1:s(i) - 1), '/', fnt, '-bold ', | |
1753 str(s(i) + 3:end)); | |
1754 endif | |
1755 elseif (strcmp (f, "color")) | |
1756 ## FIXME Ignore \color but remove trailing {} block as well | |
1757 d = strfind(str(e(i) + 1:end),'}'); | |
1758 if (isempty (d)) | |
1759 warning ('syntax error in \color argument'); | |
1760 else | |
1761 str = strcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); | |
1762 endif | |
1763 elseif(strcmp (f, "fontname")) | |
1764 b1 = strfind(str(e(i) + 1:end),'{'); | |
1765 b2 = strfind(str(e(i) + 1:end),'}'); | |
1766 if (isempty(b1) || isempty(b2)) | |
1767 warning ('syntax error in \fontname argument'); | |
1768 else | |
1769 str = strcat (str(1:s(i) - 1), '/', | |
1770 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', | |
1771 str(e(i) + b2(1) + 1:end)); | |
1772 endif | |
1773 elseif(strcmp (f, "fontsize")) | |
1774 b1 = strfind(str(e(i) + 1:end),'{'); | |
1775 b2 = strfind(str(e(i) + 1:end),'}'); | |
1776 if (isempty(b1) || isempty(b2)) | |
1777 warning ('syntax error in \fontname argument'); | |
1778 else | |
1779 str = strcat (str(1:s(i) - 1), '/=', | |
1780 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', | |
1781 str(e(i) + b2(1) + 1:end)); | |
1782 endif | |
1783 else | |
1784 ## Last desperate attempt to treat the symbol. Look for things | |
1785 ## like \pix, that should be translated to the symbol Pi and x | |
1786 for j = 1 : length (flds) | |
1787 if (strncmp (flds{j}, f, length (flds{j}))) | |
1788 g = getfield(sym, flds{j}); | |
1789 ## FIXME The symbol font doesn't seem to support bold or italic | |
1790 ##if (bld) | |
1791 ## if (it) | |
1792 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1793 ## else | |
1794 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1795 ## endif | |
1796 ##elseif (it) | |
1797 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1798 ##endif | |
1799 str = strcat (str(1:s(i) - 1), g, | |
1800 str(s(i) + length (flds{j}) + 1:end)); | |
1801 break; | |
1802 endif | |
1803 endfor | |
1804 endif | |
1805 endif | |
1806 endfor | |
1807 | |
1808 ## Prepend @ to things things like _0^x or _{-100}^{100} for alignment | |
1809 ## But need to put the shorter of the two arguments first. Carful of | |
1810 ## nested {} and unprinted characters when defining shortest.. Don't | |
1811 ## have to worry about things like ^\theta as they are already converted to | |
1812 ## ^{/Symbol q}. | |
1813 | |
1814 ## FIXME.. This is a mess... Is it worth it just for a "@" character? | |
1815 | |
1816 [s, m] = regexp(str,'[_\^]','start','matches'); | |
1817 i = 1; | |
1818 p = 0; | |
1819 while (i < length (s)) | |
1820 if (i < length(s)) | |
1821 if (str(s(i) + p + 1) == "{") | |
1822 s1 = strfind(str(s(i) + p + 2:end),'{'); | |
1823 si = 1; | |
1824 l1 = strfind(str(s(i) + p + 1:end),'}'); | |
1825 li = 1; | |
1826 while (li <= length (l1) && si <= length (s1)) | |
1827 if (l1(li) < s1(si)) | |
1828 if (li == si) | |
1829 break; | |
1830 endif | |
1831 li++; | |
1832 else | |
1833 si++; | |
1834 endif | |
1835 endwhile | |
1836 l1 = l1 (min (length(l1), si)); | |
1837 if (s(i) + l1 + 1 == s(i+1)) | |
1838 if (str(s(i + 1) + p + 1) == "{") | |
1839 s2 = strfind(str(s(i + 1) + p + 2:end),'{'); | |
1840 si = 1; | |
1841 l2 = strfind(str(s(i + 1) + p + 1:end),'}'); | |
1842 li = 1; | |
1843 while (li <= length (l2) && si <= length (s2)) | |
1844 if (l2(li) < s2(si)) | |
1845 if (li == si) | |
1846 break; | |
1847 endif | |
1848 li++; | |
1849 else | |
1850 si++; | |
1851 endif | |
1852 endwhile | |
1853 l2 = l2 (min (length(l2), si)); | |
1854 if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= | |
1855 length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) | |
1856 ## shortest already first! | |
1857 str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
1858 else | |
1859 ## Have to swap sub/super-script to get shortest first | |
1860 str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), | |
1861 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); | |
1862 endif | |
1863 else | |
1864 ## Have to swap sub/super-script to get shortest first | |
1865 str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), | |
1866 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); | |
1867 endif | |
1868 i += 2; | |
1869 p ++; | |
1870 else | |
1871 i++; | |
1872 endif | |
1873 else | |
1874 if (s(i+1) == s(i) + 2) | |
1875 ## shortest already first! | |
1876 str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
1877 p ++; | |
1878 i += 2; | |
1879 else | |
1880 i ++; | |
1881 endif | |
1882 endif | |
1883 else | |
1884 i ++; | |
1885 endif | |
1886 endwhile | |
1887 | |
1888 endfunction | |
1889 | |
1890 function l = length_string (s) | |
1891 l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}')); | |
1892 m = regexp (s, '/([\w\-]+|[\w\-]+=\d+)', 'matches'); | |
1893 if (!isempty (m)) | |
1894 l = l - sum (cellfun (@length, m)); | |
1895 endif | |
1896 endfunction | |
1897 | |
1898 function sym = __setup_sym_table__ () | |
1899 ## Setup the translation table for TeX to gnuplot enhanced mode. | |
1900 sym.forall = '{/Symbol \042}'; | |
1901 sym.exists = '{/Symbol \044}'; | |
1902 sym.ni = '{/Symbol \047}'; | |
1903 sym.cong = '{/Symbol \100}'; | |
1904 sym.Delta = '{/Symbol D}'; | |
1905 sym.Phi = '{/Symbol F}'; | |
1906 sym.Gamma = '/Symbol G}'; | |
7190 | 1907 sym.vartheta = '{/Symbol J}'; |
7189 | 1908 sym.Lambda = '{/Symbol L}'; |
1909 sym.Pi = '{/Symbol P}'; | |
1910 sym.Theta = '{/Symbol Q}'; | |
1911 sym.Sigma = '{/Symbol S}'; | |
1912 sym.varsigma = '{/Symbol V}'; | |
7420 | 1913 sym.Omega = '{/Symbol W}'; |
7189 | 1914 sym.Xi = '{/Symbol X}'; |
1915 sym.Psi = '{/Symbol Y}'; | |
1916 sym.perp = '{/Symbol \136}'; | |
1917 sym.alpha = '{/Symbol a}'; | |
1918 sym.beta = '{/Symbol b}'; | |
1919 sym.chi = '{/Symbol c}'; | |
1920 sym.delta = '{/Symbol d}'; | |
1921 sym.epsilon = '{/Symbol e}'; | |
1922 sym.phi = '{/Symbol f}'; | |
1923 sym.gamma = '/Symbol g}'; | |
1924 sym.eta = '{/Symbol h}'; | |
1925 sym.iota = '{/Symbol i}'; | |
1926 sym.kappa = '{/Symbol k}'; | |
1927 sym.lambda = '{/Symbol l}'; | |
1928 sym.mu = '{/Symbol m}'; | |
1929 sym.nu = '{/Symbol n}'; | |
1930 sym.o = '{/Symbol o}'; | |
1931 sym.pi = '{/Symbol p}'; | |
1932 sym.theta = '{/Symbol q}'; | |
1933 sym.rho = '{/Symbol r}'; | |
1934 sym.sigma = '{/Symbol s}'; | |
1935 sym.tau = '{/Symbol t}'; | |
1936 sym.upsilon = '{/Symbol u}'; | |
1937 sym.varpi = '{/Symbol v}'; | |
1938 sym.omega = '{/Symbol w}'; | |
1939 sym.xi = '{/Symbol x}'; | |
1940 sym.psi = '{/Symbol y}'; | |
1941 sym.zeta = '{/Symbol z}'; | |
1942 sym.sim = '{/Symbol \176}'; | |
1943 sym.Upsilon = '{/Symbol \241}'; | |
1944 sym.prime = '{/Symbol \242}'; | |
1945 sym.leq = '{/Symbol \243}'; | |
1946 sym.infty = '{/Symbol \245}'; | |
1947 sym.clubsuit = '{/Symbol \247}'; | |
1948 sym.diamondsuit = '{/Symbol \250}'; | |
1949 sym.heartsuit = '{/Symbol \251}'; | |
1950 sym.spadesuit = '{/Symbol \252}'; | |
1951 sym.leftrightarrow = '{/Symbol \253}'; | |
1952 sym.leftarrow = '{/Symbol \254}'; | |
1953 sym.uparrow = '{/Symbol \255}'; | |
1954 sym.rightarrow = '{/Symbol \256}'; | |
1955 sym.downarrow = '{/Symbol \257}'; | |
1956 sym.circ = '{/Symbol \260}'; | |
1957 sym.pm = '{/Symbol \261}'; | |
1958 sym.geq = '{/Symbol \263}'; | |
1959 sym.times = '{/Symbol \264}'; | |
1960 sym.propto = '{/Symbol \265}'; | |
1961 sym.partial = '{/Symbol \266}'; | |
1962 sym.bullet = '{/Symbol \267}'; | |
1963 sym.div = '{/Symbol \270}'; | |
1964 sym.neq = '{/Symbol \271}'; | |
1965 sym.equiv = '{/Symbol \272}'; | |
1966 sym.approx = '{/Symbol \273}'; | |
1967 sym.ldots = '{/Symbol \274}'; | |
1968 sym.mid = '{/Symbol \275}'; | |
1969 sym.aleph = '{/Symbol \300}'; | |
1970 sym.Im = '{/Symbol \301}'; | |
1971 sym.Re = '{/Symbol \302}'; | |
1972 sym.wp = '{/Symbol \303}'; | |
1973 sym.otimes = '{/Symbol \304}'; | |
1974 sym.oplus = '{/Symbol \305}'; | |
1975 sym.oslash = '{/Symbol \306}'; | |
1976 sym.cap = '{/Symbol \307}'; | |
1977 sym.cup = '{/Symbol \310}'; | |
1978 sym.supset = '{/Symbol \311}'; | |
1979 sym.supseteq = '{/Symbol \312}'; | |
1980 sym.subset = '{/Symbol \314}'; | |
1981 sym.subseteq = '{/Symbol \315}'; | |
1982 sym.in = '{/Symbol \316}'; | |
1983 sym.langle = '{/Symbol \320}'; | |
1984 sym.rangle = '{/Symbol \320}'; | |
1985 sym.nabla = '{/Symbol \321}'; | |
1986 sym.surd = '{/Symbol \326}'; | |
1987 sym.cdot = '{/Symbol \327}'; | |
1988 sym.neg = '{/Symbol \330}'; | |
1989 sym.wedge = '{/Symbol \331}'; | |
1990 sym.vee = '{/Symbol \332}'; | |
1991 sym.copyright = '{/Symbol \343}'; | |
1992 sym.rfloor = '{/Symbol \353}'; | |
1993 sym.lceil = '{/Symbol \351}'; | |
1994 sym.lfloor = '{/Symbol \373}'; | |
1995 sym.rceil = '{/Symbol \371}'; | |
1996 sym.int = '{/Symbol \362}'; | |
1997 endfunction | |
1998 | |
1999 function [pos, orient, sz, origin, mirr] = gnuplot_postion_colorbox (pos, cbox) | |
2000 ## This is an emprically derived function that | |
2001 | |
2002 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
2003 scl = pos([2,4]); | |
2004 else | |
2005 scl = pos([1,3]); | |
2006 endif | |
2007 | |
2008 if (length(cbox) > 7 && strncmp (cbox(end-6:end), "outside", 7)) | |
2009 scl(2) -= 0.2 * scl(2); | |
2010 if (strncmp (cbox, "west", 4) || strncmp (cbox, "south", 5)) | |
2011 scl(1) += 0.2 * scl(2); | |
2012 endif | |
2013 endif | |
2014 | |
2015 switch (cbox) | |
2016 case "northoutside" | |
2017 sz = pos(3:4) - 0.08; | |
2018 origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2); | |
2019 mirr = true; | |
2020 orient = "horizontal"; | |
2021 case "north" | |
2022 sz = pos(3:4) - 0.16; | |
2023 origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2); | |
2024 mirr = false; | |
2025 orient = "horizontal"; | |
2026 case "southoutside" | |
2027 sz = pos(3:4) - 0.08; | |
2028 origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2); | |
2029 mirr = false; | |
2030 orient = "horizontal"; | |
2031 case "south" | |
2032 sz = pos(3:4) - 0.16; | |
2033 origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2); | |
2034 mirr = true; | |
2035 orient = "horizontal"; | |
2036 case "eastoutside" | |
2037 sz = pos(3:4) - 0.08; | |
2038 origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2); | |
2039 mirr = false; | |
2040 orient = "vertical"; | |
2041 case "east" | |
2042 sz = pos(3:4) - 0.16; | |
2043 origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2); | |
2044 mirr = true; | |
2045 orient = "vertical"; | |
2046 case "westoutside" | |
2047 sz = pos(3:4) - 0.08; | |
2048 origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2); | |
2049 mirr = true; | |
2050 orient = "vertical"; | |
2051 case "west" | |
2052 sz = pos(3:4) - 0.16; | |
2053 origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2); | |
2054 mirr = false; | |
2055 orient = "vertical"; | |
2056 endswitch | |
2057 | |
2058 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
2059 sz = sz .* [1, 0.07]; | |
2060 pos([2,4]) = scl; | |
2061 else | |
2062 sz = sz .* [0.07, 1]; | |
2063 pos([1,3]) = scl; | |
2064 endif | |
2065 | |
2066 endfunction | |
7390 | 2067 |
2068 function retval = __do_enhanced_option__ (enhanced, obj) | |
2069 retval = ""; | |
2070 if (enhanced) | |
2071 if (strcmpi (obj.interpreter, "none")) | |
2072 retval = "noenhanced"; | |
2073 else | |
2074 retval = "enhanced"; | |
2075 endif | |
2076 endif | |
2077 endfunction |