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