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