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