Mercurial > hg > octave-lyh
annotate scripts/plot/__go_draw_axes__.m @ 7873:02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 05 Jun 2008 20:42:14 +0200 |
parents | b74039822fd2 |
children | 1f6eb3de1c4e |
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]; |
7583
1d7c23e288d7
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
7582
diff
changeset
|
36 if (strcmpi (axis_obj.activepositionproperty, "outerposition")) |
7240 | 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 | |
7583
1d7c23e288d7
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
7582
diff
changeset
|
52 if (! strcmpi (get (h, "__colorbar__"), "none")) |
7189 | 53 [pos, cbox_orient, cbox_size, cbox_origin, cbox_mirror] = ... |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
54 gnuplot_position_colorbox (pos, get (h, "__colorbar__"), axis_obj); |
7189 | 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 | |
6778 | 67 fputs (plot_stream, "unset label;\n"); |
68 | |
6405 | 69 if (! isempty (axis_obj.title)) |
70 t = get (axis_obj.title); | |
71 if (isempty (t.string)) | |
72 fputs (plot_stream, "unset title;\n"); | |
73 else | |
7189 | 74 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
75 have_newer_gnuplot); | |
7257 | 76 if (strcmp (f, "*")) |
77 fontspec = ""; | |
78 else | |
79 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
80 endif | |
7390 | 81 fprintf (plot_stream, "set title \"%s\" %s %s;\n", |
82 undo_string_escapes (tt), fontspec, | |
83 __do_enhanced_option__ (enhanced, t)); | |
6405 | 84 endif |
85 endif | |
86 | |
87 if (! isempty (axis_obj.xlabel)) | |
88 t = get (axis_obj.xlabel); | |
6737 | 89 angle = t.rotation; |
7269 | 90 colorspec = get_text_colorspec (axis_obj.xcolor, mono); |
6405 | 91 if (isempty (t.string)) |
7194 | 92 fprintf (plot_stream, "unset xlabel;\n"); |
93 fprintf (plot_stream, "unset x2label;\n"); | |
6405 | 94 else |
7189 | 95 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
96 have_newer_gnuplot); | |
7257 | 97 if (strcmp (f, "*")) |
98 fontspec = ""; | |
99 else | |
100 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
101 endif | |
7194 | 102 if (strcmpi (axis_obj.xaxislocation, "top")) |
7390 | 103 fprintf (plot_stream, "set x2label \"%s\" %s %s %s", |
104 undo_string_escapes (tt), colorspec, fontspec, | |
105 __do_enhanced_option__ (enhanced, t)); | |
7194 | 106 else |
7390 | 107 fprintf (plot_stream, "set xlabel \"%s\" %s %s %s", |
108 undo_string_escapes (tt), colorspec, fontspec, | |
109 __do_enhanced_option__ (enhanced, t)); | |
7194 | 110 endif |
6738 | 111 if (have_newer_gnuplot) |
112 ## Rotation of xlabel not yet support by gnuplot as of 4.2, but | |
113 ## there is no message about it. | |
114 fprintf (plot_stream, " rotate by %f", angle); | |
115 endif | |
116 fputs (plot_stream, ";\n"); | |
7194 | 117 if (strcmpi (axis_obj.xaxislocation, "top")) |
118 fprintf (plot_stream, "unset xlabel;\n"); | |
119 else | |
120 fprintf (plot_stream, "unset x2label;\n"); | |
121 endif | |
6405 | 122 endif |
123 endif | |
124 | |
125 if (! isempty (axis_obj.ylabel)) | |
126 t = get (axis_obj.ylabel); | |
6737 | 127 angle = t.rotation; |
7269 | 128 colorspec = get_text_colorspec (axis_obj.ycolor, mono); |
6405 | 129 if (isempty (t.string)) |
7194 | 130 fprintf (plot_stream, "unset ylabel;\n"); |
131 fprintf (plot_stream, "unset y2label;\n"); | |
6405 | 132 else |
7189 | 133 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
134 have_newer_gnuplot); | |
7257 | 135 if (strcmp (f, "*")) |
136 fontspec = ""; | |
137 else | |
138 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
139 endif | |
7194 | 140 if (strcmpi (axis_obj.yaxislocation, "right")) |
7390 | 141 fprintf (plot_stream, "set y2label \"%s\" %s %s %s", |
142 undo_string_escapes (tt), colorspec, fontspec, | |
143 __do_enhanced_option__ (enhanced, t)); | |
7194 | 144 else |
7390 | 145 fprintf (plot_stream, "set ylabel \"%s\" %s %s %s", |
146 undo_string_escapes (tt), colorspec, fontspec, | |
147 __do_enhanced_option__ (enhanced, t)); | |
7194 | 148 endif |
6738 | 149 if (have_newer_gnuplot) |
6766 | 150 fprintf (plot_stream, " rotate by %f;\n", angle); |
6738 | 151 endif |
152 fputs (plot_stream, ";\n"); | |
7194 | 153 if (strcmpi (axis_obj.yaxislocation, "right")) |
154 fprintf (plot_stream, "unset ylabel;\n"); | |
155 else | |
156 fprintf (plot_stream, "unset y2label;\n"); | |
157 endif | |
6405 | 158 endif |
159 endif | |
160 | |
161 if (! isempty (axis_obj.zlabel)) | |
162 t = get (axis_obj.zlabel); | |
6737 | 163 angle = t.rotation; |
7269 | 164 colorspec = get_text_colorspec (axis_obj.zcolor, mono); |
6405 | 165 if (isempty (t.string)) |
166 fputs (plot_stream, "unset zlabel;\n"); | |
167 else | |
7189 | 168 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
169 have_newer_gnuplot); | |
7257 | 170 if (strcmp (f, "*")) |
171 fontspec = ""; | |
172 else | |
173 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
174 endif | |
7390 | 175 fprintf (plot_stream, "set zlabel \"%s\" %s %s %s", |
176 undo_string_escapes (tt), colorspec, fontspec, | |
177 __do_enhanced_option__ (enhanced, t)); | |
6738 | 178 if (have_newer_gnuplot) |
179 ## Rotation of zlabel not yet support by gnuplot as of 4.2, but | |
180 ## there is no message about it. | |
181 fprintf (plot_stream, " rotate by %f;\n", angle); | |
182 endif | |
183 fputs (plot_stream, ";\n"); | |
6405 | 184 endif |
185 endif | |
186 | |
6809 | 187 if (strcmpi (axis_obj.xaxislocation, "top")) |
188 xaxisloc = "x2"; | |
189 xaxisloc_using = "x2"; | |
190 else | |
191 xaxisloc = "x"; | |
192 xaxisloc_using = "x1"; | |
7321 | 193 if (strcmpi (axis_obj.xaxislocation, "zero")) |
194 fputs (plot_stream, "set xzeroaxis;\n"); | |
195 endif | |
6809 | 196 endif |
197 if (strcmpi (axis_obj.yaxislocation, "right")) | |
198 yaxisloc = "y2"; | |
199 yaxisloc_using = "y2"; | |
200 else | |
201 yaxisloc = "y"; | |
202 yaxisloc_using = "y1"; | |
7321 | 203 if (strcmpi (axis_obj.yaxislocation, "zero")) |
204 fputs (plot_stream, "set yzeroaxis;\n"); | |
205 endif | |
6809 | 206 endif |
207 | |
7274 | 208 have_grid = false; |
209 | |
6758 | 210 if (strcmpi (axis_obj.xgrid, "on")) |
7274 | 211 have_grid = true; |
6809 | 212 fprintf (plot_stream, "set grid %stics;\n", xaxisloc); |
6405 | 213 else |
6809 | 214 fprintf (plot_stream, "set grid no%stics;\n", xaxisloc); |
6405 | 215 endif |
216 | |
6758 | 217 if (strcmpi (axis_obj.ygrid, "on")) |
7274 | 218 have_grid = true; |
6809 | 219 fprintf (plot_stream, "set grid %stics;\n", yaxisloc); |
6405 | 220 else |
6809 | 221 fprintf (plot_stream, "set grid no%stics;\n", yaxisloc); |
6405 | 222 endif |
223 | |
6758 | 224 if (strcmpi (axis_obj.zgrid, "on")) |
7274 | 225 have_grid = true; |
6405 | 226 fputs (plot_stream, "set grid ztics;\n"); |
227 else | |
7085 | 228 fputs (plot_stream, "set grid noztics;\n"); |
6405 | 229 endif |
230 | |
6758 | 231 if (strcmpi (axis_obj.xminorgrid, "on")) |
7274 | 232 have_grid = true; |
6809 | 233 fprintf (plot_stream, "set m%stics 5;\n", xaxisloc); |
234 fprintf (plot_stream, "set grid m%stics;\n", xaxisloc); | |
6405 | 235 else |
6809 | 236 fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc); |
6405 | 237 endif |
238 | |
6758 | 239 if (strcmpi (axis_obj.yminorgrid, "on")) |
7274 | 240 have_grid = true; |
6809 | 241 fprintf (plot_stream, "set m%stics 5;\n", yaxisloc); |
242 fprintf (plot_stream, "set grid m%stics;\n", yaxisloc); | |
6405 | 243 else |
6809 | 244 fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc); |
6405 | 245 endif |
246 | |
6758 | 247 if (strcmpi (axis_obj.zminorgrid, "on")) |
7274 | 248 have_grid = true; |
6405 | 249 fputs (plot_stream, "set mztics 5;\n"); |
250 fputs (plot_stream, "set grid mztics;\n"); | |
251 else | |
252 fputs (plot_stream, "set grid nomztics;\n"); | |
253 endif | |
254 | |
7307 | 255 ## The grid front/back/layerdefault option also controls the |
256 ## appearance of tics, so it is used even if the grid is absent. | |
257 if (strcmpi (axis_obj.layer, "top")) | |
258 fputs (plot_stream, "set grid front;\n"); | |
259 else | |
260 fputs (plot_stream, "set grid layerdefault;\n"); | |
261 endif | |
7297 | 262 if (! have_grid) |
263 fputs (plot_stream, "unset grid;\n"); | |
7274 | 264 endif |
265 | |
7269 | 266 do_tics (axis_obj, plot_stream, ymirror, mono); |
6405 | 267 |
6758 | 268 xlogscale = strcmpi (axis_obj.xscale, "log"); |
6405 | 269 if (xlogscale) |
6809 | 270 fprintf (plot_stream, "set logscale %s;\n", xaxisloc); |
6405 | 271 else |
6809 | 272 fprintf (plot_stream, "unset logscale %s;\n", xaxisloc); |
6405 | 273 endif |
274 | |
6758 | 275 ylogscale = strcmpi (axis_obj.yscale, "log"); |
6405 | 276 if (ylogscale) |
6809 | 277 fprintf (plot_stream, "set logscale %s;\n", yaxisloc); |
6405 | 278 else |
6809 | 279 fprintf (plot_stream, "unset logscale %s;\n", yaxisloc); |
6405 | 280 endif |
281 | |
6758 | 282 zlogscale = strcmpi (axis_obj.zscale, "log"); |
6405 | 283 if (zlogscale) |
284 fputs (plot_stream, "set logscale z;\n"); | |
285 else | |
286 fputs (plot_stream, "unset logscale z;\n"); | |
287 endif | |
288 | |
6758 | 289 xautoscale = strcmpi (axis_obj.xlimmode, "auto"); |
290 yautoscale = strcmpi (axis_obj.ylimmode, "auto"); | |
291 zautoscale = strcmpi (axis_obj.zlimmode, "auto"); | |
7109 | 292 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
|
293 cdatadirect = false; |
6405 | 294 |
295 kids = axis_obj.children; | |
296 | |
7316 | 297 nd = __calc_dimensions__ (axis_obj); |
298 | |
299 if (nd == 3) | |
300 fputs (plot_stream, "set parametric;\n"); | |
301 fputs (plot_stream, "set style data lines;\n"); | |
302 fputs (plot_stream, "set surface;\n"); | |
303 fputs (plot_stream, "unset contour;\n"); | |
304 endif | |
305 | |
6405 | 306 data_idx = 0; |
307 data = cell (); | |
6464 | 308 is_image_data = []; |
7175 | 309 hidden_removal = NaN; |
7271 | 310 view_map = false; |
6405 | 311 |
7223 | 312 xlim = axis_obj.xlim; |
313 ylim = axis_obj.ylim; | |
314 zlim = axis_obj.zlim; | |
315 clim = axis_obj.clim; | |
6405 | 316 |
7222 | 317 if (! cautoscale && clim(1) == clim(2)) |
318 clim(2)++; | |
7189 | 319 endif |
320 | |
6405 | 321 [view_cmd, view_fcn, view_zoom] = image_viewer (); |
322 use_gnuplot_for_images = (ischar (view_fcn) | |
7583
1d7c23e288d7
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
7582
diff
changeset
|
323 && strcmpi (view_fcn, "gnuplot_internal")); |
6405 | 324 |
325 ximg_data = {}; | |
326 ximg_data_idx = 0; | |
327 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
328 while (! isempty (kids)) |
6405 | 329 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
330 obj = get (kids(1)); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
331 kids = kids(2:end); |
6405 | 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 | |
7583
1d7c23e288d7
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
7582
diff
changeset
|
341 if (strcmpi (obj.cdatamapping, "direct")) |
7471
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)); |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
398 titlespec{data_idx} = cstrcat ("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; | |
7583
1d7c23e288d7
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
7582
diff
changeset
|
512 if (strcmpi (obj.cdatamapping, "direct")) |
7471
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)); |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
550 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); |
7170 | 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)) | |
7582 | 582 warning ("\"interp\" not supported, using 1st entry of cdata"); |
7170 | 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 |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
606 typ = get_old_gnuplot_color (color); |
7170 | 607 withclause{data_idx} = sprintf ("with filledcurve lt %d", typ); |
608 endif | |
609 data{data_idx} = [xcol, ycol]'; | |
610 usingclause{data_idx} = "using ($1):($2)"; | |
611 endif | |
612 endif | |
613 | |
614 ## patch outline | |
615 if (! strncmp (obj.edgecolor, "none", 4)) | |
616 | |
617 data_idx++; | |
618 is_image_data(data_idx) = false; | |
619 parametric(data_idx) = false; | |
620 have_cdata(data_idx) = false; | |
621 titlespec{data_idx} = "title \"\""; | |
7020 | 622 usingclause{data_idx} = ""; |
7189 | 623 |
624 if (isfield (obj, "markersize")) | |
7564
90536e155fde
adjust markersize by a factor of 1/6
John W. Eaton <jwe@octave.org>
parents:
7542
diff
changeset
|
625 mdat = obj.markersize / 6; |
7189 | 626 endif |
627 | |
628 if (isfield (obj, "edgecolor")) | |
629 if ((strncmp (obj.edgecolor, "flat", 4) | |
7284 | 630 || strncmp (obj.edgecolor, "interp", 6)) |
631 && isfield (obj, "cdata")) | |
7119 | 632 if (ndims (obj.cdata) == 2 |
7189 | 633 && (size (obj.cdata, 2) == nc |
634 && (size (obj.cdata, 1) == 1 | |
635 || size (obj.cdata, 1) == 3))) | |
636 ccol = cdat (:, i); | |
637 elseif (ndims (obj.cdata) == 2 | |
638 && (size (obj.cdata, 1) == nc | |
639 && (size (obj.cdata, 2) == 1 | |
640 || size (obj.cdata, 2) == 3))) | |
641 ccol = cdat (i, :); | |
7020 | 642 elseif (ndims (obj.cdata) == 3) |
7189 | 643 ccol = permute (cdat (:, i, :), [1, 3, 2]); |
7020 | 644 else |
7189 | 645 ccol = cdat; |
7020 | 646 endif |
7170 | 647 if (strncmp (obj.edgecolor, "flat", 4)) |
7189 | 648 if (numel(ccol) == 3) |
7020 | 649 color = ccol; |
650 else | |
7226 | 651 r = 1 + round ((size (cmap, 1) - 1) |
652 * (ccol - clim(1))/(clim(2) - clim(1))); | |
7020 | 653 r = max (1, min (r, size (cmap, 1))); |
654 color = cmap(r, :); | |
655 endif | |
7170 | 656 elseif (strncmp (obj.edgecolor, "interp", 6)) |
7582 | 657 warning ("\"interp\" not supported, using 1st entry of cdata"); |
7020 | 658 r = 1 + round ((size (cmap, 1) - 1) * ccol(1)); |
659 r = max (1, min (r, size (cmap, 1))); | |
660 color = cmap(r,:); | |
661 endif | |
7189 | 662 elseif (isnumeric (obj.edgecolor)) |
663 color = obj.edgecolor; | |
664 else | |
665 color = [0, 0, 0]; | |
7020 | 666 endif |
667 else | |
7189 | 668 color = [0, 0, 0]; |
7020 | 669 endif |
7189 | 670 |
671 if (isfield (obj, "linestyle")) | |
672 switch (obj.linestyle) | |
673 case "-" | |
7317 | 674 lt = "lt 1"; |
7189 | 675 case "--" |
7317 | 676 lt = "lt 2"; |
7189 | 677 case ":" |
7317 | 678 lt = "lt 3"; |
7189 | 679 case "-." |
7317 | 680 lt = "lt 6"; |
7189 | 681 case "none" |
682 lt = ""; | |
683 otherwise | |
684 lt = ""; | |
685 endswitch | |
686 else | |
687 lt = ""; | |
688 endif | |
689 | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
690 if (isfield (obj, "linewidth")) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
691 if (have_newer_gnuplot) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
692 lw = sprintf("linewidth %f", obj.linewidth); |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
693 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
694 lw = sprintf("lw %f", obj.linewidth); |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
695 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
696 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
697 lw = ""; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
698 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
699 |
7189 | 700 if (isfield (obj, "marker")) |
701 if (isfield (obj, "marker")) | |
702 switch (obj.marker) | |
703 case "+" | |
704 pt = "pt 1"; | |
705 case "o" | |
706 pt = "pt 6"; | |
707 case "*" | |
708 pt = "pt 3"; | |
709 case "." | |
710 pt = "pt 0"; | |
711 case "x" | |
712 pt = "pt 2"; | |
713 case {"square", "s"} | |
714 pt = "pt 5"; | |
715 case {"diamond", "d"} | |
716 pt = "pt 13"; | |
717 case "^" | |
718 pt = "pt 9"; | |
719 case "v" | |
720 pt = "pt 11"; | |
721 case ">" | |
722 pt = "pt 8"; | |
723 case "<" | |
724 pt = "pt 10"; | |
725 case {"pentagram", "p"} | |
726 pt = "pt 4"; | |
727 case {"hexagram", "h"} | |
728 pt = "pt 12"; | |
729 case "none" | |
730 pt = ""; | |
731 otherwise | |
732 pt = ""; | |
733 endswitch | |
734 endif | |
735 else | |
736 pt = ""; | |
737 endif | |
738 | |
739 style = "lines"; | |
740 if (isempty (lt)) | |
741 if (! isempty (pt)) | |
742 style = "points"; | |
743 endif | |
744 elseif (! isempty (pt)) | |
745 style = "linespoints"; | |
746 endif | |
747 | |
748 if (isfield (obj, "markersize")) | |
749 if (length (mdat) == nc) | |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7593
diff
changeset
|
750 m = mdat(i); |
7189 | 751 else |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7593
diff
changeset
|
752 m = mdat; |
7189 | 753 endif |
754 if (! strcmpi (style, "lines")) | |
755 if (have_newer_gnuplot) | |
756 ps = sprintf("pointsize %f", m); | |
757 else | |
758 ps = sprintf("ps %f", m); | |
759 endif | |
760 else | |
761 ps = ""; | |
762 endif | |
763 else | |
764 ps = ""; | |
765 endif | |
766 | |
7020 | 767 if (have_newer_gnuplot) |
7269 | 768 if (mono) |
769 colorspec = ""; | |
770 else | |
771 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
772 round (255*color)); | |
773 endif | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
774 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
|
775 style, lw, pt, lt, ps, |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
776 colorspec); |
7020 | 777 else |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
778 typ = get_old_gnuplot_color (color); |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7420
diff
changeset
|
779 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
|
780 style, lw, pt, ps, typ); |
7020 | 781 endif |
6790 | 782 |
7316 | 783 if (nd == 3) |
7170 | 784 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) |
785 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... | |
786 [zcol; zcol(1)]]'; | |
787 else | |
788 data{data_idx} = [xcol, ycol, zcol]'; | |
789 endif | |
790 usingclause{data_idx} = "using ($1):($2):($3)"; | |
7020 | 791 else |
7170 | 792 if (! isnan (xcol) && ! isnan (ycol)) |
793 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; | |
794 else | |
795 data{data_idx} = [xcol, ycol]'; | |
796 endif | |
797 usingclause{data_idx} = "using ($1):($2)"; | |
7020 | 798 endif |
6885 | 799 endif |
7020 | 800 endfor |
6790 | 801 |
6405 | 802 case "surface" |
7271 | 803 view_map = true; |
7110 | 804 if (! (strncmp (obj.edgecolor, "none", 4) |
805 && strncmp (obj.facecolor, "none", 4))) | |
7109 | 806 data_idx++; |
807 is_image_data(data_idx) = false; | |
808 parametric(data_idx) = false; | |
7119 | 809 have_cdata(data_idx) = true; |
7170 | 810 [style, typ, with] = do_linestyle_command (obj, data_idx, |
7269 | 811 mono, plot_stream); |
7109 | 812 if (isempty (obj.keylabel)) |
813 titlespec{data_idx} = "title \"\""; | |
814 else | |
7189 | 815 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
816 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); |
7109 | 817 endif |
818 usingclause{data_idx} = ""; | |
819 if (have_newer_gnuplot || isnan (typ)) | |
7318 | 820 withclause{data_idx} = sprintf ("with pm3d linestyle %d", |
821 data_idx); | |
6405 | 822 else |
7318 | 823 withclause{data_idx} = sprintf ("with pm3d linetype %d %s", |
824 typ, with); | |
7109 | 825 endif |
826 | |
827 xdat = obj.xdata; | |
828 ydat = obj.ydata; | |
829 zdat = obj.zdata; | |
830 cdat = obj.cdata; | |
7110 | 831 |
7109 | 832 err = false; |
833 if (! size_equal(zdat, cdat)) | |
6405 | 834 err = true; |
7109 | 835 endif |
836 if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) | |
7110 | 837 if (rows (zdat) == length (ydat) |
838 && columns (zdat) == length (xdat)) | |
7109 | 839 [xdat, ydat] = meshgrid (xdat, ydat); |
840 else | |
841 err = true; | |
842 endif | |
843 elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) | |
7292 | 844 if (! size_equal (xdat, ydat, zdat)) |
7109 | 845 err = true; |
846 endif | |
847 else | |
848 err = true; | |
849 endif | |
850 if (err) | |
851 error ("__go_draw_axes__: invalid grid data"); | |
6405 | 852 endif |
7109 | 853 xlen = columns (zdat); |
854 ylen = rows (zdat); | |
855 if (xlen == columns (xdat) && xlen == columns (ydat) | |
856 && ylen == rows (xdat) && ylen == rows (ydat)) | |
857 len = 4 * xlen; | |
858 zz = zeros (ylen, len); | |
859 k = 1; | |
860 for kk = 1:4:len | |
861 zz(:,kk) = xdat(:,k); | |
862 zz(:,kk+1) = ydat(:,k); | |
863 zz(:,kk+2) = zdat(:,k); | |
864 zz(:,kk+3) = cdat(:,k); | |
865 k++; | |
866 endfor | |
7170 | 867 data{data_idx} = zz.'; |
7109 | 868 endif |
869 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
7582 | 870 ## fputs (plot_stream, "unset parametric;\n"); |
7109 | 871 |
7119 | 872 ## Interpolation does not work for flat surfaces (e.g. pcolor) |
873 ## and color mapping --> currently set empty. | |
874 interp_str = ""; | |
875 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) | |
876 || strncmp (obj.facecolor, "interp", 6)); | |
877 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) | |
878 || strncmp (obj.edgecolor, "interp", 6)); | |
7154 | 879 |
880 facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4) | |
881 || (isnumeric (obj.facecolor) | |
882 && all (obj.facecolor == 1))); | |
7582 | 883 hidden_removal = false; |
7592 | 884 fputs (plot_stream, "set style increment default;\n"); |
7318 | 885 if (flat_interp_edge && facecolor_none_or_white) |
7189 | 886 withclause{data_idx} = "with line palette"; |
7541
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
887 fputs (plot_stream, "unset pm3d\n"); |
7582 | 888 if (all (obj.facecolor == 1)) |
7592 | 889 hidden_removal = true; |
7582 | 890 endif |
7541
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
891 elseif (facecolor_none_or_white) |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
892 edgecol = obj.edgecolor; |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
893 if (have_newer_gnuplot) |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
894 if (mono) |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
895 colorspec = ""; |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
896 else |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
897 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
898 round (255*edgecol)); |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
899 endif |
7582 | 900 if (all (obj.facecolor == 1)) |
901 hidden_removal = true; | |
902 endif | |
903 fputs(plot_stream,"unset pm3d;\n"); | |
7541
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
904 fprintf (plot_stream, |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
905 "set style line %d %s lw %f;\n", |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
906 data_idx, colorspec, obj.linewidth); |
7582 | 907 fputs(plot_stream,"set style increment user;\n"); |
7541
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
908 else |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
909 typ = get_old_gnuplot_color (edgecol); |
7541
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
910 fprintf (plot_stream, |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
911 "set style line %d lt %d lw %f;\n", |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
912 data_idx, typ, obj.linewidth); |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
913 endif |
6acd0a18a3ee
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
7540
diff
changeset
|
914 withclause{data_idx} = sprintf("with line linestyle %d", data_idx); |
7582 | 915 fputs (plot_stream, "unset pm3d\n"); |
7119 | 916 endif |
7109 | 917 |
7189 | 918 if (have_newer_gnuplot) |
919 dord = "depthorder"; | |
920 else | |
921 dord = ""; | |
922 endif | |
7109 | 923 |
7318 | 924 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) |
925 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", | |
7189 | 926 interp_str, dord); |
7318 | 927 elseif (!facecolor_none_or_white) |
7119 | 928 if (strncmp (obj.edgecolor, "none", 4)) |
7318 | 929 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", |
7189 | 930 interp_str, dord); |
7109 | 931 else |
7119 | 932 edgecol = obj.edgecolor; |
933 if (ischar (obj.edgecolor)) | |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
934 edgecol = [0, 0, 0]; |
7119 | 935 endif |
7318 | 936 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", |
7189 | 937 data_idx, interp_str, dord); |
7119 | 938 |
939 if (have_newer_gnuplot) | |
7269 | 940 if (mono) |
941 colorspec = ""; | |
942 else | |
943 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", | |
944 round (255*edgecol)); | |
945 endif | |
7110 | 946 fprintf (plot_stream, |
7269 | 947 "set style line %d %s lw %f;\n", |
948 data_idx, colorspec, obj.linewidth); | |
7119 | 949 else |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
950 typ = get_old_gnuplot_color (edgecol); |
7119 | 951 fprintf (plot_stream, |
952 "set style line %d lt %d lw %f;\n", | |
953 data_idx, typ, obj.linewidth); | |
954 endif | |
7109 | 955 endif |
7119 | 956 endif |
6405 | 957 endif |
958 | |
959 case "text" | |
7189 | 960 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string", |
961 have_newer_gnuplot); | |
7257 | 962 if (strcmp (f, "*")) |
963 fontspec = ""; | |
964 else | |
965 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
966 endif | |
6405 | 967 lpos = obj.position; |
968 halign = obj.horizontalalignment; | |
6724 | 969 angle = obj.rotation; |
6752 | 970 units = obj.units; |
6829 | 971 color = obj.color; |
6758 | 972 if (strcmpi (units, "normalized")) |
6752 | 973 units = "graph"; |
974 else | |
975 units = ""; | |
976 endif | |
977 | |
6829 | 978 if (isnumeric (color)) |
7269 | 979 colorspec = get_text_colorspec (color, mono); |
6829 | 980 endif |
981 | |
6405 | 982 if (nd == 3) |
6724 | 983 fprintf (plot_stream, |
7390 | 984 "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 985 undo_string_escapes (label), units, lpos(1), |
7390 | 986 lpos(2), lpos(3), halign, angle, fontspec, |
987 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 988 else |
7162 | 989 fprintf (plot_stream, |
7390 | 990 "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 991 undo_string_escapes (label), units, |
7390 | 992 lpos(1), lpos(2), halign, angle, fontspec, |
993 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 994 endif |
995 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
996 case "hggroup" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
997 # push group children into the kid list |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
998 kids = [obj.children kids]; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
999 |
6405 | 1000 otherwise |
1001 error ("__go_draw_axes__: unknown object class, %s", | |
1002 obj.type); | |
1003 endswitch | |
1004 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1005 endwhile |
6405 | 1006 |
7692
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1007 ## This is need to prevent warnings for rotations in 3D plots, while |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1008 ## allowing colorbars with contours.. |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1009 if (nd == 2 || data_idx > 1) |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1010 fputs (plot_stream, "set pm3d implicit;\n"); |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1011 else |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1012 fputs (plot_stream, "set pm3d explicit;\n"); |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1013 endif |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1014 |
7175 | 1015 if (isnan(hidden_removal) || hidden_removal) |
7149 | 1016 fputs (plot_stream, "set hidden3d;\n"); |
1017 else | |
1018 fputs (plot_stream, "unset hidden3d;\n"); | |
1019 endif | |
1020 | |
7152 | 1021 have_data = (! (isempty (data) || any (cellfun (@isempty, data)))); |
6405 | 1022 |
7222 | 1023 if (isempty (xlim)) |
1024 return; | |
6405 | 1025 endif |
6758 | 1026 if (strcmpi (axis_obj.xdir, "reverse")) |
6405 | 1027 xdir = "reverse"; |
1028 else | |
1029 xdir = "noreverse"; | |
1030 endif | |
7115 | 1031 fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", |
1032 xaxisloc, xlim, xdir); | |
6405 | 1033 |
7222 | 1034 if (isempty (ylim)) |
1035 return; | |
6405 | 1036 endif |
6758 | 1037 if (strcmpi (axis_obj.ydir, "reverse")) |
6405 | 1038 ydir = "reverse"; |
1039 else | |
1040 ydir = "noreverse"; | |
1041 endif | |
7110 | 1042 fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", |
1043 yaxisloc, ylim, ydir); | |
6405 | 1044 |
7119 | 1045 if (nd == 3) |
7222 | 1046 if (isempty (zlim)) |
1047 return; | |
6405 | 1048 endif |
6758 | 1049 if (strcmpi (axis_obj.zdir, "reverse")) |
6405 | 1050 zdir = "reverse"; |
1051 else | |
1052 zdir = "noreverse"; | |
1053 endif | |
6942 | 1054 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); |
6405 | 1055 endif |
7110 | 1056 |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1057 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
|
1058 cmap_sz = rows(cmap); |
7189 | 1059 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
|
1060 if (cdatadirect) |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1061 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
|
1062 else |
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1063 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
|
1064 endif |
7189 | 1065 endif |
1066 | |
6758 | 1067 if (strcmpi (axis_obj.box, "on")) |
7119 | 1068 if (nd == 3) |
6405 | 1069 fputs (plot_stream, "set border 4095;\n"); |
1070 else | |
1071 fputs (plot_stream, "set border 431;\n"); | |
1072 endif | |
1073 else | |
7119 | 1074 if (nd == 3) |
6405 | 1075 fputs (plot_stream, "set border 895;\n"); |
1076 else | |
7320 | 1077 if (strcmpi (axis_obj.yaxislocation, "right")) |
7873
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1078 fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n", |
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1079 axis_obj.tickdir); |
7320 | 1080 if (strcmpi (axis_obj.xaxislocation, "top")) |
7873
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1081 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", |
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1082 axis_obj.tickdir); |
7320 | 1083 fputs (plot_stream, "set border 12;\n"); |
1084 else | |
7873
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1085 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", |
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1086 axis_obj.tickdir); |
7320 | 1087 fputs (plot_stream, "set border 9;\n"); |
1088 endif | |
1089 else | |
7873
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1090 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", |
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1091 axis_obj.tickdir); |
7320 | 1092 if (strcmpi (axis_obj.xaxislocation, "top")) |
7873
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1093 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", |
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1094 axis_obj.tickdir); |
7320 | 1095 fputs (plot_stream, "set border 6;\n"); |
1096 else | |
7873
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1097 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", |
02b590f46a29
correct fputs to fprintf in __go_draw_axes__.m
Jaroslav Hajek <highegg@gmail.com>
parents:
7865
diff
changeset
|
1098 axis_obj.tickdir); |
7320 | 1099 fputs (plot_stream, "set border 3;\n"); |
1100 endif | |
1101 endif | |
6405 | 1102 endif |
1103 endif | |
1104 | |
7060 | 1105 if (strcmpi (axis_obj.visible, "off")) |
1106 fputs (plot_stream, "unset border; unset tics\n"); | |
7565
1e6443ff960f
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
7564
diff
changeset
|
1107 else |
1e6443ff960f
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
7564
diff
changeset
|
1108 fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth); |
7060 | 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"); | |
7472
2d8315dcd8d2
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
7471
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 | |
7583
1d7c23e288d7
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
7582
diff
changeset
|
1205 if (strcmpi (get (h, "__colorbar__"), "none")) |
7189 | 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 | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1264 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
|
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 |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
1288 typ = get_old_gnuplot_color (color); |
6425 | 1289 endif |
6405 | 1290 endif |
1291 found_style = true; | |
1292 endif | |
1293 | |
1294 if (isfield (obj, "linestyle")) | |
1295 switch (obj.linestyle) | |
1296 case "-" | |
6415 | 1297 lt = "1"; |
6405 | 1298 case "--" |
6415 | 1299 lt = "2"; |
6405 | 1300 case ":" |
6415 | 1301 lt = "3"; |
6405 | 1302 case "-." |
6415 | 1303 lt = "6"; |
6405 | 1304 case "none" |
1305 lt = ""; | |
1306 otherwise | |
1307 lt = ""; | |
1308 endswitch | |
6843 | 1309 |
1310 ## FIXME -- linetype is currently broken, since it disables the | |
1311 ## gnuplot default dashed and solid linestyles with the only | |
1312 ## benefit of being able to specify '--' and get a single sized | |
1313 ## dashed line of identical dash pattern for all called this way. | |
1314 ## All dash patterns are a subset of "with lines" and none of the | |
1315 ## lt specifications will correctly propagate into the x11 terminal | |
1316 ## or the print command. Therefore, it is currently disabled in | |
1317 ## order to allow print (..., "-dashed") etc. to work correctly. | |
1318 | |
1319 ## if (! isempty (lt)) | |
1320 ## fprintf (plot_stream, " linetype %s", lt); | |
1321 ## found_style = true; | |
1322 ## endif | |
1323 | |
6405 | 1324 else |
1325 lt = ""; | |
1326 endif | |
1327 | |
1328 if (isfield (obj, "linewidth")) | |
6465 | 1329 if (have_newer_gnuplot) |
1330 fprintf (plot_stream, " linewidth %f", obj.linewidth); | |
1331 else | |
1332 with = sprintf ("%s lw %f", with, obj.linewidth); | |
1333 endif | |
6405 | 1334 found_style = true; |
1335 endif | |
1336 | |
1337 if (isfield (obj, "marker")) | |
1338 switch (obj.marker) | |
1339 case "+" | |
1340 pt = "1"; | |
1341 case "o" | |
6413 | 1342 pt = "6"; |
6405 | 1343 case "*" |
1344 pt = "3"; | |
1345 case "." | |
7078 | 1346 pt = "0"; |
6405 | 1347 case "x" |
1348 pt = "2"; | |
1349 case {"square", "s"} | |
1350 pt = "5"; | |
1351 case {"diamond", "d"} | |
1352 pt = "13"; | |
1353 case "^" | |
1354 pt = "9"; | |
1355 case "v" | |
1356 pt = "11"; | |
1357 case ">" | |
1358 pt = "8"; | |
1359 case "<" | |
1360 pt = "10"; | |
1361 case {"pentagram", "p"} | |
1362 pt = "4"; | |
1363 case {"hexagram", "h"} | |
6413 | 1364 pt = "12"; |
6405 | 1365 case "none" |
1366 pt = ""; | |
1367 otherwise | |
1368 pt = ""; | |
1369 endswitch | |
1370 if (! isempty (pt)) | |
6465 | 1371 if (have_newer_gnuplot) |
1372 fprintf (plot_stream, " pointtype %s", pt); | |
1373 else | |
1374 with = sprintf ("%s pt %s", with, pt); | |
1375 endif | |
6405 | 1376 found_style = true; |
1377 endif | |
1378 else | |
1379 pt = ""; | |
1380 endif | |
1381 | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1382 if (isempty (errbars)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1383 style = "lines"; |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1384 if (isempty (lt)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1385 if (! isempty (pt)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1386 style = "points"; |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1387 endif |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1388 elseif (! isempty (pt)) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1389 style = "linespoints"; |
6405 | 1390 endif |
1391 | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1392 if (isfield (obj, "markersize")) |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1393 if (have_newer_gnuplot) |
7564
90536e155fde
adjust markersize by a factor of 1/6
John W. Eaton <jwe@octave.org>
parents:
7542
diff
changeset
|
1394 fprintf (plot_stream, " pointsize %f", obj.markersize / 6); |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1395 else |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1396 if (! strcmpi (style, "lines")) |
7564
90536e155fde
adjust markersize by a factor of 1/6
John W. Eaton <jwe@octave.org>
parents:
7542
diff
changeset
|
1397 with = sprintf ("%s ps %f", with, obj.markersize / 6); |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1398 endif |
6465 | 1399 endif |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1400 found_style = true; |
6465 | 1401 endif |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1402 else |
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
1403 style = errbars; |
6465 | 1404 found_style = true; |
1405 endif | |
1406 | |
6405 | 1407 if (have_newer_gnuplot && ! found_style) |
1408 fputs (plot_stream, " default"); | |
1409 endif | |
1410 | |
1411 fputs (plot_stream, ";\n"); | |
1412 | |
1413 endfunction | |
6510 | 1414 |
7316 | 1415 function nd = __calc_dimensions__ (obj) |
1416 kids = obj.children; | |
1417 nd = 2; | |
1418 for i = 1:length (kids) | |
1419 obj = get (kids(i)); | |
1420 switch (obj.type) | |
1421 case {"image", "text"} | |
1422 ## ignore as they | |
1423 case {"line", "patch"} | |
1424 if (! isempty (obj.zdata)) | |
1425 nd = 3; | |
1426 endif | |
1427 case "surface" | |
1428 nd = 3; | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1429 case "hggroup" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1430 obj_nd = __calc_dimensions__ (obj); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1431 if (obj_nd == 3) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1432 nd = 3; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1433 endif |
7316 | 1434 endswitch |
1435 endfor | |
1436 endfunction | |
1437 | |
7119 | 1438 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) |
6510 | 1439 |
1440 ## DATA is already transposed. | |
1441 | |
1442 ## FIXME -- this may need to be converted to C++ for speed. | |
1443 | |
6605 | 1444 ## Convert NA elements to normal NaN values because fprintf writes |
1445 ## "NA" and that confuses gnuplot. | |
1446 idx = find (isna (data)); | |
1447 if (any (idx)) | |
1448 data(idx) = NaN; | |
1449 endif | |
1450 | |
6510 | 1451 if (nd == 2) |
1452 nan_elts = find (sum (isnan (data))); | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1453 fmt = cstrcat (repmat ("%.15g ", 1, rows (data)), "\n"); |
6510 | 1454 if (isempty (nan_elts)) |
1455 fprintf (plot_stream, fmt, data); | |
1456 else | |
1457 n = columns (data); | |
1458 have_nans = true; | |
1459 num_nan_elts = numel (nan_elts); | |
1460 k = 1; | |
1461 for i = 1:n | |
1462 if (have_nans && i == nan_elts(k)) | |
1463 fputs (plot_stream, "\n"); | |
1464 have_nans = ++k <= num_nan_elts; | |
1465 else | |
1466 fprintf (plot_stream, fmt, data(:,i)); | |
1467 endif | |
1468 endfor | |
1469 endif | |
7109 | 1470 elseif (nd == 3) |
6510 | 1471 ## FIXME -- handle NaNs here too? |
1472 if (parametric) | |
6914 | 1473 fprintf (plot_stream, "%.15g %.15g %.15g\n", data); |
6510 | 1474 else |
7170 | 1475 nr = rows (data); |
7119 | 1476 if (cdata) |
7170 | 1477 for j = 1:4:nr |
1478 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(j:j+3,:)); | |
7119 | 1479 fputs (plot_stream, "\n"); |
1480 endfor | |
1481 else | |
7170 | 1482 for j = 1:3:nr |
1483 fprintf (plot_stream, "%.15g %.15g %.15g\n", data(j:j+2,:)); | |
7119 | 1484 fputs (plot_stream, "\n"); |
1485 endfor | |
1486 endif | |
7109 | 1487 endif |
6510 | 1488 endif |
1489 fputs (plot_stream, "e\n"); | |
1490 | |
1491 endfunction | |
6745 | 1492 |
7269 | 1493 function do_tics (obj, plot_stream, ymirror, mono) |
6809 | 1494 if (strcmpi (obj.xaxislocation, "top")) |
1495 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1496 obj.xcolor, "x2", plot_stream, true, mono, "border", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1497 obj.tickdir); |
6809 | 1498 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1499 obj.xcolor, "x", plot_stream, true, mono, "border", ""); |
7321 | 1500 elseif (strcmpi (obj.xaxislocation, "zero")) |
1501 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1502 obj.xcolor, "x", plot_stream, true, mono, "axis", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1503 obj.tickdir); |
7321 | 1504 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1505 obj.xcolor, "x2", plot_stream, true, mono, "axis", ""); |
6809 | 1506 else |
1507 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1508 obj.xcolor, "x", plot_stream, true, mono, "border", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1509 obj.tickdir); |
6809 | 1510 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1511 obj.xcolor, "x2", plot_stream, true, mono, "border", ""); |
6809 | 1512 endif |
1513 if (strcmpi (obj.yaxislocation, "right")) | |
1514 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1515 obj.ycolor, "y2", plot_stream, ymirror, mono, "border", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1516 obj.tickdir); |
6809 | 1517 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1518 obj.ycolor, "y", plot_stream, ymirror, mono, "border", ""); |
7321 | 1519 elseif (strcmpi (obj.xaxislocation, "zero")) |
1520 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1521 obj.ycolor, "y", plot_stream, ymirror, mono, "axis", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1522 obj.tickdir); |
7321 | 1523 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1524 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis", ""); |
6809 | 1525 else |
1526 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1527 obj.ycolor, "y", plot_stream, ymirror, mono, "border", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1528 obj.tickdir); |
6809 | 1529 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1530 obj.ycolor, "y2", plot_stream, ymirror, mono, "border", ""); |
6809 | 1531 endif |
6745 | 1532 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1533 obj.zcolor, "z", plot_stream, true, mono, "border", |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1534 obj.tickdir); |
6745 | 1535 endfunction |
1536 | |
7269 | 1537 function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1538 plot_stream, mirror, mono, axispos, tickdir) |
7269 | 1539 colorspec = get_text_colorspec (color, mono); |
6758 | 1540 if (strcmpi (ticmode, "manual")) |
6745 | 1541 if (isempty (tics)) |
1542 fprintf (plot_stream, "unset %stics;\n", ax); | |
6758 | 1543 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) |
6751 | 1544 if (ischar (labels)) |
1545 labels = cellstr (labels); | |
1546 endif | |
6745 | 1547 if (iscellstr (labels)) |
6751 | 1548 k = 1; |
1549 ntics = numel (tics); | |
1550 nlabels = numel (labels); | |
6745 | 1551 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
7206 | 1552 if (mirror) |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1553 fprintf (plot_stream, "set %stics %s %s (", ax, tickdir, axispos); |
7206 | 1554 else |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1555 fprintf (plot_stream, "set %stics %s %s nomirror (", ax, |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1556 tickdir, axispos); |
7206 | 1557 endif |
7228 | 1558 labels = regexprep(labels, "%", "%%"); |
6745 | 1559 for i = 1:ntics |
7582 | 1560 fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i)); |
6745 | 1561 if (i < ntics) |
1562 fputs (plot_stream, ", "); | |
1563 endif | |
1564 if (k > nlabels) | |
1565 k = 1; | |
1566 endif | |
1567 endfor | |
7220 | 1568 fprintf (plot_stream, ") %s;\n", colorspec); |
6745 | 1569 else |
1570 error ("unsupported type of ticklabel"); | |
1571 endif | |
1572 else | |
6920 | 1573 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1574 if (mirror) |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1575 fprintf (plot_stream, "set %stics %s %s (", ax, tickdir, axispos ); |
7206 | 1576 else |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1577 fprintf (plot_stream, "set %stics %s %s nomirror (", ax, tickdir, |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1578 axispos); |
7206 | 1579 endif |
6920 | 1580 fprintf (plot_stream, " %g,", tics(1:end-1)); |
1581 fprintf (plot_stream, " %g);\n", tics(end)); | |
6745 | 1582 endif |
1583 else | |
6920 | 1584 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1585 if (mirror) |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1586 fprintf (plot_stream, "set %stics %s %s %s;\n", ax, axispos, tickdir, |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1587 colorspec); |
7206 | 1588 else |
7676
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1589 fprintf (plot_stream, "set %stics %s %s nomirror %s;\n", ax, |
6c0f7bcf5b55
Fix spurious tics for plotyy with gnuplot backend
David Bateman <dbateman@free.fr>
parents:
7608
diff
changeset
|
1590 tickdir, axispos, colorspec); |
7206 | 1591 endif |
7194 | 1592 endif |
1593 endfunction | |
1594 | |
7269 | 1595 function colorspec = get_text_colorspec (color, mono) |
7194 | 1596 persistent have_newer_gnuplot ... |
1597 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
1598 | |
1599 if (have_newer_gnuplot) | |
7269 | 1600 if (mono) |
1601 colorspec = ""; | |
1602 else | |
1603 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"", | |
1604 round (255*color)); | |
1605 endif | |
7194 | 1606 else |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
1607 typ = get_old_gnuplot_color (color); |
7194 | 1608 colorspec = sprintf ("textcolor lt %d", typ); |
6745 | 1609 endif |
1610 endfunction | |
7163 | 1611 |
7189 | 1612 function [f, s, fnt, it, bld] = get_fontname_and_size (t) |
7163 | 1613 if (isempty (t.fontname)) |
7372 | 1614 fnt = "Helvetica"; |
7163 | 1615 else |
7372 | 1616 fnt = t.fontname; |
7168 | 1617 endif |
7189 | 1618 f = fnt; |
1619 it = false; | |
1620 bld = false; | |
7372 | 1621 if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold")) |
7168 | 1622 if (! isempty(t.fontangle) |
7372 | 1623 && (strcmpi (t.fontangle, "italic") |
1624 || strcmpi (t.fontangle, "oblique"))) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1625 f = cstrcat (f, "-bolditalic"); |
7189 | 1626 it = true; |
1627 bld = true; | |
7168 | 1628 else |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1629 f = cstrcat (f, "-bold"); |
7189 | 1630 bld = true; |
7168 | 1631 endif |
1632 elseif (! isempty(t.fontangle) | |
7372 | 1633 && (strcmpi (t.fontangle, "italic") |
1634 || strcmpi (t.fontangle, "oblique"))) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1635 f = cstrcat (f, "-italic"); |
7189 | 1636 it = true; |
7163 | 1637 endif |
1638 if (isempty (t.fontsize)) | |
1639 s = 10; | |
1640 else | |
1641 s = t.fontsize; | |
1642 endif | |
1643 endfunction | |
7189 | 1644 |
1645 function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld, | |
1646 have_newer_gnuplot) | |
1647 persistent warned_latex = false; | |
1648 | |
1649 if (strcmp (fld, "string")) | |
1650 [f, s, fnt, it, bld] = get_fontname_and_size (obj); | |
1651 else | |
7372 | 1652 f = "Helvetica"; |
7189 | 1653 s = 10; |
1654 fnt = f; | |
1655 it = false; | |
1656 bld = false; | |
1657 endif | |
1658 | |
1659 str = getfield (obj, fld); | |
1660 if (enhanced) | |
1661 if (strcmp (obj.interpreter, "tex")) | |
1662 str = __tex2enhanced__ (str, fnt, it, bld); | |
1663 if (! have_newer_gnuplot) | |
1664 ## Set the font to work around gnuplot 4.0 X11 enhanced terminal bug | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1665 str = cstrcat ('{/', f, ' ', str, ' }'); |
7189 | 1666 endif |
1667 elseif (strcmp (obj.interpreter, "latex")) | |
1668 if (! warned_latex) | |
1669 warning ("latex text objects not supported"); | |
1670 warned_latex = true; | |
1671 endif | |
1672 endif | |
1673 endif | |
1674 endfunction | |
1675 | |
1676 function str = __tex2enhanced__ (str, fnt, it, bld) | |
1677 persistent sym = __setup_sym_table__ (); | |
1678 persistent flds = fieldnames (sym); | |
1679 | |
1680 [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches'); | |
1681 | |
1682 for i = length (s) : -1 : 1 | |
1683 ## special case for "\0" and replace with "{/Symbol \306}' | |
1684 if (strncmp (m{i}, '\0', 2)) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1685 str = cstrcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); |
7189 | 1686 else |
1687 f = m{i}(2:end); | |
1688 if (isfield (sym, f)) | |
1689 g = getfield(sym, f); | |
1690 ## FIXME The symbol font doesn't seem to support bold or italic | |
1691 ##if (bld) | |
1692 ## if (it) | |
1693 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1694 ## else | |
1695 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1696 ## endif | |
1697 ##elseif (it) | |
1698 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1699 ##endif | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1700 str = cstrcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); |
7189 | 1701 elseif (strncmp (f, "rm", 2)) |
1702 bld = false; | |
1703 it = false; | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1704 str = cstrcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); |
7189 | 1705 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) |
1706 it = true; | |
1707 if (bld) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1708 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', |
7189 | 1709 str(s(i) + 3:end)); |
1710 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1711 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ', |
7189 | 1712 str(s(i) + 3:end)); |
1713 endif | |
1714 elseif (strncmp (f, "bf", 2)) | |
1715 bld = true; | |
1716 if (it) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1717 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', |
7189 | 1718 str(2(i) + 3:end)); |
1719 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1720 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ', |
7189 | 1721 str(s(i) + 3:end)); |
1722 endif | |
1723 elseif (strcmp (f, "color")) | |
1724 ## FIXME Ignore \color but remove trailing {} block as well | |
1725 d = strfind(str(e(i) + 1:end),'}'); | |
1726 if (isempty (d)) | |
1727 warning ('syntax error in \color argument'); | |
1728 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1729 str = cstrcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); |
7189 | 1730 endif |
1731 elseif(strcmp (f, "fontname")) | |
1732 b1 = strfind(str(e(i) + 1:end),'{'); | |
1733 b2 = strfind(str(e(i) + 1:end),'}'); | |
1734 if (isempty(b1) || isempty(b2)) | |
1735 warning ('syntax error in \fontname argument'); | |
1736 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1737 str = cstrcat (str(1:s(i) - 1), '/', |
7189 | 1738 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', |
1739 str(e(i) + b2(1) + 1:end)); | |
1740 endif | |
1741 elseif(strcmp (f, "fontsize")) | |
1742 b1 = strfind(str(e(i) + 1:end),'{'); | |
1743 b2 = strfind(str(e(i) + 1:end),'}'); | |
1744 if (isempty(b1) || isempty(b2)) | |
1745 warning ('syntax error in \fontname argument'); | |
1746 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1747 str = cstrcat (str(1:s(i) - 1), '/=', |
7189 | 1748 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', |
1749 str(e(i) + b2(1) + 1:end)); | |
1750 endif | |
1751 else | |
1752 ## Last desperate attempt to treat the symbol. Look for things | |
1753 ## like \pix, that should be translated to the symbol Pi and x | |
1754 for j = 1 : length (flds) | |
1755 if (strncmp (flds{j}, f, length (flds{j}))) | |
1756 g = getfield(sym, flds{j}); | |
1757 ## FIXME The symbol font doesn't seem to support bold or italic | |
1758 ##if (bld) | |
1759 ## if (it) | |
1760 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1761 ## else | |
1762 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1763 ## endif | |
1764 ##elseif (it) | |
1765 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1766 ##endif | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1767 str = cstrcat (str(1:s(i) - 1), g, |
7189 | 1768 str(s(i) + length (flds{j}) + 1:end)); |
1769 break; | |
1770 endif | |
1771 endfor | |
1772 endif | |
1773 endif | |
1774 endfor | |
1775 | |
1776 ## Prepend @ to things things like _0^x or _{-100}^{100} for alignment | |
1777 ## But need to put the shorter of the two arguments first. Carful of | |
1778 ## nested {} and unprinted characters when defining shortest.. Don't | |
1779 ## have to worry about things like ^\theta as they are already converted to | |
1780 ## ^{/Symbol q}. | |
1781 | |
1782 ## FIXME.. This is a mess... Is it worth it just for a "@" character? | |
1783 | |
1784 [s, m] = regexp(str,'[_\^]','start','matches'); | |
1785 i = 1; | |
1786 p = 0; | |
1787 while (i < length (s)) | |
1788 if (i < length(s)) | |
1789 if (str(s(i) + p + 1) == "{") | |
1790 s1 = strfind(str(s(i) + p + 2:end),'{'); | |
1791 si = 1; | |
1792 l1 = strfind(str(s(i) + p + 1:end),'}'); | |
1793 li = 1; | |
1794 while (li <= length (l1) && si <= length (s1)) | |
1795 if (l1(li) < s1(si)) | |
1796 if (li == si) | |
1797 break; | |
1798 endif | |
1799 li++; | |
1800 else | |
1801 si++; | |
1802 endif | |
1803 endwhile | |
1804 l1 = l1 (min (length(l1), si)); | |
1805 if (s(i) + l1 + 1 == s(i+1)) | |
1806 if (str(s(i + 1) + p + 1) == "{") | |
1807 s2 = strfind(str(s(i + 1) + p + 2:end),'{'); | |
1808 si = 1; | |
1809 l2 = strfind(str(s(i + 1) + p + 1:end),'}'); | |
1810 li = 1; | |
1811 while (li <= length (l2) && si <= length (s2)) | |
1812 if (l2(li) < s2(si)) | |
1813 if (li == si) | |
1814 break; | |
1815 endif | |
1816 li++; | |
1817 else | |
1818 si++; | |
1819 endif | |
1820 endwhile | |
1821 l2 = l2 (min (length(l2), si)); | |
1822 if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= | |
1823 length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) | |
1824 ## shortest already first! | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1825 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); |
7189 | 1826 else |
1827 ## Have to swap sub/super-script to get shortest first | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1828 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), |
7189 | 1829 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); |
1830 endif | |
1831 else | |
1832 ## Have to swap sub/super-script to get shortest first | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1833 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), |
7189 | 1834 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); |
1835 endif | |
1836 i += 2; | |
1837 p ++; | |
1838 else | |
1839 i++; | |
1840 endif | |
1841 else | |
1842 if (s(i+1) == s(i) + 2) | |
1843 ## shortest already first! | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
1844 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); |
7189 | 1845 p ++; |
1846 i += 2; | |
1847 else | |
1848 i ++; | |
1849 endif | |
1850 endif | |
1851 else | |
1852 i ++; | |
1853 endif | |
1854 endwhile | |
1855 | |
1856 endfunction | |
1857 | |
1858 function l = length_string (s) | |
1859 l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}')); | |
1860 m = regexp (s, '/([\w\-]+|[\w\-]+=\d+)', 'matches'); | |
1861 if (!isempty (m)) | |
1862 l = l - sum (cellfun (@length, m)); | |
1863 endif | |
1864 endfunction | |
1865 | |
1866 function sym = __setup_sym_table__ () | |
1867 ## Setup the translation table for TeX to gnuplot enhanced mode. | |
1868 sym.forall = '{/Symbol \042}'; | |
1869 sym.exists = '{/Symbol \044}'; | |
1870 sym.ni = '{/Symbol \047}'; | |
1871 sym.cong = '{/Symbol \100}'; | |
1872 sym.Delta = '{/Symbol D}'; | |
1873 sym.Phi = '{/Symbol F}'; | |
7608
49810341db91
Correct typos in __go_draw_axes__.m and update Manual
godfrey@qss.Stanford.EDU
parents:
7603
diff
changeset
|
1874 sym.Gamma = '{/Symbol G}'; |
7190 | 1875 sym.vartheta = '{/Symbol J}'; |
7189 | 1876 sym.Lambda = '{/Symbol L}'; |
1877 sym.Pi = '{/Symbol P}'; | |
1878 sym.Theta = '{/Symbol Q}'; | |
1879 sym.Sigma = '{/Symbol S}'; | |
1880 sym.varsigma = '{/Symbol V}'; | |
7420 | 1881 sym.Omega = '{/Symbol W}'; |
7189 | 1882 sym.Xi = '{/Symbol X}'; |
1883 sym.Psi = '{/Symbol Y}'; | |
1884 sym.perp = '{/Symbol \136}'; | |
1885 sym.alpha = '{/Symbol a}'; | |
1886 sym.beta = '{/Symbol b}'; | |
1887 sym.chi = '{/Symbol c}'; | |
1888 sym.delta = '{/Symbol d}'; | |
1889 sym.epsilon = '{/Symbol e}'; | |
1890 sym.phi = '{/Symbol f}'; | |
7608
49810341db91
Correct typos in __go_draw_axes__.m and update Manual
godfrey@qss.Stanford.EDU
parents:
7603
diff
changeset
|
1891 sym.gamma = '{/Symbol g}'; |
7189 | 1892 sym.eta = '{/Symbol h}'; |
1893 sym.iota = '{/Symbol i}'; | |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1894 sym.varphi = '{/Symbol j}'; |
7189 | 1895 sym.kappa = '{/Symbol k}'; |
1896 sym.lambda = '{/Symbol l}'; | |
1897 sym.mu = '{/Symbol m}'; | |
1898 sym.nu = '{/Symbol n}'; | |
1899 sym.o = '{/Symbol o}'; | |
1900 sym.pi = '{/Symbol p}'; | |
1901 sym.theta = '{/Symbol q}'; | |
1902 sym.rho = '{/Symbol r}'; | |
1903 sym.sigma = '{/Symbol s}'; | |
1904 sym.tau = '{/Symbol t}'; | |
1905 sym.upsilon = '{/Symbol u}'; | |
1906 sym.varpi = '{/Symbol v}'; | |
1907 sym.omega = '{/Symbol w}'; | |
1908 sym.xi = '{/Symbol x}'; | |
1909 sym.psi = '{/Symbol y}'; | |
1910 sym.zeta = '{/Symbol z}'; | |
1911 sym.sim = '{/Symbol \176}'; | |
1912 sym.Upsilon = '{/Symbol \241}'; | |
1913 sym.prime = '{/Symbol \242}'; | |
1914 sym.leq = '{/Symbol \243}'; | |
1915 sym.infty = '{/Symbol \245}'; | |
1916 sym.clubsuit = '{/Symbol \247}'; | |
1917 sym.diamondsuit = '{/Symbol \250}'; | |
1918 sym.heartsuit = '{/Symbol \251}'; | |
1919 sym.spadesuit = '{/Symbol \252}'; | |
1920 sym.leftrightarrow = '{/Symbol \253}'; | |
1921 sym.leftarrow = '{/Symbol \254}'; | |
1922 sym.uparrow = '{/Symbol \255}'; | |
1923 sym.rightarrow = '{/Symbol \256}'; | |
1924 sym.downarrow = '{/Symbol \257}'; | |
1925 sym.circ = '{/Symbol \260}'; | |
1926 sym.pm = '{/Symbol \261}'; | |
1927 sym.geq = '{/Symbol \263}'; | |
1928 sym.times = '{/Symbol \264}'; | |
1929 sym.propto = '{/Symbol \265}'; | |
1930 sym.partial = '{/Symbol \266}'; | |
1931 sym.bullet = '{/Symbol \267}'; | |
1932 sym.div = '{/Symbol \270}'; | |
1933 sym.neq = '{/Symbol \271}'; | |
1934 sym.equiv = '{/Symbol \272}'; | |
1935 sym.approx = '{/Symbol \273}'; | |
1936 sym.ldots = '{/Symbol \274}'; | |
1937 sym.mid = '{/Symbol \275}'; | |
1938 sym.aleph = '{/Symbol \300}'; | |
1939 sym.Im = '{/Symbol \301}'; | |
1940 sym.Re = '{/Symbol \302}'; | |
1941 sym.wp = '{/Symbol \303}'; | |
1942 sym.otimes = '{/Symbol \304}'; | |
1943 sym.oplus = '{/Symbol \305}'; | |
1944 sym.oslash = '{/Symbol \306}'; | |
1945 sym.cap = '{/Symbol \307}'; | |
1946 sym.cup = '{/Symbol \310}'; | |
1947 sym.supset = '{/Symbol \311}'; | |
1948 sym.supseteq = '{/Symbol \312}'; | |
1949 sym.subset = '{/Symbol \314}'; | |
1950 sym.subseteq = '{/Symbol \315}'; | |
1951 sym.in = '{/Symbol \316}'; | |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1952 sym.notin = '{/Symbol \317}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1953 sym.angle = '{/Symbol \320}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1954 sym.bigtriangledown = '{/Symbol \321}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1955 sym.langle = '{/Symbol \341}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1956 sym.rangle = '{/Symbol \361}'; |
7189 | 1957 sym.nabla = '{/Symbol \321}'; |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1958 sym.prod = '{/Symbol \325}'; |
7189 | 1959 sym.surd = '{/Symbol \326}'; |
1960 sym.cdot = '{/Symbol \327}'; | |
1961 sym.neg = '{/Symbol \330}'; | |
1962 sym.wedge = '{/Symbol \331}'; | |
1963 sym.vee = '{/Symbol \332}'; | |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1964 sym.Leftrightarrow = '{/Symbol \333}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1965 sym.Leftarrow = '{/Symbol \334}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1966 sym.Uparrow = '{/Symbol \335}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1967 sym.Rightarrow = '{/Symbol \336}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1968 sym.Downarrow = '{/Symbol \337}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1969 sym.diamond = '{/Symbol \340}'; |
7189 | 1970 sym.copyright = '{/Symbol \343}'; |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1971 sym.lfloor = '{/Symbol \353}'; |
7189 | 1972 sym.lceil = '{/Symbol \351}'; |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
1973 sym.rfloor = '{/Symbol \373}'; |
7189 | 1974 sym.rceil = '{/Symbol \371}'; |
1975 sym.int = '{/Symbol \362}'; | |
1976 endfunction | |
1977 | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1978 function [pos, orient, sz, origin, mirr] = gnuplot_position_colorbox (pos, cbox, obj) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1979 ## This is an emprically derived function that attempts to find a good |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1980 ## size for the colorbox even for subplots and strange aspect ratios. |
7189 | 1981 |
1982 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
1983 scl = pos([2,4]); | |
1984 else | |
1985 scl = pos([1,3]); | |
1986 endif | |
1987 | |
1988 if (length(cbox) > 7 && strncmp (cbox(end-6:end), "outside", 7)) | |
1989 scl(2) -= 0.2 * scl(2); | |
1990 if (strncmp (cbox, "west", 4) || strncmp (cbox, "south", 5)) | |
1991 scl(1) += 0.2 * scl(2); | |
1992 endif | |
1993 endif | |
1994 | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1995 if (strcmpi (obj.dataaspectratiomode, "manual")) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1996 sz = min(pos(3:4))([1,1]); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1997 r = obj.dataaspectratio; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1998 if (pos(3) > pos(4)) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
1999 switch (cbox) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2000 case {"north", "northoutside"} |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2001 off = 4 / 3 * [(pos(3) - pos(4)) ./ (r(2)/r(1)), pos(4) / pos(3) / 2]; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2002 sz = 2 * sz / 3; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2003 case {"south", "southoutside"} |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2004 off = 4 / 3 * [(pos(3) - pos(4)) ./ (r(2)/r(1)), 0]; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2005 sz = 2 * sz / 3; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2006 otherwise |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2007 off = [(pos(3) - pos(4)) ./ (r(2)/r(1)), 0]; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2008 endswitch |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2009 else |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2010 switch (cbox) |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2011 case {"north", "northoutside"} |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2012 off = 1.5 * [0, (pos(4) - pos(3)) ./ (r(1) / r(2))]; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2013 case {"south", "southoutside"} |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2014 off = 0.5 * [0, (pos(4) - pos(3)) ./ (r(1) / r(2))]; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2015 otherwise |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2016 off = [0, (pos(4) - pos(3)) ./ (r(1) / r(2))]; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2017 endswitch |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2018 endif |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2019 off = off / 2; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2020 else |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2021 sz = pos(3:4); |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2022 off = 0; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2023 endif |
7189 | 2024 switch (cbox) |
2025 case "northoutside" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2026 sz = sz - 0.08; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2027 origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2) + off; |
7189 | 2028 mirr = true; |
2029 orient = "horizontal"; | |
2030 case "north" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2031 sz = sz - 0.16; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2032 origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2) + off; |
7189 | 2033 mirr = false; |
2034 orient = "horizontal"; | |
2035 case "southoutside" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2036 sz = sz - 0.08; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2037 origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2) + off; |
7189 | 2038 mirr = false; |
2039 orient = "horizontal"; | |
2040 case "south" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2041 sz = sz - 0.16; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2042 origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2) + off; |
7189 | 2043 mirr = true; |
2044 orient = "horizontal"; | |
2045 case "eastoutside" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2046 sz = sz - 0.08; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2047 origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2) + off; |
7189 | 2048 mirr = false; |
2049 orient = "vertical"; | |
2050 case "east" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2051 sz = sz - 0.16; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2052 origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2) + off; |
7189 | 2053 mirr = true; |
2054 orient = "vertical"; | |
2055 case "westoutside" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2056 sz = sz - 0.08; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2057 origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2) + off; |
7189 | 2058 mirr = true; |
2059 orient = "vertical"; | |
2060 case "west" | |
7726
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2061 sz = sz - 0.16; |
1b954fdaf4ff
Try to get the colorbar position right for manual aspect ratios as well
David Bateman <dbateman@free.fr>
parents:
7692
diff
changeset
|
2062 origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2) + off; |
7189 | 2063 mirr = false; |
2064 orient = "vertical"; | |
2065 endswitch | |
2066 | |
2067 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
2068 sz = sz .* [1, 0.07]; | |
2069 pos([2,4]) = scl; | |
2070 else | |
2071 sz = sz .* [0.07, 1]; | |
2072 pos([1,3]) = scl; | |
2073 endif | |
2074 | |
2075 endfunction | |
7390 | 2076 |
2077 function retval = __do_enhanced_option__ (enhanced, obj) | |
2078 retval = ""; | |
2079 if (enhanced) | |
2080 if (strcmpi (obj.interpreter, "none")) | |
2081 retval = "noenhanced"; | |
2082 else | |
2083 retval = "enhanced"; | |
2084 endif | |
2085 endif | |
2086 endfunction | |
7542
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2087 |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2088 function typ = get_old_gnuplot_color (color) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2089 if (isequal (color, [0, 0, 0])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2090 typ = -1; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2091 elseif (isequal (color, [1, 0, 0])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2092 typ = 1; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2093 elseif (isequal (color, [0, 1, 0])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2094 typ = 2; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2095 elseif (isequal (color, [0, 0, 1])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2096 typ = 3; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2097 elseif (isequal (color, [1, 0, 1])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2098 typ = 4; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2099 elseif (isequal (color, [0, 1, 1])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2100 typ = 5; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2101 elseif (isequal (color, [1, 1, 1])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2102 typ = -1; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2103 elseif (isequal (color, [1, 1, 0])) |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2104 typ = 7; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2105 else |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2106 typ = -1; |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2107 endif |
b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
7541
diff
changeset
|
2108 endfunction |