Mercurial > octave-nkf
annotate scripts/plot/__go_draw_axes__.m @ 11666:93d17b1e756f release-3-0-x
use Helvetica, not helvetica; don't downcase user-supplied font names
author | jwe |
---|---|
date | Mon, 14 Jan 2008 19:50:10 +0000 |
parents | db22340e1f24 |
children | e6364723ae29 |
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 |
27 axis_obj = get (h); | |
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 | |
11636
2be7477f470a
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
11635
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 | |
11615 | 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")) |
11615 | 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 |
11615 | 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")) |
11615 | 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 |
11615 | 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 | |
11615 | 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"); |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
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 | |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
341 if (strcmp (obj.cdatamapping, "direct")) |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
342 cdatadirect = true; |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
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} = ""; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
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)"; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
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)"; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
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)"; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
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 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
485 |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
486 [style, typ, with] = do_linestyle_command (obj, data_idx, mono, |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
487 plot_stream, errbars); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
488 |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
489 if (have_newer_gnuplot || isnan (typ)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
490 withclause{data_idx} = sprintf ("with %s linestyle %d", |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
491 style, data_idx); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
492 else |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
493 withclause{data_idx} = sprintf ("with %s linetype %d", |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
494 style, typ); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
495 endif |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
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; | |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
512 if (strcmp (obj.cdatamapping, "direct")) |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
513 cdatadirect = true; |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
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 | |
708 if (isfield (obj, "marker")) | |
709 if (isfield (obj, "marker")) | |
710 switch (obj.marker) | |
711 case "+" | |
712 pt = "pt 1"; | |
713 case "o" | |
714 pt = "pt 6"; | |
715 case "*" | |
716 pt = "pt 3"; | |
717 case "." | |
718 pt = "pt 0"; | |
719 case "x" | |
720 pt = "pt 2"; | |
721 case {"square", "s"} | |
722 pt = "pt 5"; | |
723 case {"diamond", "d"} | |
724 pt = "pt 13"; | |
725 case "^" | |
726 pt = "pt 9"; | |
727 case "v" | |
728 pt = "pt 11"; | |
729 case ">" | |
730 pt = "pt 8"; | |
731 case "<" | |
732 pt = "pt 10"; | |
733 case {"pentagram", "p"} | |
734 pt = "pt 4"; | |
735 case {"hexagram", "h"} | |
736 pt = "pt 12"; | |
737 case "none" | |
738 pt = ""; | |
739 otherwise | |
740 pt = ""; | |
741 endswitch | |
742 endif | |
743 else | |
744 pt = ""; | |
745 endif | |
746 | |
747 style = "lines"; | |
748 if (isempty (lt)) | |
749 if (! isempty (pt)) | |
750 style = "points"; | |
751 endif | |
752 elseif (! isempty (pt)) | |
753 style = "linespoints"; | |
754 endif | |
755 | |
756 if (isfield (obj, "markersize")) | |
757 if (length (mdat) == nc) | |
758 m = mdat(i); | |
759 else | |
760 m = mdat; | |
761 endif | |
762 if (! strcmpi (style, "lines")) | |
763 if (have_newer_gnuplot) | |
764 ps = sprintf("pointsize %f", m); | |
765 else | |
766 ps = sprintf("ps %f", m); | |
767 endif | |
768 else | |
769 ps = ""; | |
770 endif | |
771 else | |
772 ps = ""; | |
773 endif | |
774 | |
7020 | 775 if (have_newer_gnuplot) |
7269 | 776 if (mono) |
777 colorspec = ""; | |
778 else | |
779 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
780 round (255*color)); | |
781 endif | |
7317 | 782 withclause{data_idx} = sprintf ("with %s %s %s %s %s", |
783 style, pt, lt, ps, colorspec); | |
7020 | 784 else |
785 if (isequal (color, [0,0,0])) | |
786 typ = -1; | |
787 elseif (isequal (color, [1,0,0])) | |
788 typ = 1; | |
789 elseif (isequal (color, [0,1,0])) | |
790 typ = 2; | |
791 elseif (isequal (color, [0,0,1])) | |
792 typ = 3; | |
793 elseif (isequal (color, [1,0,1])) | |
794 typ = 4; | |
795 elseif (isequal (color, [0,1,1])) | |
796 typ = 5; | |
797 elseif (isequal (color, [1,1,1])) | |
798 typ = -1; | |
799 elseif (isequal (color, [1,1,0])) | |
800 typ = 7; | |
801 else | |
802 typ = -1; | |
803 endif | |
7189 | 804 withclause{data_idx} = sprintf ("with %s %s %s lt %d", |
805 style, pt, ps, typ); | |
7020 | 806 endif |
6790 | 807 |
7316 | 808 if (nd == 3) |
7170 | 809 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) |
810 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... | |
811 [zcol; zcol(1)]]'; | |
812 else | |
813 data{data_idx} = [xcol, ycol, zcol]'; | |
814 endif | |
815 usingclause{data_idx} = "using ($1):($2):($3)"; | |
7020 | 816 else |
7170 | 817 if (! isnan (xcol) && ! isnan (ycol)) |
818 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; | |
819 else | |
820 data{data_idx} = [xcol, ycol]'; | |
821 endif | |
822 usingclause{data_idx} = "using ($1):($2)"; | |
7020 | 823 endif |
6885 | 824 endif |
7020 | 825 endfor |
6790 | 826 |
6405 | 827 case "surface" |
7271 | 828 view_map = true; |
7110 | 829 if (! (strncmp (obj.edgecolor, "none", 4) |
830 && strncmp (obj.facecolor, "none", 4))) | |
7109 | 831 data_idx++; |
832 is_image_data(data_idx) = false; | |
833 parametric(data_idx) = false; | |
7119 | 834 have_cdata(data_idx) = true; |
7170 | 835 [style, typ, with] = do_linestyle_command (obj, data_idx, |
7269 | 836 mono, plot_stream); |
7109 | 837 if (isempty (obj.keylabel)) |
838 titlespec{data_idx} = "title \"\""; | |
839 else | |
7189 | 840 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7109 | 841 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
842 endif | |
843 usingclause{data_idx} = ""; | |
844 if (have_newer_gnuplot || isnan (typ)) | |
7318 | 845 withclause{data_idx} = sprintf ("with pm3d linestyle %d", |
846 data_idx); | |
6405 | 847 else |
7318 | 848 withclause{data_idx} = sprintf ("with pm3d linetype %d %s", |
849 typ, with); | |
7109 | 850 endif |
851 | |
852 xdat = obj.xdata; | |
853 ydat = obj.ydata; | |
854 zdat = obj.zdata; | |
855 cdat = obj.cdata; | |
7110 | 856 |
7109 | 857 err = false; |
858 if (! size_equal(zdat, cdat)) | |
6405 | 859 err = true; |
7109 | 860 endif |
861 if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) | |
7110 | 862 if (rows (zdat) == length (ydat) |
863 && columns (zdat) == length (xdat)) | |
7109 | 864 [xdat, ydat] = meshgrid (xdat, ydat); |
865 else | |
866 err = true; | |
867 endif | |
868 elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) | |
7292 | 869 if (! size_equal (xdat, ydat, zdat)) |
7109 | 870 err = true; |
871 endif | |
872 else | |
873 err = true; | |
874 endif | |
875 if (err) | |
876 error ("__go_draw_axes__: invalid grid data"); | |
6405 | 877 endif |
7109 | 878 xlen = columns (zdat); |
879 ylen = rows (zdat); | |
880 if (xlen == columns (xdat) && xlen == columns (ydat) | |
881 && ylen == rows (xdat) && ylen == rows (ydat)) | |
882 len = 4 * xlen; | |
883 zz = zeros (ylen, len); | |
884 k = 1; | |
885 for kk = 1:4:len | |
886 zz(:,kk) = xdat(:,k); | |
887 zz(:,kk+1) = ydat(:,k); | |
888 zz(:,kk+2) = zdat(:,k); | |
889 zz(:,kk+3) = cdat(:,k); | |
890 k++; | |
891 endfor | |
7170 | 892 data{data_idx} = zz.'; |
7109 | 893 endif |
894 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
7316 | 895 ## fputs (plot_stream, "unset parametric;\n"); |
7109 | 896 |
7119 | 897 ## Interpolation does not work for flat surfaces (e.g. pcolor) |
898 ## and color mapping --> currently set empty. | |
899 interp_str = ""; | |
900 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) | |
901 || strncmp (obj.facecolor, "interp", 6)); | |
902 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) | |
903 || strncmp (obj.edgecolor, "interp", 6)); | |
7154 | 904 |
905 facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4) | |
906 || (isnumeric (obj.facecolor) | |
907 && all (obj.facecolor == 1))); | |
7149 | 908 if (strncmp (obj.facecolor, "none", 4)) |
7318 | 909 hidden_removal = false; |
7175 | 910 else |
7318 | 911 if (isnan (hidden_removal)) |
912 hidden_removal = true; | |
913 endif | |
7149 | 914 endif |
7318 | 915 |
916 if (flat_interp_edge && facecolor_none_or_white) | |
7189 | 917 withclause{data_idx} = "with line palette"; |
7119 | 918 endif |
7109 | 919 |
7189 | 920 if (have_newer_gnuplot) |
921 dord = "depthorder"; | |
922 else | |
923 dord = ""; | |
924 endif | |
7109 | 925 |
7318 | 926 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) |
927 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", | |
7189 | 928 interp_str, dord); |
7318 | 929 elseif (!facecolor_none_or_white) |
7119 | 930 if (strncmp (obj.edgecolor, "none", 4)) |
7318 | 931 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", |
7189 | 932 interp_str, dord); |
7109 | 933 else |
7119 | 934 edgecol = obj.edgecolor; |
935 if (ischar (obj.edgecolor)) | |
936 edgecol = [0,0,0]; | |
937 endif | |
7318 | 938 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", |
7189 | 939 data_idx, interp_str, dord); |
7119 | 940 |
941 if (have_newer_gnuplot) | |
7269 | 942 if (mono) |
943 colorspec = ""; | |
944 else | |
945 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", | |
946 round (255*edgecol)); | |
947 endif | |
7110 | 948 fprintf (plot_stream, |
7269 | 949 "set style line %d %s lw %f;\n", |
950 data_idx, colorspec, obj.linewidth); | |
7119 | 951 else |
952 if (isequal (edgecol, [0,0,0])) | |
953 typ = -1; | |
954 elseif (isequal (edgecol, [1,0,0])) | |
955 typ = 1; | |
956 elseif (isequal (edgecol, [0,1,0])) | |
957 typ = 2; | |
958 elseif (isequal (edgecol, [0,0,1])) | |
959 typ = 3; | |
960 elseif (isequal (edgecol, [1,0,1])) | |
961 typ = 4; | |
962 elseif (isequal (edgecol, [0,1,1])) | |
963 typ = 5; | |
964 elseif (isequal (edgecol, [1,1,1])) | |
965 typ = -1; | |
966 elseif (isequal (edgecol, [1,1,0])) | |
967 typ = 7; | |
968 else | |
969 typ = -1; | |
970 endif | |
971 fprintf (plot_stream, | |
972 "set style line %d lt %d lw %f;\n", | |
973 data_idx, typ, obj.linewidth); | |
974 endif | |
7109 | 975 endif |
7119 | 976 endif |
6405 | 977 endif |
978 | |
979 case "text" | |
7189 | 980 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string", |
981 have_newer_gnuplot); | |
7257 | 982 if (strcmp (f, "*")) |
983 fontspec = ""; | |
984 else | |
985 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
986 endif | |
6405 | 987 lpos = obj.position; |
988 halign = obj.horizontalalignment; | |
6724 | 989 angle = obj.rotation; |
6752 | 990 units = obj.units; |
6829 | 991 color = obj.color; |
6758 | 992 if (strcmpi (units, "normalized")) |
6752 | 993 units = "graph"; |
994 else | |
995 units = ""; | |
996 endif | |
997 | |
6829 | 998 if (isnumeric (color)) |
7269 | 999 colorspec = get_text_colorspec (color, mono); |
6829 | 1000 endif |
1001 | |
6405 | 1002 if (nd == 3) |
6724 | 1003 fprintf (plot_stream, |
11615 | 1004 "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 1005 undo_string_escapes (label), units, lpos(1), |
11615 | 1006 lpos(2), lpos(3), halign, angle, fontspec, |
1007 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 1008 else |
7162 | 1009 fprintf (plot_stream, |
11615 | 1010 "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 1011 undo_string_escapes (label), units, |
11615 | 1012 lpos(1), lpos(2), halign, angle, fontspec, |
1013 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 1014 endif |
1015 | |
1016 otherwise | |
1017 error ("__go_draw_axes__: unknown object class, %s", | |
1018 obj.type); | |
1019 endswitch | |
1020 | |
1021 endfor | |
1022 | |
7175 | 1023 if (isnan(hidden_removal) || hidden_removal) |
7149 | 1024 fputs (plot_stream, "set hidden3d;\n"); |
1025 else | |
1026 fputs (plot_stream, "unset hidden3d;\n"); | |
1027 endif | |
1028 | |
7152 | 1029 have_data = (! (isempty (data) || any (cellfun (@isempty, data)))); |
6405 | 1030 |
7222 | 1031 if (isempty (xlim)) |
1032 return; | |
6405 | 1033 endif |
6758 | 1034 if (strcmpi (axis_obj.xdir, "reverse")) |
6405 | 1035 xdir = "reverse"; |
1036 else | |
1037 xdir = "noreverse"; | |
1038 endif | |
7115 | 1039 fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", |
1040 xaxisloc, xlim, xdir); | |
6405 | 1041 |
7222 | 1042 if (isempty (ylim)) |
1043 return; | |
6405 | 1044 endif |
6758 | 1045 if (strcmpi (axis_obj.ydir, "reverse")) |
6405 | 1046 ydir = "reverse"; |
1047 else | |
1048 ydir = "noreverse"; | |
1049 endif | |
7110 | 1050 fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", |
1051 yaxisloc, ylim, ydir); | |
6405 | 1052 |
7119 | 1053 if (nd == 3) |
7222 | 1054 if (isempty (zlim)) |
1055 return; | |
6405 | 1056 endif |
6758 | 1057 if (strcmpi (axis_obj.zdir, "reverse")) |
6405 | 1058 zdir = "reverse"; |
1059 else | |
1060 zdir = "noreverse"; | |
1061 endif | |
6942 | 1062 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); |
6405 | 1063 endif |
7110 | 1064 |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1065 cmap = parent_figure_obj.colormap; |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1066 cmap_sz = rows(cmap); |
7189 | 1067 if (! any (isinf (clim))) |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1068 if (cdatadirect) |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1069 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz); |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1070 else |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1071 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1072 endif |
7189 | 1073 endif |
1074 | |
6758 | 1075 if (strcmpi (axis_obj.box, "on")) |
7119 | 1076 if (nd == 3) |
6405 | 1077 fputs (plot_stream, "set border 4095;\n"); |
1078 else | |
1079 fputs (plot_stream, "set border 431;\n"); | |
1080 endif | |
1081 else | |
7119 | 1082 if (nd == 3) |
6405 | 1083 fputs (plot_stream, "set border 895;\n"); |
1084 else | |
7320 | 1085 if (strcmpi (axis_obj.yaxislocation, "right")) |
1086 fputs (plot_stream, "unset ytics; set y2tics nomirror\n"); | |
1087 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1088 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | |
1089 fputs (plot_stream, "set border 12;\n"); | |
1090 else | |
1091 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | |
1092 fputs (plot_stream, "set border 9;\n"); | |
1093 endif | |
1094 else | |
1095 fputs (plot_stream, "unset y2tics; set ytics nomirror\n"); | |
1096 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1097 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | |
1098 fputs (plot_stream, "set border 6;\n"); | |
1099 else | |
1100 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | |
1101 fputs (plot_stream, "set border 3;\n"); | |
1102 endif | |
1103 endif | |
6405 | 1104 endif |
1105 endif | |
1106 | |
7060 | 1107 if (strcmpi (axis_obj.visible, "off")) |
1108 fputs (plot_stream, "unset border; unset tics\n"); | |
1109 endif | |
1110 | |
6758 | 1111 if (strcmpi (axis_obj.key, "on")) |
1112 if (strcmpi (axis_obj.keybox, "on")) | |
6405 | 1113 box = "box"; |
1114 else | |
1115 box = "nobox"; | |
1116 endif | |
1117 inout = "inside"; | |
6977 | 1118 keypos = axis_obj.keypos; |
1119 if (ischar (keypos)) | |
1120 keypos = lower (keypos); | |
1121 keyout = findstr (keypos, "outside"); | |
1122 if (! isempty (keyout)) | |
1123 inout = "outside"; | |
7119 | 1124 keypos = keypos(1:keyout-1); |
6977 | 1125 endif |
1126 endif | |
1127 switch (keypos) | |
6405 | 1128 case -1 |
6977 | 1129 pos = "right top"; |
6405 | 1130 inout = "outside"; |
1131 case 1 | |
1132 pos = "right top"; | |
1133 case 2 | |
1134 pos = "left top"; | |
1135 case 3 | |
1136 pos = "left bottom"; | |
6977 | 1137 case {4, 0} |
6405 | 1138 pos = "right bottom"; |
6977 | 1139 case "north" |
1140 pos = "center top"; | |
1141 case "south" | |
1142 pos = "center bottom"; | |
1143 case "east" | |
1144 pos = "right center"; | |
1145 case "west" | |
1146 pos = "left center"; | |
1147 case "northeast" | |
1148 pos = "right top"; | |
1149 case "northwest" | |
1150 pos = "left top"; | |
1151 case "southeast" | |
1152 pos = "right bottom"; | |
1153 case "southwest" | |
1154 pos = "left bottom"; | |
1155 case "best" | |
1156 pos = ""; | |
1157 warning ("legend: 'Best' not yet implemented for location specifier.\n"); | |
1158 ## least conflict with data in plot | |
1159 ## least unused space outside plot | |
6405 | 1160 otherwise |
1161 pos = ""; | |
1162 endswitch | |
1163 if (! have_newer_gnuplot) | |
1164 inout = ""; | |
1165 endif | |
1166 fprintf (plot_stream, "set key %s %s %s;\n", inout, pos, box); | |
1167 else | |
1168 fputs (plot_stream, "unset key;\n"); | |
1169 endif | |
1170 | |
1171 fputs (plot_stream, "set style data lines;\n"); | |
1172 | |
1173 if (! use_gnuplot_for_images) | |
1174 for i = 1:ximg_data_idx | |
1175 view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd); | |
1176 endfor | |
1177 endif | |
1178 | |
7189 | 1179 if (length(cmap) > 0) |
1180 if (have_newer_gnuplot) | |
1181 fprintf (plot_stream, | |
1182 "set palette positive color model RGB maxcolors %i;\n", | |
1183 cmap_sz); | |
1184 fprintf (plot_stream, | |
1185 "set palette file \"-\" binary record=%d using 1:2:3:4;\n", | |
1186 cmap_sz); | |
1187 fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32"); | |
11636
2be7477f470a
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
11635
diff
changeset
|
1188 fwrite (plot_stream, "\n"); |
7189 | 1189 else |
1190 fputs (plot_stream, "set palette defined ("); | |
1191 for i = 1: cmap_sz | |
1192 col = floor(cmap(i, :) * 255); | |
1193 if (i == 1) | |
1194 fputs (plot_stream, sprintf("%d \"#%02X%02X%02X\"", i - 1, | |
1195 col(1), col(2), col(3))); | |
1196 else | |
1197 fputs (plot_stream, sprintf(", %d \"#%02X%02X%02X\"", i - 1, | |
1198 col(1), col(2), col(3))); | |
1199 endif | |
1200 endfor | |
1201 fputs (plot_stream, ");\n"); | |
1202 endif | |
1203 endif | |
1204 | |
1205 if (strcmp (axis_obj.__colorbar__, "none")) | |
1206 fputs (plot_stream, "unset colorbox;\n"); | |
1207 else | |
1208 ## FIXME If cbox_mirror is true we want to invert the tic labels | |
1209 ## but gnuplot doesn't allow that | |
1210 fputs (plot_stream, | |
1211 sprintf ("set colorbox %s user origin %f,%f size %f,%f;\n", | |
1212 cbox_orient, cbox_origin, cbox_size)); | |
1213 endif | |
1214 | |
6405 | 1215 if (have_data) |
1216 if (nd == 2) | |
1217 plot_cmd = "plot"; | |
1218 else | |
1219 plot_cmd = "splot"; | |
1220 rot_x = 90 - axis_obj.view(2); | |
1221 rot_z = axis_obj.view(1); | |
1222 while (rot_z < 0) | |
1223 rot_z += 360; | |
1224 endwhile | |
6461 | 1225 fputs (plot_stream, "set ticslevel 0;\n"); |
7271 | 1226 if (view_map && rot_x == 0 && rot_z == 0) |
1227 fputs (plot_stream, "set view map;\n"); | |
1228 else | |
1229 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); | |
1230 endif | |
6405 | 1231 endif |
6611 | 1232 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
6464 | 1233 usingclause{1}, titlespec{1}, withclause{1}); |
6405 | 1234 for i = 2:data_idx |
6611 | 1235 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", |
6464 | 1236 usingclause{i}, titlespec{i}, withclause{i}); |
6405 | 1237 endfor |
1238 fputs (plot_stream, ";\n"); | |
1239 for i = 1:data_idx | |
6464 | 1240 if (is_image_data(i)) |
1241 fwrite (plot_stream, data{i}, "float32"); | |
1242 else | |
7119 | 1243 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i), |
1244 have_cdata(i)); | |
6405 | 1245 endif |
1246 endfor | |
6431 | 1247 else |
1248 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n"); | |
6405 | 1249 endif |
1250 | |
7271 | 1251 ## Needed to allow mouse rotation with pcolor |
1252 if (view_map) | |
1253 fputs (plot_stream, "unset view;\n"); | |
1254 endif | |
1255 | |
6405 | 1256 fflush (plot_stream); |
1257 | |
1258 else | |
1259 print_usage (); | |
7109 | 1260 endif |
6405 | 1261 |
1262 endfunction | |
1263 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1264 function [style, typ, with] = do_linestyle_command (obj, idx, mono, |
11658
db22340e1f24
__stepimp__: don't call subplot for single plot
John W. Eaton <jwe@octave.org>
parents:
11655
diff
changeset
|
1265 plot_stream, errbars = "") |
6405 | 1266 |
6413 | 1267 persistent have_newer_gnuplot ... |
1268 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
6405 | 1269 |
1270 if (have_newer_gnuplot) | |
1271 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1272 endif | |
1273 fprintf (plot_stream, "set style line %d", idx); | |
1274 | |
1275 found_style = false; | |
6425 | 1276 typ = NaN; |
6465 | 1277 with = ""; |
6405 | 1278 |
6425 | 1279 if (isfield (obj, "color")) |
6405 | 1280 color = obj.color; |
1281 if (isnumeric (color)) | |
6425 | 1282 if (have_newer_gnuplot) |
7269 | 1283 if (! mono) |
1284 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1285 round (255*color)); | |
1286 endif | |
6425 | 1287 else |
1288 if (isequal (color, [0,0,0])) | |
1289 typ = -1; | |
1290 elseif (isequal (color, [1,0,0])) | |
1291 typ = 1; | |
1292 elseif (isequal (color, [0,1,0])) | |
1293 typ = 2; | |
1294 elseif (isequal (color, [0,0,1])) | |
1295 typ = 3; | |
1296 elseif (isequal (color, [1,0,1])) | |
1297 typ = 4; | |
1298 elseif (isequal (color, [0,1,1])) | |
1299 typ = 5; | |
1300 elseif (isequal (color, [1,1,1])) | |
1301 typ = 6; | |
1302 elseif (isequal (color, [1,1,0])) | |
1303 typ = 7; | |
1304 else | |
1305 typ = 2; | |
1306 endif | |
1307 endif | |
6405 | 1308 endif |
1309 found_style = true; | |
1310 endif | |
1311 | |
1312 if (isfield (obj, "linestyle")) | |
1313 switch (obj.linestyle) | |
1314 case "-" | |
6415 | 1315 lt = "1"; |
6405 | 1316 case "--" |
6415 | 1317 lt = "2"; |
6405 | 1318 case ":" |
6415 | 1319 lt = "3"; |
6405 | 1320 case "-." |
6415 | 1321 lt = "6"; |
6405 | 1322 case "none" |
1323 lt = ""; | |
1324 otherwise | |
1325 lt = ""; | |
1326 endswitch | |
6843 | 1327 |
1328 ## FIXME -- linetype is currently broken, since it disables the | |
1329 ## gnuplot default dashed and solid linestyles with the only | |
1330 ## benefit of being able to specify '--' and get a single sized | |
1331 ## dashed line of identical dash pattern for all called this way. | |
1332 ## All dash patterns are a subset of "with lines" and none of the | |
1333 ## lt specifications will correctly propagate into the x11 terminal | |
1334 ## or the print command. Therefore, it is currently disabled in | |
1335 ## order to allow print (..., "-dashed") etc. to work correctly. | |
1336 | |
1337 ## if (! isempty (lt)) | |
1338 ## fprintf (plot_stream, " linetype %s", lt); | |
1339 ## found_style = true; | |
1340 ## endif | |
1341 | |
6405 | 1342 else |
1343 lt = ""; | |
1344 endif | |
1345 | |
1346 if (isfield (obj, "linewidth")) | |
6465 | 1347 if (have_newer_gnuplot) |
1348 fprintf (plot_stream, " linewidth %f", obj.linewidth); | |
1349 else | |
1350 with = sprintf ("%s lw %f", with, obj.linewidth); | |
1351 endif | |
6405 | 1352 found_style = true; |
1353 endif | |
1354 | |
1355 if (isfield (obj, "marker")) | |
1356 switch (obj.marker) | |
1357 case "+" | |
1358 pt = "1"; | |
1359 case "o" | |
6413 | 1360 pt = "6"; |
6405 | 1361 case "*" |
1362 pt = "3"; | |
1363 case "." | |
7078 | 1364 pt = "0"; |
6405 | 1365 case "x" |
1366 pt = "2"; | |
1367 case {"square", "s"} | |
1368 pt = "5"; | |
1369 case {"diamond", "d"} | |
1370 pt = "13"; | |
1371 case "^" | |
1372 pt = "9"; | |
1373 case "v" | |
1374 pt = "11"; | |
1375 case ">" | |
1376 pt = "8"; | |
1377 case "<" | |
1378 pt = "10"; | |
1379 case {"pentagram", "p"} | |
1380 pt = "4"; | |
1381 case {"hexagram", "h"} | |
6413 | 1382 pt = "12"; |
6405 | 1383 case "none" |
1384 pt = ""; | |
1385 otherwise | |
1386 pt = ""; | |
1387 endswitch | |
1388 if (! isempty (pt)) | |
6465 | 1389 if (have_newer_gnuplot) |
1390 fprintf (plot_stream, " pointtype %s", pt); | |
1391 else | |
1392 with = sprintf ("%s pt %s", with, pt); | |
1393 endif | |
6405 | 1394 found_style = true; |
1395 endif | |
1396 else | |
1397 pt = ""; | |
1398 endif | |
1399 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1400 if (isempty (errbars)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1401 style = "lines"; |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1402 if (isempty (lt)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1403 if (! isempty (pt)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1404 style = "points"; |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1405 endif |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1406 elseif (! isempty (pt)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1407 style = "linespoints"; |
6405 | 1408 endif |
1409 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1410 if (isfield (obj, "markersize")) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1411 if (have_newer_gnuplot) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1412 fprintf (plot_stream, " pointsize %f", obj.markersize); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1413 else |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1414 if (! strcmpi (style, "lines")) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1415 with = sprintf ("%s ps %f", with, obj.markersize); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1416 endif |
6465 | 1417 endif |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1418 found_style = true; |
6465 | 1419 endif |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1420 else |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1421 style = errbars; |
6465 | 1422 found_style = true; |
1423 endif | |
1424 | |
6405 | 1425 if (have_newer_gnuplot && ! found_style) |
1426 fputs (plot_stream, " default"); | |
1427 endif | |
1428 | |
1429 fputs (plot_stream, ";\n"); | |
1430 | |
1431 endfunction | |
6510 | 1432 |
7316 | 1433 function nd = __calc_dimensions__ (obj) |
1434 kids = obj.children; | |
1435 nd = 2; | |
1436 for i = 1:length (kids) | |
1437 obj = get (kids(i)); | |
1438 switch (obj.type) | |
1439 case {"image", "text"} | |
1440 ## ignore as they | |
1441 case {"line", "patch"} | |
1442 if (! isempty (obj.zdata)) | |
1443 nd = 3; | |
1444 endif | |
1445 case "surface" | |
1446 nd = 3; | |
1447 endswitch | |
1448 endfor | |
1449 endfunction | |
1450 | |
7119 | 1451 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) |
6510 | 1452 |
1453 ## DATA is already transposed. | |
1454 | |
1455 ## FIXME -- this may need to be converted to C++ for speed. | |
1456 | |
6605 | 1457 ## Convert NA elements to normal NaN values because fprintf writes |
1458 ## "NA" and that confuses gnuplot. | |
1459 idx = find (isna (data)); | |
1460 if (any (idx)) | |
1461 data(idx) = NaN; | |
1462 endif | |
1463 | |
6510 | 1464 if (nd == 2) |
1465 nan_elts = find (sum (isnan (data))); | |
6914 | 1466 fmt = strcat (repmat ("%.15g ", 1, rows (data)), "\n"); |
6510 | 1467 if (isempty (nan_elts)) |
1468 fprintf (plot_stream, fmt, data); | |
1469 else | |
1470 n = columns (data); | |
1471 have_nans = true; | |
1472 num_nan_elts = numel (nan_elts); | |
1473 k = 1; | |
1474 for i = 1:n | |
1475 if (have_nans && i == nan_elts(k)) | |
1476 fputs (plot_stream, "\n"); | |
1477 have_nans = ++k <= num_nan_elts; | |
1478 else | |
1479 fprintf (plot_stream, fmt, data(:,i)); | |
1480 endif | |
1481 endfor | |
1482 endif | |
7109 | 1483 elseif (nd == 3) |
6510 | 1484 ## FIXME -- handle NaNs here too? |
1485 if (parametric) | |
6914 | 1486 fprintf (plot_stream, "%.15g %.15g %.15g\n", data); |
6510 | 1487 else |
7170 | 1488 nr = rows (data); |
7119 | 1489 if (cdata) |
7170 | 1490 for j = 1:4:nr |
1491 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(j:j+3,:)); | |
7119 | 1492 fputs (plot_stream, "\n"); |
1493 endfor | |
1494 else | |
7170 | 1495 for j = 1:3:nr |
1496 fprintf (plot_stream, "%.15g %.15g %.15g\n", data(j:j+2,:)); | |
7119 | 1497 fputs (plot_stream, "\n"); |
1498 endfor | |
1499 endif | |
7109 | 1500 endif |
6510 | 1501 endif |
1502 fputs (plot_stream, "e\n"); | |
1503 | |
1504 endfunction | |
6745 | 1505 |
7269 | 1506 function do_tics (obj, plot_stream, ymirror, mono) |
6809 | 1507 if (strcmpi (obj.xaxislocation, "top")) |
1508 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7321 | 1509 obj.xcolor, "x2", plot_stream, true, mono, "border"); |
6809 | 1510 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7321 | 1511 obj.xcolor, "x", plot_stream, true, mono, "border"); |
1512 elseif (strcmpi (obj.xaxislocation, "zero")) | |
1513 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
1514 obj.xcolor, "x", plot_stream, true, mono, "axis"); | |
1515 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, | |
1516 obj.xcolor, "x2", plot_stream, true, mono, "axis"); | |
6809 | 1517 else |
1518 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7321 | 1519 obj.xcolor, "x", plot_stream, true, mono, "border"); |
6809 | 1520 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7321 | 1521 obj.xcolor, "x2", plot_stream, true, mono, "border"); |
6809 | 1522 endif |
1523 if (strcmpi (obj.yaxislocation, "right")) | |
1524 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7321 | 1525 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); |
6809 | 1526 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7321 | 1527 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); |
1528 elseif (strcmpi (obj.xaxislocation, "zero")) | |
1529 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
1530 obj.ycolor, "y", plot_stream, ymirror, mono, "axis"); | |
1531 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, | |
1532 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis"); | |
6809 | 1533 else |
1534 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7321 | 1535 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); |
6809 | 1536 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7321 | 1537 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); |
6809 | 1538 endif |
6745 | 1539 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, |
7321 | 1540 obj.zcolor, "z", plot_stream, true, mono, "border"); |
6745 | 1541 endfunction |
1542 | |
7269 | 1543 function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, |
7321 | 1544 plot_stream, mirror, mono, axispos) |
7269 | 1545 colorspec = get_text_colorspec (color, mono); |
6758 | 1546 if (strcmpi (ticmode, "manual")) |
6745 | 1547 if (isempty (tics)) |
1548 fprintf (plot_stream, "unset %stics;\n", ax); | |
6758 | 1549 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) |
6751 | 1550 if (ischar (labels)) |
1551 labels = cellstr (labels); | |
1552 endif | |
6745 | 1553 if (iscellstr (labels)) |
6751 | 1554 k = 1; |
1555 ntics = numel (tics); | |
1556 nlabels = numel (labels); | |
6745 | 1557 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
7206 | 1558 if (mirror) |
7321 | 1559 fprintf (plot_stream, "set %stics %s (", ax, axispos); |
7206 | 1560 else |
7321 | 1561 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); |
7206 | 1562 endif |
7228 | 1563 labels = regexprep(labels, "%", "%%"); |
6745 | 1564 for i = 1:ntics |
7228 | 1565 fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i)) |
6745 | 1566 if (i < ntics) |
1567 fputs (plot_stream, ", "); | |
1568 endif | |
1569 if (k > nlabels) | |
1570 k = 1; | |
1571 endif | |
1572 endfor | |
7220 | 1573 fprintf (plot_stream, ") %s;\n", colorspec); |
6745 | 1574 else |
1575 error ("unsupported type of ticklabel"); | |
1576 endif | |
1577 else | |
6920 | 1578 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1579 if (mirror) |
7321 | 1580 fprintf (plot_stream, "set %stics %s (", ax, axispos ); |
7206 | 1581 else |
7321 | 1582 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); |
7206 | 1583 endif |
6920 | 1584 fprintf (plot_stream, " %g,", tics(1:end-1)); |
1585 fprintf (plot_stream, " %g);\n", tics(end)); | |
6745 | 1586 endif |
1587 else | |
6920 | 1588 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1589 if (mirror) |
7321 | 1590 fprintf (plot_stream, "set %stics %s %s;\n", ax, axispos, colorspec); |
7206 | 1591 else |
7321 | 1592 fprintf (plot_stream, "set %stics %s nomirror %s;\n", ax, |
1593 axispos, colorspec); | |
7206 | 1594 endif |
7194 | 1595 endif |
1596 endfunction | |
1597 | |
7269 | 1598 function colorspec = get_text_colorspec (color, mono) |
7194 | 1599 persistent have_newer_gnuplot ... |
1600 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
1601 | |
1602 if (have_newer_gnuplot) | |
7269 | 1603 if (mono) |
1604 colorspec = ""; | |
1605 else | |
1606 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"", | |
1607 round (255*color)); | |
1608 endif | |
7194 | 1609 else |
1610 if (isequal (color, [0,0,0])) | |
1611 typ = -1; | |
1612 elseif (isequal (color, [1,0,0])) | |
1613 typ = 1; | |
1614 elseif (isequal (color, [0,1,0])) | |
1615 typ = 2; | |
1616 elseif (isequal (color, [0,0,1])) | |
1617 typ = 3; | |
1618 elseif (isequal (color, [1,0,1])) | |
1619 typ = 4; | |
1620 elseif (isequal (color, [0,1,1])) | |
1621 typ = 5; | |
1622 elseif (isequal (color, [1,1,1])) | |
1623 typ = -1; | |
1624 elseif (isequal (color, [1,1,0])) | |
1625 typ = 7; | |
1626 else | |
1627 typ = -1; | |
1628 endif | |
1629 colorspec = sprintf ("textcolor lt %d", typ); | |
6745 | 1630 endif |
1631 endfunction | |
7163 | 1632 |
7189 | 1633 function [f, s, fnt, it, bld] = get_fontname_and_size (t) |
7163 | 1634 if (isempty (t.fontname)) |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1635 fnt = "Helvetica"; |
7163 | 1636 else |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1637 fnt = t.fontname; |
7168 | 1638 endif |
7189 | 1639 f = fnt; |
1640 it = false; | |
1641 bld = false; | |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1642 if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold")) |
7168 | 1643 if (! isempty(t.fontangle) |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1644 && (strcmpi (t.fontangle, "italic") |
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1645 || strcmpi (t.fontangle, "oblique"))) |
7168 | 1646 f = strcat (f, "-bolditalic"); |
7189 | 1647 it = true; |
1648 bld = true; | |
7168 | 1649 else |
1650 f = strcat (f, "-bold"); | |
7189 | 1651 bld = true; |
7168 | 1652 endif |
1653 elseif (! isempty(t.fontangle) | |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1654 && (strcmpi (t.fontangle, "italic") |
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1655 || strcmpi (t.fontangle, "oblique"))) |
7168 | 1656 f = strcat (f, "-italic"); |
7189 | 1657 it = true; |
7163 | 1658 endif |
1659 if (isempty (t.fontsize)) | |
1660 s = 10; | |
1661 else | |
1662 s = t.fontsize; | |
1663 endif | |
1664 endfunction | |
7189 | 1665 |
1666 function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld, | |
1667 have_newer_gnuplot) | |
1668 persistent warned_latex = false; | |
1669 | |
1670 if (strcmp (fld, "string")) | |
1671 [f, s, fnt, it, bld] = get_fontname_and_size (obj); | |
1672 else | |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1673 f = "Helvetica"; |
7189 | 1674 s = 10; |
1675 fnt = f; | |
1676 it = false; | |
1677 bld = false; | |
1678 endif | |
1679 | |
1680 str = getfield (obj, fld); | |
1681 if (enhanced) | |
1682 if (strcmp (obj.interpreter, "tex")) | |
1683 str = __tex2enhanced__ (str, fnt, it, bld); | |
1684 if (! have_newer_gnuplot) | |
1685 ## Set the font to work around gnuplot 4.0 X11 enhanced terminal bug | |
1686 str = strcat ('{/', f, ' ', str, ' }'); | |
1687 endif | |
1688 elseif (strcmp (obj.interpreter, "latex")) | |
1689 if (! warned_latex) | |
1690 warning ("latex text objects not supported"); | |
1691 warned_latex = true; | |
1692 endif | |
1693 endif | |
1694 endif | |
1695 endfunction | |
1696 | |
1697 function str = __tex2enhanced__ (str, fnt, it, bld) | |
1698 persistent sym = __setup_sym_table__ (); | |
1699 persistent flds = fieldnames (sym); | |
1700 | |
1701 [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches'); | |
1702 | |
1703 for i = length (s) : -1 : 1 | |
1704 ## special case for "\0" and replace with "{/Symbol \306}' | |
1705 if (strncmp (m{i}, '\0', 2)) | |
7190 | 1706 str = strcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); |
7189 | 1707 else |
1708 f = m{i}(2:end); | |
1709 if (isfield (sym, f)) | |
1710 g = getfield(sym, f); | |
1711 ## FIXME The symbol font doesn't seem to support bold or italic | |
1712 ##if (bld) | |
1713 ## if (it) | |
1714 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1715 ## else | |
1716 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1717 ## endif | |
1718 ##elseif (it) | |
1719 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1720 ##endif | |
1721 str = strcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); | |
1722 elseif (strncmp (f, "rm", 2)) | |
1723 bld = false; | |
1724 it = false; | |
1725 str = strcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); | |
1726 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) | |
1727 it = true; | |
1728 if (bld) | |
1729 str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', | |
1730 str(s(i) + 3:end)); | |
1731 else | |
1732 str = strcat (str(1:s(i) - 1), '/', fnt, '-italic ', | |
1733 str(s(i) + 3:end)); | |
1734 endif | |
1735 elseif (strncmp (f, "bf", 2)) | |
1736 bld = true; | |
1737 if (it) | |
1738 str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', | |
1739 str(2(i) + 3:end)); | |
1740 else | |
1741 str = strcat (str(1:s(i) - 1), '/', fnt, '-bold ', | |
1742 str(s(i) + 3:end)); | |
1743 endif | |
1744 elseif (strcmp (f, "color")) | |
1745 ## FIXME Ignore \color but remove trailing {} block as well | |
1746 d = strfind(str(e(i) + 1:end),'}'); | |
1747 if (isempty (d)) | |
1748 warning ('syntax error in \color argument'); | |
1749 else | |
1750 str = strcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); | |
1751 endif | |
1752 elseif(strcmp (f, "fontname")) | |
1753 b1 = strfind(str(e(i) + 1:end),'{'); | |
1754 b2 = strfind(str(e(i) + 1:end),'}'); | |
1755 if (isempty(b1) || isempty(b2)) | |
1756 warning ('syntax error in \fontname argument'); | |
1757 else | |
1758 str = strcat (str(1:s(i) - 1), '/', | |
1759 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', | |
1760 str(e(i) + b2(1) + 1:end)); | |
1761 endif | |
1762 elseif(strcmp (f, "fontsize")) | |
1763 b1 = strfind(str(e(i) + 1:end),'{'); | |
1764 b2 = strfind(str(e(i) + 1:end),'}'); | |
1765 if (isempty(b1) || isempty(b2)) | |
1766 warning ('syntax error in \fontname argument'); | |
1767 else | |
1768 str = strcat (str(1:s(i) - 1), '/=', | |
1769 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', | |
1770 str(e(i) + b2(1) + 1:end)); | |
1771 endif | |
1772 else | |
1773 ## Last desperate attempt to treat the symbol. Look for things | |
1774 ## like \pix, that should be translated to the symbol Pi and x | |
1775 for j = 1 : length (flds) | |
1776 if (strncmp (flds{j}, f, length (flds{j}))) | |
1777 g = getfield(sym, flds{j}); | |
1778 ## FIXME The symbol font doesn't seem to support bold or italic | |
1779 ##if (bld) | |
1780 ## if (it) | |
1781 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1782 ## else | |
1783 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1784 ## endif | |
1785 ##elseif (it) | |
1786 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1787 ##endif | |
1788 str = strcat (str(1:s(i) - 1), g, | |
1789 str(s(i) + length (flds{j}) + 1:end)); | |
1790 break; | |
1791 endif | |
1792 endfor | |
1793 endif | |
1794 endif | |
1795 endfor | |
1796 | |
1797 ## Prepend @ to things things like _0^x or _{-100}^{100} for alignment | |
1798 ## But need to put the shorter of the two arguments first. Carful of | |
1799 ## nested {} and unprinted characters when defining shortest.. Don't | |
1800 ## have to worry about things like ^\theta as they are already converted to | |
1801 ## ^{/Symbol q}. | |
1802 | |
1803 ## FIXME.. This is a mess... Is it worth it just for a "@" character? | |
1804 | |
1805 [s, m] = regexp(str,'[_\^]','start','matches'); | |
1806 i = 1; | |
1807 p = 0; | |
1808 while (i < length (s)) | |
1809 if (i < length(s)) | |
1810 if (str(s(i) + p + 1) == "{") | |
1811 s1 = strfind(str(s(i) + p + 2:end),'{'); | |
1812 si = 1; | |
1813 l1 = strfind(str(s(i) + p + 1:end),'}'); | |
1814 li = 1; | |
1815 while (li <= length (l1) && si <= length (s1)) | |
1816 if (l1(li) < s1(si)) | |
1817 if (li == si) | |
1818 break; | |
1819 endif | |
1820 li++; | |
1821 else | |
1822 si++; | |
1823 endif | |
1824 endwhile | |
1825 l1 = l1 (min (length(l1), si)); | |
1826 if (s(i) + l1 + 1 == s(i+1)) | |
1827 if (str(s(i + 1) + p + 1) == "{") | |
1828 s2 = strfind(str(s(i + 1) + p + 2:end),'{'); | |
1829 si = 1; | |
1830 l2 = strfind(str(s(i + 1) + p + 1:end),'}'); | |
1831 li = 1; | |
1832 while (li <= length (l2) && si <= length (s2)) | |
1833 if (l2(li) < s2(si)) | |
1834 if (li == si) | |
1835 break; | |
1836 endif | |
1837 li++; | |
1838 else | |
1839 si++; | |
1840 endif | |
1841 endwhile | |
1842 l2 = l2 (min (length(l2), si)); | |
1843 if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= | |
1844 length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) | |
1845 ## shortest already first! | |
1846 str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
1847 else | |
1848 ## Have to swap sub/super-script to get shortest first | |
1849 str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), | |
1850 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); | |
1851 endif | |
1852 else | |
1853 ## Have to swap sub/super-script to get shortest first | |
1854 str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), | |
1855 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); | |
1856 endif | |
1857 i += 2; | |
1858 p ++; | |
1859 else | |
1860 i++; | |
1861 endif | |
1862 else | |
1863 if (s(i+1) == s(i) + 2) | |
1864 ## shortest already first! | |
1865 str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
1866 p ++; | |
1867 i += 2; | |
1868 else | |
1869 i ++; | |
1870 endif | |
1871 endif | |
1872 else | |
1873 i ++; | |
1874 endif | |
1875 endwhile | |
1876 | |
1877 endfunction | |
1878 | |
1879 function l = length_string (s) | |
1880 l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}')); | |
1881 m = regexp (s, '/([\w\-]+|[\w\-]+=\d+)', 'matches'); | |
1882 if (!isempty (m)) | |
1883 l = l - sum (cellfun (@length, m)); | |
1884 endif | |
1885 endfunction | |
1886 | |
1887 function sym = __setup_sym_table__ () | |
1888 ## Setup the translation table for TeX to gnuplot enhanced mode. | |
1889 sym.forall = '{/Symbol \042}'; | |
1890 sym.exists = '{/Symbol \044}'; | |
1891 sym.ni = '{/Symbol \047}'; | |
1892 sym.cong = '{/Symbol \100}'; | |
1893 sym.Delta = '{/Symbol D}'; | |
1894 sym.Phi = '{/Symbol F}'; | |
1895 sym.Gamma = '/Symbol G}'; | |
7190 | 1896 sym.vartheta = '{/Symbol J}'; |
7189 | 1897 sym.Lambda = '{/Symbol L}'; |
1898 sym.Pi = '{/Symbol P}'; | |
1899 sym.Theta = '{/Symbol Q}'; | |
1900 sym.Sigma = '{/Symbol S}'; | |
1901 sym.varsigma = '{/Symbol V}'; | |
11622 | 1902 sym.Omega = '{/Symbol W}'; |
7189 | 1903 sym.Xi = '{/Symbol X}'; |
1904 sym.Psi = '{/Symbol Y}'; | |
1905 sym.perp = '{/Symbol \136}'; | |
1906 sym.alpha = '{/Symbol a}'; | |
1907 sym.beta = '{/Symbol b}'; | |
1908 sym.chi = '{/Symbol c}'; | |
1909 sym.delta = '{/Symbol d}'; | |
1910 sym.epsilon = '{/Symbol e}'; | |
1911 sym.phi = '{/Symbol f}'; | |
1912 sym.gamma = '/Symbol g}'; | |
1913 sym.eta = '{/Symbol h}'; | |
1914 sym.iota = '{/Symbol i}'; | |
1915 sym.kappa = '{/Symbol k}'; | |
1916 sym.lambda = '{/Symbol l}'; | |
1917 sym.mu = '{/Symbol m}'; | |
1918 sym.nu = '{/Symbol n}'; | |
1919 sym.o = '{/Symbol o}'; | |
1920 sym.pi = '{/Symbol p}'; | |
1921 sym.theta = '{/Symbol q}'; | |
1922 sym.rho = '{/Symbol r}'; | |
1923 sym.sigma = '{/Symbol s}'; | |
1924 sym.tau = '{/Symbol t}'; | |
1925 sym.upsilon = '{/Symbol u}'; | |
1926 sym.varpi = '{/Symbol v}'; | |
1927 sym.omega = '{/Symbol w}'; | |
1928 sym.xi = '{/Symbol x}'; | |
1929 sym.psi = '{/Symbol y}'; | |
1930 sym.zeta = '{/Symbol z}'; | |
1931 sym.sim = '{/Symbol \176}'; | |
1932 sym.Upsilon = '{/Symbol \241}'; | |
1933 sym.prime = '{/Symbol \242}'; | |
1934 sym.leq = '{/Symbol \243}'; | |
1935 sym.infty = '{/Symbol \245}'; | |
1936 sym.clubsuit = '{/Symbol \247}'; | |
1937 sym.diamondsuit = '{/Symbol \250}'; | |
1938 sym.heartsuit = '{/Symbol \251}'; | |
1939 sym.spadesuit = '{/Symbol \252}'; | |
1940 sym.leftrightarrow = '{/Symbol \253}'; | |
1941 sym.leftarrow = '{/Symbol \254}'; | |
1942 sym.uparrow = '{/Symbol \255}'; | |
1943 sym.rightarrow = '{/Symbol \256}'; | |
1944 sym.downarrow = '{/Symbol \257}'; | |
1945 sym.circ = '{/Symbol \260}'; | |
1946 sym.pm = '{/Symbol \261}'; | |
1947 sym.geq = '{/Symbol \263}'; | |
1948 sym.times = '{/Symbol \264}'; | |
1949 sym.propto = '{/Symbol \265}'; | |
1950 sym.partial = '{/Symbol \266}'; | |
1951 sym.bullet = '{/Symbol \267}'; | |
1952 sym.div = '{/Symbol \270}'; | |
1953 sym.neq = '{/Symbol \271}'; | |
1954 sym.equiv = '{/Symbol \272}'; | |
1955 sym.approx = '{/Symbol \273}'; | |
1956 sym.ldots = '{/Symbol \274}'; | |
1957 sym.mid = '{/Symbol \275}'; | |
1958 sym.aleph = '{/Symbol \300}'; | |
1959 sym.Im = '{/Symbol \301}'; | |
1960 sym.Re = '{/Symbol \302}'; | |
1961 sym.wp = '{/Symbol \303}'; | |
1962 sym.otimes = '{/Symbol \304}'; | |
1963 sym.oplus = '{/Symbol \305}'; | |
1964 sym.oslash = '{/Symbol \306}'; | |
1965 sym.cap = '{/Symbol \307}'; | |
1966 sym.cup = '{/Symbol \310}'; | |
1967 sym.supset = '{/Symbol \311}'; | |
1968 sym.supseteq = '{/Symbol \312}'; | |
1969 sym.subset = '{/Symbol \314}'; | |
1970 sym.subseteq = '{/Symbol \315}'; | |
1971 sym.in = '{/Symbol \316}'; | |
1972 sym.langle = '{/Symbol \320}'; | |
1973 sym.rangle = '{/Symbol \320}'; | |
1974 sym.nabla = '{/Symbol \321}'; | |
1975 sym.surd = '{/Symbol \326}'; | |
1976 sym.cdot = '{/Symbol \327}'; | |
1977 sym.neg = '{/Symbol \330}'; | |
1978 sym.wedge = '{/Symbol \331}'; | |
1979 sym.vee = '{/Symbol \332}'; | |
1980 sym.copyright = '{/Symbol \343}'; | |
1981 sym.rfloor = '{/Symbol \353}'; | |
1982 sym.lceil = '{/Symbol \351}'; | |
1983 sym.lfloor = '{/Symbol \373}'; | |
1984 sym.rceil = '{/Symbol \371}'; | |
1985 sym.int = '{/Symbol \362}'; | |
1986 endfunction | |
1987 | |
1988 function [pos, orient, sz, origin, mirr] = gnuplot_postion_colorbox (pos, cbox) | |
1989 ## This is an emprically derived function that | |
1990 | |
1991 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
1992 scl = pos([2,4]); | |
1993 else | |
1994 scl = pos([1,3]); | |
1995 endif | |
1996 | |
1997 if (length(cbox) > 7 && strncmp (cbox(end-6:end), "outside", 7)) | |
1998 scl(2) -= 0.2 * scl(2); | |
1999 if (strncmp (cbox, "west", 4) || strncmp (cbox, "south", 5)) | |
2000 scl(1) += 0.2 * scl(2); | |
2001 endif | |
2002 endif | |
2003 | |
2004 switch (cbox) | |
2005 case "northoutside" | |
2006 sz = pos(3:4) - 0.08; | |
2007 origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2); | |
2008 mirr = true; | |
2009 orient = "horizontal"; | |
2010 case "north" | |
2011 sz = pos(3:4) - 0.16; | |
2012 origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2); | |
2013 mirr = false; | |
2014 orient = "horizontal"; | |
2015 case "southoutside" | |
2016 sz = pos(3:4) - 0.08; | |
2017 origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2); | |
2018 mirr = false; | |
2019 orient = "horizontal"; | |
2020 case "south" | |
2021 sz = pos(3:4) - 0.16; | |
2022 origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2); | |
2023 mirr = true; | |
2024 orient = "horizontal"; | |
2025 case "eastoutside" | |
2026 sz = pos(3:4) - 0.08; | |
2027 origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2); | |
2028 mirr = false; | |
2029 orient = "vertical"; | |
2030 case "east" | |
2031 sz = pos(3:4) - 0.16; | |
2032 origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2); | |
2033 mirr = true; | |
2034 orient = "vertical"; | |
2035 case "westoutside" | |
2036 sz = pos(3:4) - 0.08; | |
2037 origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2); | |
2038 mirr = true; | |
2039 orient = "vertical"; | |
2040 case "west" | |
2041 sz = pos(3:4) - 0.16; | |
2042 origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2); | |
2043 mirr = false; | |
2044 orient = "vertical"; | |
2045 endswitch | |
2046 | |
2047 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
2048 sz = sz .* [1, 0.07]; | |
2049 pos([2,4]) = scl; | |
2050 else | |
2051 sz = sz .* [0.07, 1]; | |
2052 pos([1,3]) = scl; | |
2053 endif | |
2054 | |
2055 endfunction | |
11615 | 2056 |
2057 function retval = __do_enhanced_option__ (enhanced, obj) | |
2058 retval = ""; | |
2059 if (enhanced) | |
2060 if (strcmpi (obj.interpreter, "none")) | |
2061 retval = "noenhanced"; | |
2062 else | |
2063 retval = "enhanced"; | |
2064 endif | |
2065 endif | |
2066 endfunction |