Mercurial > octave-nkf
annotate scripts/plot/__go_draw_axes__.m @ 11690:42e936258b19 release-3-0-x
_go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 11 Mar 2008 23:38:00 -0400 |
parents | e13219eaf388 |
children | 550113e01d87 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 2005, 2007 John W. Eaton |
6405 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6405 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6405 | 18 |
6895 | 19 ## Undocumented internal function. |
6405 | 20 |
21 ## Author: jwe | |
22 | |
7269 | 23 function __go_draw_axes__ (h, plot_stream, enhanced, mono) |
6405 | 24 |
7269 | 25 if (nargin == 4) |
6405 | 26 |
27 axis_obj = get (h); | |
28 | |
29 parent_figure_obj = get (axis_obj.parent); | |
30 | |
6413 | 31 persistent have_newer_gnuplot ... |
32 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
6405 | 33 |
34 ## Set axis properties here? | |
7191 | 35 pos = [0, 0, 1, 1]; |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
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 | |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
diff
changeset
|
52 if (! strcmpi (get (h, "__colorbar__"), "none")) |
7189 | 53 [pos, cbox_orient, cbox_size, cbox_origin, cbox_mirror] = ... |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
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 | |
11636
2be7477f470a
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
11635
diff
changeset
|
67 fputs (plot_stream, "set pm3d implicit;\n"); |
6778 | 68 fputs (plot_stream, "unset label;\n"); |
69 | |
6405 | 70 if (! isempty (axis_obj.title)) |
71 t = get (axis_obj.title); | |
72 if (isempty (t.string)) | |
73 fputs (plot_stream, "unset title;\n"); | |
74 else | |
7189 | 75 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
76 have_newer_gnuplot); | |
7257 | 77 if (strcmp (f, "*")) |
78 fontspec = ""; | |
79 else | |
80 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
81 endif | |
11615 | 82 fprintf (plot_stream, "set title \"%s\" %s %s;\n", |
83 undo_string_escapes (tt), fontspec, | |
84 __do_enhanced_option__ (enhanced, t)); | |
6405 | 85 endif |
86 endif | |
87 | |
88 if (! isempty (axis_obj.xlabel)) | |
89 t = get (axis_obj.xlabel); | |
6737 | 90 angle = t.rotation; |
7269 | 91 colorspec = get_text_colorspec (axis_obj.xcolor, mono); |
6405 | 92 if (isempty (t.string)) |
7194 | 93 fprintf (plot_stream, "unset xlabel;\n"); |
94 fprintf (plot_stream, "unset x2label;\n"); | |
6405 | 95 else |
7189 | 96 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
97 have_newer_gnuplot); | |
7257 | 98 if (strcmp (f, "*")) |
99 fontspec = ""; | |
100 else | |
101 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
102 endif | |
7194 | 103 if (strcmpi (axis_obj.xaxislocation, "top")) |
11615 | 104 fprintf (plot_stream, "set x2label \"%s\" %s %s %s", |
105 undo_string_escapes (tt), colorspec, fontspec, | |
106 __do_enhanced_option__ (enhanced, t)); | |
7194 | 107 else |
11615 | 108 fprintf (plot_stream, "set xlabel \"%s\" %s %s %s", |
109 undo_string_escapes (tt), colorspec, fontspec, | |
110 __do_enhanced_option__ (enhanced, t)); | |
7194 | 111 endif |
6738 | 112 if (have_newer_gnuplot) |
113 ## Rotation of xlabel not yet support by gnuplot as of 4.2, but | |
114 ## there is no message about it. | |
115 fprintf (plot_stream, " rotate by %f", angle); | |
116 endif | |
117 fputs (plot_stream, ";\n"); | |
7194 | 118 if (strcmpi (axis_obj.xaxislocation, "top")) |
119 fprintf (plot_stream, "unset xlabel;\n"); | |
120 else | |
121 fprintf (plot_stream, "unset x2label;\n"); | |
122 endif | |
6405 | 123 endif |
124 endif | |
125 | |
126 if (! isempty (axis_obj.ylabel)) | |
127 t = get (axis_obj.ylabel); | |
6737 | 128 angle = t.rotation; |
7269 | 129 colorspec = get_text_colorspec (axis_obj.ycolor, mono); |
6405 | 130 if (isempty (t.string)) |
7194 | 131 fprintf (plot_stream, "unset ylabel;\n"); |
132 fprintf (plot_stream, "unset y2label;\n"); | |
6405 | 133 else |
7189 | 134 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
135 have_newer_gnuplot); | |
7257 | 136 if (strcmp (f, "*")) |
137 fontspec = ""; | |
138 else | |
139 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
140 endif | |
7194 | 141 if (strcmpi (axis_obj.yaxislocation, "right")) |
11615 | 142 fprintf (plot_stream, "set y2label \"%s\" %s %s %s", |
143 undo_string_escapes (tt), colorspec, fontspec, | |
144 __do_enhanced_option__ (enhanced, t)); | |
7194 | 145 else |
11615 | 146 fprintf (plot_stream, "set ylabel \"%s\" %s %s %s", |
147 undo_string_escapes (tt), colorspec, fontspec, | |
148 __do_enhanced_option__ (enhanced, t)); | |
7194 | 149 endif |
6738 | 150 if (have_newer_gnuplot) |
6766 | 151 fprintf (plot_stream, " rotate by %f;\n", angle); |
6738 | 152 endif |
153 fputs (plot_stream, ";\n"); | |
7194 | 154 if (strcmpi (axis_obj.yaxislocation, "right")) |
155 fprintf (plot_stream, "unset ylabel;\n"); | |
156 else | |
157 fprintf (plot_stream, "unset y2label;\n"); | |
158 endif | |
6405 | 159 endif |
160 endif | |
161 | |
162 if (! isempty (axis_obj.zlabel)) | |
163 t = get (axis_obj.zlabel); | |
6737 | 164 angle = t.rotation; |
7269 | 165 colorspec = get_text_colorspec (axis_obj.zcolor, mono); |
6405 | 166 if (isempty (t.string)) |
167 fputs (plot_stream, "unset zlabel;\n"); | |
168 else | |
7189 | 169 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string", |
170 have_newer_gnuplot); | |
7257 | 171 if (strcmp (f, "*")) |
172 fontspec = ""; | |
173 else | |
174 fontspec = sprintf ("font \"%s,%d\"", f, s); | |
175 endif | |
11615 | 176 fprintf (plot_stream, "set zlabel \"%s\" %s %s %s", |
177 undo_string_escapes (tt), colorspec, fontspec, | |
178 __do_enhanced_option__ (enhanced, t)); | |
6738 | 179 if (have_newer_gnuplot) |
180 ## Rotation of zlabel not yet support by gnuplot as of 4.2, but | |
181 ## there is no message about it. | |
182 fprintf (plot_stream, " rotate by %f;\n", angle); | |
183 endif | |
184 fputs (plot_stream, ";\n"); | |
6405 | 185 endif |
186 endif | |
187 | |
6809 | 188 if (strcmpi (axis_obj.xaxislocation, "top")) |
189 xaxisloc = "x2"; | |
190 xaxisloc_using = "x2"; | |
191 else | |
192 xaxisloc = "x"; | |
193 xaxisloc_using = "x1"; | |
7321 | 194 if (strcmpi (axis_obj.xaxislocation, "zero")) |
195 fputs (plot_stream, "set xzeroaxis;\n"); | |
196 endif | |
6809 | 197 endif |
198 if (strcmpi (axis_obj.yaxislocation, "right")) | |
199 yaxisloc = "y2"; | |
200 yaxisloc_using = "y2"; | |
201 else | |
202 yaxisloc = "y"; | |
203 yaxisloc_using = "y1"; | |
7321 | 204 if (strcmpi (axis_obj.yaxislocation, "zero")) |
205 fputs (plot_stream, "set yzeroaxis;\n"); | |
206 endif | |
6809 | 207 endif |
208 | |
7274 | 209 have_grid = false; |
210 | |
6758 | 211 if (strcmpi (axis_obj.xgrid, "on")) |
7274 | 212 have_grid = true; |
6809 | 213 fprintf (plot_stream, "set grid %stics;\n", xaxisloc); |
6405 | 214 else |
6809 | 215 fprintf (plot_stream, "set grid no%stics;\n", xaxisloc); |
6405 | 216 endif |
217 | |
6758 | 218 if (strcmpi (axis_obj.ygrid, "on")) |
7274 | 219 have_grid = true; |
6809 | 220 fprintf (plot_stream, "set grid %stics;\n", yaxisloc); |
6405 | 221 else |
6809 | 222 fprintf (plot_stream, "set grid no%stics;\n", yaxisloc); |
6405 | 223 endif |
224 | |
6758 | 225 if (strcmpi (axis_obj.zgrid, "on")) |
7274 | 226 have_grid = true; |
6405 | 227 fputs (plot_stream, "set grid ztics;\n"); |
228 else | |
7085 | 229 fputs (plot_stream, "set grid noztics;\n"); |
6405 | 230 endif |
231 | |
6758 | 232 if (strcmpi (axis_obj.xminorgrid, "on")) |
7274 | 233 have_grid = true; |
6809 | 234 fprintf (plot_stream, "set m%stics 5;\n", xaxisloc); |
235 fprintf (plot_stream, "set grid m%stics;\n", xaxisloc); | |
6405 | 236 else |
6809 | 237 fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc); |
6405 | 238 endif |
239 | |
6758 | 240 if (strcmpi (axis_obj.yminorgrid, "on")) |
7274 | 241 have_grid = true; |
6809 | 242 fprintf (plot_stream, "set m%stics 5;\n", yaxisloc); |
243 fprintf (plot_stream, "set grid m%stics;\n", yaxisloc); | |
6405 | 244 else |
6809 | 245 fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc); |
6405 | 246 endif |
247 | |
6758 | 248 if (strcmpi (axis_obj.zminorgrid, "on")) |
7274 | 249 have_grid = true; |
6405 | 250 fputs (plot_stream, "set mztics 5;\n"); |
251 fputs (plot_stream, "set grid mztics;\n"); | |
252 else | |
253 fputs (plot_stream, "set grid nomztics;\n"); | |
254 endif | |
255 | |
7307 | 256 ## The grid front/back/layerdefault option also controls the |
257 ## appearance of tics, so it is used even if the grid is absent. | |
258 if (strcmpi (axis_obj.layer, "top")) | |
259 fputs (plot_stream, "set grid front;\n"); | |
260 else | |
261 fputs (plot_stream, "set grid layerdefault;\n"); | |
262 endif | |
7297 | 263 if (! have_grid) |
264 fputs (plot_stream, "unset grid;\n"); | |
7274 | 265 endif |
266 | |
7269 | 267 do_tics (axis_obj, plot_stream, ymirror, mono); |
6405 | 268 |
6758 | 269 xlogscale = strcmpi (axis_obj.xscale, "log"); |
6405 | 270 if (xlogscale) |
6809 | 271 fprintf (plot_stream, "set logscale %s;\n", xaxisloc); |
6405 | 272 else |
6809 | 273 fprintf (plot_stream, "unset logscale %s;\n", xaxisloc); |
6405 | 274 endif |
275 | |
6758 | 276 ylogscale = strcmpi (axis_obj.yscale, "log"); |
6405 | 277 if (ylogscale) |
6809 | 278 fprintf (plot_stream, "set logscale %s;\n", yaxisloc); |
6405 | 279 else |
6809 | 280 fprintf (plot_stream, "unset logscale %s;\n", yaxisloc); |
6405 | 281 endif |
282 | |
6758 | 283 zlogscale = strcmpi (axis_obj.zscale, "log"); |
6405 | 284 if (zlogscale) |
285 fputs (plot_stream, "set logscale z;\n"); | |
286 else | |
287 fputs (plot_stream, "unset logscale z;\n"); | |
288 endif | |
289 | |
6758 | 290 xautoscale = strcmpi (axis_obj.xlimmode, "auto"); |
291 yautoscale = strcmpi (axis_obj.ylimmode, "auto"); | |
292 zautoscale = strcmpi (axis_obj.zlimmode, "auto"); | |
7109 | 293 cautoscale = strcmpi (axis_obj.climmode, "auto"); |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
294 cdatadirect = false; |
6405 | 295 |
296 kids = axis_obj.children; | |
297 | |
7316 | 298 nd = __calc_dimensions__ (axis_obj); |
299 | |
300 if (nd == 3) | |
301 fputs (plot_stream, "set parametric;\n"); | |
302 fputs (plot_stream, "set style data lines;\n"); | |
303 fputs (plot_stream, "set surface;\n"); | |
304 fputs (plot_stream, "unset contour;\n"); | |
305 endif | |
306 | |
6405 | 307 data_idx = 0; |
308 data = cell (); | |
6464 | 309 is_image_data = []; |
7175 | 310 hidden_removal = NaN; |
7271 | 311 view_map = false; |
6405 | 312 |
7223 | 313 xlim = axis_obj.xlim; |
314 ylim = axis_obj.ylim; | |
315 zlim = axis_obj.zlim; | |
316 clim = axis_obj.clim; | |
6405 | 317 |
7222 | 318 if (! cautoscale && clim(1) == clim(2)) |
319 clim(2)++; | |
7189 | 320 endif |
321 | |
6405 | 322 [view_cmd, view_fcn, view_zoom] = image_viewer (); |
323 use_gnuplot_for_images = (ischar (view_fcn) | |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
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 | |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
diff
changeset
|
341 if (strcmpi (obj.cdatamapping, "direct")) |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
342 cdatadirect = true; |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
343 endif |
7271 | 344 fputs (plot_stream, "set border front;\n"); |
6405 | 345 data_idx++; |
6464 | 346 is_image_data(data_idx) = true; |
6861 | 347 parametric(data_idx) = false; |
7119 | 348 have_cdata(data_idx) = false; |
6405 | 349 |
350 [y_dim, x_dim] = size (img_data(:,:,1)); | |
351 if (x_dim > 1) | |
352 dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); | |
353 else | |
354 dx = 1; | |
355 endif | |
356 if (y_dim > 1) | |
357 dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); | |
358 else | |
359 dy = 1; | |
360 endif | |
361 x_origin = min (img_xdata); | |
362 y_origin = min (img_ydata); | |
363 | |
364 if (ndims (img_data) == 3) | |
6464 | 365 data{data_idx} = permute (img_data, [3, 1, 2])(:); |
6405 | 366 format = "1:2:3"; |
367 imagetype = "rgbimage"; | |
368 else | |
6464 | 369 data{data_idx} = img_data(:); |
6405 | 370 format = "1"; |
371 imagetype = "image"; | |
372 endif | |
373 | |
6579 | 374 titlespec{data_idx} = "title \"\""; |
6914 | 375 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s", |
6405 | 376 x_dim, y_dim, x_origin, y_origin, dx, dy, format); |
377 withclause{data_idx} = sprintf ("with %s", imagetype); | |
378 | |
379 else | |
380 ximg_data{++ximg_data_idx} = img_data; | |
381 endif | |
382 | |
383 case "line" | |
7120 | 384 if (strncmp (obj.linestyle, "none", 4) |
385 && (! isfield (obj, "marker") | |
386 || (isfield (obj, "marker") | |
387 && strncmp (obj.marker, "none", 4)))) | |
388 continue; | |
389 endif | |
6405 | 390 data_idx++; |
6464 | 391 is_image_data(data_idx) = false; |
6861 | 392 parametric(data_idx) = true; |
7119 | 393 have_cdata(data_idx) = false; |
6405 | 394 if (isempty (obj.keylabel)) |
395 titlespec{data_idx} = "title \"\""; | |
396 else | |
7189 | 397 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7094 | 398 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
6405 | 399 endif |
400 usingclause{data_idx} = ""; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
401 errbars = ""; |
7316 | 402 if (nd == 3) |
6405 | 403 xdat = obj.xdata(:); |
404 ydat = obj.ydata(:); | |
7316 | 405 if (! isempty (obj.zdata)) |
406 zdat = obj.zdata(:); | |
407 else | |
408 zdat = zeros (size (xdat)); | |
409 endif | |
6405 | 410 data{data_idx} = [xdat, ydat, zdat]'; |
411 usingclause{data_idx} = "using ($1):($2):($3)"; | |
7316 | 412 ## fputs (plot_stream, "set parametric;\n"); |
6405 | 413 else |
414 xdat = obj.xdata(:); | |
415 ydat = obj.ydata(:); | |
416 ldat = obj.ldata; | |
417 yerr = xerr = false; | |
418 if (! isempty (ldat)) | |
419 yerr = true; | |
420 ldat = ldat(:); | |
421 endif | |
422 udat = obj.udata; | |
423 if (! isempty (udat)) | |
424 udat = udat(:); | |
425 endif | |
426 xldat = obj.xldata; | |
427 if (! isempty (xldat)) | |
428 xerr = true; | |
429 xldat = xldat(:); | |
430 endif | |
431 xudat = obj.xudata; | |
432 if (! isempty (xudat)) | |
433 xudat = xudat(:); | |
434 endif | |
435 if (yerr) | |
7213 | 436 if (isempty (ldat)) |
437 ylo = ydat; | |
438 else | |
439 ylo = ydat-ldat; | |
440 endif | |
441 if (isempty (udat)) | |
442 yhi = ydat; | |
443 else | |
444 yhi = ydat+udat; | |
445 endif | |
6405 | 446 if (xerr) |
7213 | 447 if (isempty (xldat)) |
448 xlo = xdat; | |
449 else | |
450 xlo = xdat-xldat; | |
451 endif | |
452 if (isempty (xudat)) | |
453 xhi = xdat; | |
454 else | |
455 xhi = xdat+xudat; | |
456 endif | |
6405 | 457 data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; |
458 usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
459 errbars = "xyerrorbars"; |
6405 | 460 else |
461 data{data_idx} = [xdat, ydat, ylo, yhi]'; | |
462 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
463 errbars = "yerrorbars"; |
6405 | 464 endif |
465 elseif (xerr) | |
7236 | 466 if (isempty (xldat)) |
467 xlo = xdat; | |
468 else | |
469 xlo = xdat-xldat; | |
470 endif | |
471 if (isempty (xudat)) | |
472 xhi = xdat; | |
473 else | |
474 xhi = xdat+xudat; | |
475 endif | |
6405 | 476 data{data_idx} = [xdat, ydat, xlo, xhi]'; |
477 usingclause{data_idx} = "using ($1):($2):($3):($4)"; | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
478 errbars = "xerrorbars"; |
6405 | 479 else |
480 data{data_idx} = [xdat, ydat]'; | |
6809 | 481 usingclause{data_idx} = sprintf ("using ($1):($2) axes %s%s", |
482 xaxisloc_using, yaxisloc_using); | |
6405 | 483 endif |
484 endif | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
485 |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
486 [style, typ, with] = do_linestyle_command (obj, data_idx, mono, |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
487 plot_stream, errbars); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
488 |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
489 if (have_newer_gnuplot || isnan (typ)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
490 withclause{data_idx} = sprintf ("with %s linestyle %d", |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
491 style, data_idx); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
492 else |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
493 withclause{data_idx} = sprintf ("with %s linetype %d", |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
494 style, typ); |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
495 endif |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
496 |
6465 | 497 if (! (have_newer_gnuplot || isempty (with))) |
498 if (isempty (withclause{data_idx})) | |
6809 | 499 withclause{data_idx} = sprintf ("with %s", with); |
6465 | 500 else |
6809 | 501 withclause{data_idx} = sprintf ("%s %s", withclause{data_idx}, |
502 with); | |
6465 | 503 endif |
504 endif | |
6405 | 505 |
6790 | 506 case "patch" |
6885 | 507 cmap = parent_figure_obj.colormap; |
7020 | 508 [nr, nc] = size (obj.xdata); |
509 | |
7189 | 510 if (! isempty (obj.cdata)) |
511 cdat = obj.cdata; | |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
diff
changeset
|
512 if (strcmpi (obj.cdatamapping, "direct")) |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
513 cdatadirect = true; |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
514 endif |
7189 | 515 else |
516 cdat = []; | |
517 endif | |
518 | |
7170 | 519 for i = 1:nc |
7020 | 520 xcol = obj.xdata(:,i); |
521 ycol = obj.ydata(:,i); | |
7316 | 522 if (nd == 3) |
523 if (! isempty (obj.zdata)) | |
524 zcol = obj.zdata(:,i); | |
525 else | |
526 zcol = zeros (size (xcol)); | |
527 endif | |
7170 | 528 endif |
7020 | 529 |
530 if (! isnan (xcol) && ! isnan (ycol)) | |
531 ## Is the patch closed or not | |
7175 | 532 if (strncmp (obj.facecolor, "none", 4)) |
7318 | 533 hidden_removal = false; |
534 else | |
7175 | 535 if (isnan (hidden_removal)) |
7318 | 536 hidden_removal = true; |
7175 | 537 endif |
7316 | 538 if (nd == 3) |
7170 | 539 error ("gnuplot (as of v4.2) only supports 2D filled patches"); |
540 endif | |
541 | |
542 data_idx++; | |
543 is_image_data(data_idx) = false; | |
544 parametric(data_idx) = false; | |
545 have_cdata(data_idx) = false; | |
546 if (i > 1 || isempty (obj.keylabel)) | |
547 titlespec{data_idx} = "title \"\""; | |
548 else | |
7189 | 549 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); |
7170 | 550 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
551 endif | |
552 usingclause{data_idx} = ""; | |
7189 | 553 if (isfield (obj, "facecolor")) |
554 if ((strncmp (obj.facecolor, "flat", 4) | |
7284 | 555 || strncmp (obj.facecolor, "interp", 6)) |
556 && isfield (obj, "cdata")) | |
7170 | 557 if (ndims (obj.cdata) == 2 |
7189 | 558 && (size (obj.cdata, 2) == nc |
559 && (size (obj.cdata, 1) == 1 | |
560 || size (obj.cdata, 1) == 3))) | |
561 ccol = cdat (:, i); | |
562 elseif (ndims (obj.cdata) == 2 | |
563 && (size (obj.cdata, 1) == nc | |
564 && (size (obj.cdata, 2) == 1 | |
565 || size (obj.cdata, 2) == 3))) | |
566 ccol = cdat (i, :); | |
7170 | 567 elseif (ndims (obj.cdata) == 3) |
7189 | 568 ccol = permute (cdat (:, i, :), [1, 3, 2]); |
7170 | 569 else |
7189 | 570 ccol = cdat; |
7170 | 571 endif |
572 if (strncmp (obj.facecolor, "flat", 4)) | |
573 if (numel(ccol) == 3) | |
574 color = ccol; | |
575 else | |
7226 | 576 r = 1 + round ((size (cmap, 1) - 1) |
577 * (ccol - clim(1))/(clim(2) - clim(1))); | |
7170 | 578 r = max (1, min (r, size (cmap, 1))); |
579 color = cmap(r, :); | |
580 endif | |
581 elseif (strncmp (obj.facecolor, "interp", 6)) | |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
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 |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
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")) | |
11673
e6364723ae29
markersize compatibility changes
John W. Eaton <jwe@octave.org>
parents:
11666
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)) |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
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 | |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
690 if (isfield (obj, "linewidth")) |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
691 if (have_newer_gnuplot) |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
692 lw = sprintf("linewidth %f", obj.linewidth); |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
693 else |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
694 lw = sprintf("lw %f", obj.linewidth); |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
695 endif |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
696 else |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
697 lw = ""; |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
698 endif |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
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) | |
11673
e6364723ae29
markersize compatibility changes
John W. Eaton <jwe@octave.org>
parents:
11666
diff
changeset
|
750 m = mdat(i) / 6; |
7189 | 751 else |
11673
e6364723ae29
markersize compatibility changes
John W. Eaton <jwe@octave.org>
parents:
11666
diff
changeset
|
752 m = mdat / 6; |
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 | |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
774 withclause{data_idx} = sprintf ("with %s %s %s %s %s %s", |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
775 style, lw, pt, lt, ps, |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
776 colorspec); |
7020 | 777 else |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
778 typ = get_old_gnuplot_color (color); |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
779 withclause{data_idx} = sprintf ("with %s %s %s %s lt %d", |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
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)); |
7109 | 816 titlespec{data_idx} = strcat ("title \"", tmp, "\""); |
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)"; | |
11687 | 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))); | |
11687 | 883 hidden_removal = false; |
11686
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
884 |
7318 | 885 if (flat_interp_edge && facecolor_none_or_white) |
7189 | 886 withclause{data_idx} = "with line palette"; |
11686
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
887 fputs (plot_stream, "unset pm3d\n"); |
11687 | 888 if (all (obj.facecolor == 1)) |
889 hidden_removal = true; | |
890 endif | |
11686
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
891 elseif (facecolor_none_or_white) |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
892 edgecol = obj.edgecolor; |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
893 if (have_newer_gnuplot) |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
894 if (mono) |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
895 colorspec = ""; |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
896 else |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
897 colorspec = sprintf ("linecolor rgb \"#%02x%02x%02x\"", |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
898 round (255*edgecol)); |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
899 endif |
11687 | 900 if (all (obj.facecolor == 1)) |
901 hidden_removal = true; | |
902 endif | |
903 fputs(plot_stream,"unset pm3d;\n"); | |
11686
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
904 fprintf (plot_stream, |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
905 "set style line %d %s lw %f;\n", |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
906 data_idx, colorspec, obj.linewidth); |
11687 | 907 fputs(plot_stream,"set style increment user;\n"); |
11686
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
908 else |
11690
42e936258b19
_go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11688
diff
changeset
|
909 typ = get_old_gnuplot_color (edgecol); |
11686
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
910 fprintf (plot_stream, |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
911 "set style line %d lt %d lw %f;\n", |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
912 data_idx, typ, obj.linewidth); |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
913 endif |
7956ecd5fa43
If FaceColor is none don't use pm3d mode and set linestyle correctly.
kai@linux-pc
parents:
11685
diff
changeset
|
914 withclause{data_idx} = sprintf("with line linestyle %d", data_idx); |
11687 | 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)) | |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
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 |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
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, |
11615 | 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), |
11615 | 986 lpos(2), lpos(3), halign, angle, fontspec, |
987 __do_enhanced_option__ (enhanced, obj), colorspec); | |
6405 | 988 else |
7162 | 989 fprintf (plot_stream, |
11615 | 990 "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n", |
7162 | 991 undo_string_escapes (label), units, |
11615 | 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 |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1045 cmap = parent_figure_obj.colormap; |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1046 cmap_sz = rows(cmap); |
7189 | 1047 if (! any (isinf (clim))) |
11635
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1048 if (cdatadirect) |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1049 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz); |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1050 else |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
1051 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); |
e08d2fff0d58
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
11622
diff
changeset
|
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")) |
1066 fputs (plot_stream, "unset ytics; set y2tics nomirror\n"); | |
1067 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1068 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | |
1069 fputs (plot_stream, "set border 12;\n"); | |
1070 else | |
1071 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | |
1072 fputs (plot_stream, "set border 9;\n"); | |
1073 endif | |
1074 else | |
1075 fputs (plot_stream, "unset y2tics; set ytics nomirror\n"); | |
1076 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1077 fputs (plot_stream, "unset xtics; set x2tics nomirror\n"); | |
1078 fputs (plot_stream, "set border 6;\n"); | |
1079 else | |
1080 fputs (plot_stream, "unset x2tics; set xtics nomirror\n"); | |
1081 fputs (plot_stream, "set border 3;\n"); | |
1082 endif | |
1083 endif | |
6405 | 1084 endif |
1085 endif | |
1086 | |
7060 | 1087 if (strcmpi (axis_obj.visible, "off")) |
1088 fputs (plot_stream, "unset border; unset tics\n"); | |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
1089 else |
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
1090 fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth); |
7060 | 1091 endif |
1092 | |
6758 | 1093 if (strcmpi (axis_obj.key, "on")) |
1094 if (strcmpi (axis_obj.keybox, "on")) | |
6405 | 1095 box = "box"; |
1096 else | |
1097 box = "nobox"; | |
1098 endif | |
1099 inout = "inside"; | |
6977 | 1100 keypos = axis_obj.keypos; |
1101 if (ischar (keypos)) | |
1102 keypos = lower (keypos); | |
1103 keyout = findstr (keypos, "outside"); | |
1104 if (! isempty (keyout)) | |
1105 inout = "outside"; | |
7119 | 1106 keypos = keypos(1:keyout-1); |
6977 | 1107 endif |
1108 endif | |
1109 switch (keypos) | |
6405 | 1110 case -1 |
6977 | 1111 pos = "right top"; |
6405 | 1112 inout = "outside"; |
1113 case 1 | |
1114 pos = "right top"; | |
1115 case 2 | |
1116 pos = "left top"; | |
1117 case 3 | |
1118 pos = "left bottom"; | |
6977 | 1119 case {4, 0} |
6405 | 1120 pos = "right bottom"; |
6977 | 1121 case "north" |
1122 pos = "center top"; | |
1123 case "south" | |
1124 pos = "center bottom"; | |
1125 case "east" | |
1126 pos = "right center"; | |
1127 case "west" | |
1128 pos = "left center"; | |
1129 case "northeast" | |
1130 pos = "right top"; | |
1131 case "northwest" | |
1132 pos = "left top"; | |
1133 case "southeast" | |
1134 pos = "right bottom"; | |
1135 case "southwest" | |
1136 pos = "left bottom"; | |
1137 case "best" | |
1138 pos = ""; | |
1139 warning ("legend: 'Best' not yet implemented for location specifier.\n"); | |
1140 ## least conflict with data in plot | |
1141 ## least unused space outside plot | |
6405 | 1142 otherwise |
1143 pos = ""; | |
1144 endswitch | |
1145 if (! have_newer_gnuplot) | |
1146 inout = ""; | |
1147 endif | |
1148 fprintf (plot_stream, "set key %s %s %s;\n", inout, pos, box); | |
1149 else | |
1150 fputs (plot_stream, "unset key;\n"); | |
1151 endif | |
1152 | |
1153 fputs (plot_stream, "set style data lines;\n"); | |
1154 | |
1155 if (! use_gnuplot_for_images) | |
1156 for i = 1:ximg_data_idx | |
1157 view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd); | |
1158 endfor | |
1159 endif | |
1160 | |
7189 | 1161 if (length(cmap) > 0) |
1162 if (have_newer_gnuplot) | |
1163 fprintf (plot_stream, | |
1164 "set palette positive color model RGB maxcolors %i;\n", | |
1165 cmap_sz); | |
1166 fprintf (plot_stream, | |
1167 "set palette file \"-\" binary record=%d using 1:2:3:4;\n", | |
1168 cmap_sz); | |
1169 fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32"); | |
11636
2be7477f470a
Fix colorbar with contours
David Bateman <dbateman@free.fr>
parents:
11635
diff
changeset
|
1170 fwrite (plot_stream, "\n"); |
7189 | 1171 else |
1172 fputs (plot_stream, "set palette defined ("); | |
1173 for i = 1: cmap_sz | |
1174 col = floor(cmap(i, :) * 255); | |
1175 if (i == 1) | |
1176 fputs (plot_stream, sprintf("%d \"#%02X%02X%02X\"", i - 1, | |
1177 col(1), col(2), col(3))); | |
1178 else | |
1179 fputs (plot_stream, sprintf(", %d \"#%02X%02X%02X\"", i - 1, | |
1180 col(1), col(2), col(3))); | |
1181 endif | |
1182 endfor | |
1183 fputs (plot_stream, ");\n"); | |
1184 endif | |
1185 endif | |
1186 | |
11688
e13219eaf388
__go_draw_axes__: use strcmpi for text properties; use get for hidden properties
John W. Eaton <jwe@octave.org>
parents:
11687
diff
changeset
|
1187 if (strcmpi (get (h, "__colorbar__"), "none")) |
7189 | 1188 fputs (plot_stream, "unset colorbox;\n"); |
1189 else | |
1190 ## FIXME If cbox_mirror is true we want to invert the tic labels | |
1191 ## but gnuplot doesn't allow that | |
1192 fputs (plot_stream, | |
1193 sprintf ("set colorbox %s user origin %f,%f size %f,%f;\n", | |
1194 cbox_orient, cbox_origin, cbox_size)); | |
1195 endif | |
1196 | |
6405 | 1197 if (have_data) |
1198 if (nd == 2) | |
1199 plot_cmd = "plot"; | |
1200 else | |
1201 plot_cmd = "splot"; | |
1202 rot_x = 90 - axis_obj.view(2); | |
1203 rot_z = axis_obj.view(1); | |
1204 while (rot_z < 0) | |
1205 rot_z += 360; | |
1206 endwhile | |
6461 | 1207 fputs (plot_stream, "set ticslevel 0;\n"); |
7271 | 1208 if (view_map && rot_x == 0 && rot_z == 0) |
1209 fputs (plot_stream, "set view map;\n"); | |
1210 else | |
1211 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); | |
1212 endif | |
6405 | 1213 endif |
6611 | 1214 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
6464 | 1215 usingclause{1}, titlespec{1}, withclause{1}); |
6405 | 1216 for i = 2:data_idx |
6611 | 1217 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", |
6464 | 1218 usingclause{i}, titlespec{i}, withclause{i}); |
6405 | 1219 endfor |
1220 fputs (plot_stream, ";\n"); | |
1221 for i = 1:data_idx | |
6464 | 1222 if (is_image_data(i)) |
1223 fwrite (plot_stream, data{i}, "float32"); | |
1224 else | |
7119 | 1225 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i), |
1226 have_cdata(i)); | |
6405 | 1227 endif |
1228 endfor | |
6431 | 1229 else |
1230 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n"); | |
6405 | 1231 endif |
1232 | |
7271 | 1233 ## Needed to allow mouse rotation with pcolor |
1234 if (view_map) | |
1235 fputs (plot_stream, "unset view;\n"); | |
1236 endif | |
1237 | |
6405 | 1238 fflush (plot_stream); |
1239 | |
1240 else | |
1241 print_usage (); | |
7109 | 1242 endif |
6405 | 1243 |
1244 endfunction | |
1245 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1246 function [style, typ, with] = do_linestyle_command (obj, idx, mono, |
11658
db22340e1f24
__stepimp__: don't call subplot for single plot
John W. Eaton <jwe@octave.org>
parents:
11655
diff
changeset
|
1247 plot_stream, errbars = "") |
6405 | 1248 |
6413 | 1249 persistent have_newer_gnuplot ... |
1250 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
6405 | 1251 |
1252 if (have_newer_gnuplot) | |
1253 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1254 endif | |
1255 fprintf (plot_stream, "set style line %d", idx); | |
1256 | |
1257 found_style = false; | |
6425 | 1258 typ = NaN; |
6465 | 1259 with = ""; |
6405 | 1260 |
6425 | 1261 if (isfield (obj, "color")) |
6405 | 1262 color = obj.color; |
1263 if (isnumeric (color)) | |
6425 | 1264 if (have_newer_gnuplot) |
7269 | 1265 if (! mono) |
1266 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1267 round (255*color)); | |
1268 endif | |
6425 | 1269 else |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
1270 typ = get_old_gnuplot_color (color); |
6425 | 1271 endif |
6405 | 1272 endif |
1273 found_style = true; | |
1274 endif | |
1275 | |
1276 if (isfield (obj, "linestyle")) | |
1277 switch (obj.linestyle) | |
1278 case "-" | |
6415 | 1279 lt = "1"; |
6405 | 1280 case "--" |
6415 | 1281 lt = "2"; |
6405 | 1282 case ":" |
6415 | 1283 lt = "3"; |
6405 | 1284 case "-." |
6415 | 1285 lt = "6"; |
6405 | 1286 case "none" |
1287 lt = ""; | |
1288 otherwise | |
1289 lt = ""; | |
1290 endswitch | |
6843 | 1291 |
1292 ## FIXME -- linetype is currently broken, since it disables the | |
1293 ## gnuplot default dashed and solid linestyles with the only | |
1294 ## benefit of being able to specify '--' and get a single sized | |
1295 ## dashed line of identical dash pattern for all called this way. | |
1296 ## All dash patterns are a subset of "with lines" and none of the | |
1297 ## lt specifications will correctly propagate into the x11 terminal | |
1298 ## or the print command. Therefore, it is currently disabled in | |
1299 ## order to allow print (..., "-dashed") etc. to work correctly. | |
1300 | |
1301 ## if (! isempty (lt)) | |
1302 ## fprintf (plot_stream, " linetype %s", lt); | |
1303 ## found_style = true; | |
1304 ## endif | |
1305 | |
6405 | 1306 else |
1307 lt = ""; | |
1308 endif | |
1309 | |
1310 if (isfield (obj, "linewidth")) | |
6465 | 1311 if (have_newer_gnuplot) |
1312 fprintf (plot_stream, " linewidth %f", obj.linewidth); | |
1313 else | |
1314 with = sprintf ("%s lw %f", with, obj.linewidth); | |
1315 endif | |
6405 | 1316 found_style = true; |
1317 endif | |
1318 | |
1319 if (isfield (obj, "marker")) | |
1320 switch (obj.marker) | |
1321 case "+" | |
1322 pt = "1"; | |
1323 case "o" | |
6413 | 1324 pt = "6"; |
6405 | 1325 case "*" |
1326 pt = "3"; | |
1327 case "." | |
7078 | 1328 pt = "0"; |
6405 | 1329 case "x" |
1330 pt = "2"; | |
1331 case {"square", "s"} | |
1332 pt = "5"; | |
1333 case {"diamond", "d"} | |
1334 pt = "13"; | |
1335 case "^" | |
1336 pt = "9"; | |
1337 case "v" | |
1338 pt = "11"; | |
1339 case ">" | |
1340 pt = "8"; | |
1341 case "<" | |
1342 pt = "10"; | |
1343 case {"pentagram", "p"} | |
1344 pt = "4"; | |
1345 case {"hexagram", "h"} | |
6413 | 1346 pt = "12"; |
6405 | 1347 case "none" |
1348 pt = ""; | |
1349 otherwise | |
1350 pt = ""; | |
1351 endswitch | |
1352 if (! isempty (pt)) | |
6465 | 1353 if (have_newer_gnuplot) |
1354 fprintf (plot_stream, " pointtype %s", pt); | |
1355 else | |
1356 with = sprintf ("%s pt %s", with, pt); | |
1357 endif | |
6405 | 1358 found_style = true; |
1359 endif | |
1360 else | |
1361 pt = ""; | |
1362 endif | |
1363 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1364 if (isempty (errbars)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1365 style = "lines"; |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1366 if (isempty (lt)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1367 if (! isempty (pt)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1368 style = "points"; |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1369 endif |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1370 elseif (! isempty (pt)) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1371 style = "linespoints"; |
6405 | 1372 endif |
1373 | |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1374 if (isfield (obj, "markersize")) |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1375 if (have_newer_gnuplot) |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
1376 fprintf (plot_stream, " pointsize %f", obj.markersize / 6); |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1377 else |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1378 if (! strcmpi (style, "lines")) |
11673
e6364723ae29
markersize compatibility changes
John W. Eaton <jwe@octave.org>
parents:
11666
diff
changeset
|
1379 with = sprintf ("%s ps %f", with, obj.markersize / 6); |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1380 endif |
6465 | 1381 endif |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1382 found_style = true; |
6465 | 1383 endif |
11655
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1384 else |
4bfe1ab20e99
fsolve: detect nonsquare systems
John W. Eaton <jwe@octave.org>
parents:
11636
diff
changeset
|
1385 style = errbars; |
6465 | 1386 found_style = true; |
1387 endif | |
1388 | |
6405 | 1389 if (have_newer_gnuplot && ! found_style) |
1390 fputs (plot_stream, " default"); | |
1391 endif | |
1392 | |
1393 fputs (plot_stream, ";\n"); | |
1394 | |
1395 endfunction | |
6510 | 1396 |
7316 | 1397 function nd = __calc_dimensions__ (obj) |
1398 kids = obj.children; | |
1399 nd = 2; | |
1400 for i = 1:length (kids) | |
1401 obj = get (kids(i)); | |
1402 switch (obj.type) | |
1403 case {"image", "text"} | |
1404 ## ignore as they | |
1405 case {"line", "patch"} | |
1406 if (! isempty (obj.zdata)) | |
1407 nd = 3; | |
1408 endif | |
1409 case "surface" | |
1410 nd = 3; | |
1411 endswitch | |
1412 endfor | |
1413 endfunction | |
1414 | |
7119 | 1415 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) |
6510 | 1416 |
1417 ## DATA is already transposed. | |
1418 | |
1419 ## FIXME -- this may need to be converted to C++ for speed. | |
1420 | |
6605 | 1421 ## Convert NA elements to normal NaN values because fprintf writes |
1422 ## "NA" and that confuses gnuplot. | |
1423 idx = find (isna (data)); | |
1424 if (any (idx)) | |
1425 data(idx) = NaN; | |
1426 endif | |
1427 | |
6510 | 1428 if (nd == 2) |
1429 nan_elts = find (sum (isnan (data))); | |
6914 | 1430 fmt = strcat (repmat ("%.15g ", 1, rows (data)), "\n"); |
6510 | 1431 if (isempty (nan_elts)) |
1432 fprintf (plot_stream, fmt, data); | |
1433 else | |
1434 n = columns (data); | |
1435 have_nans = true; | |
1436 num_nan_elts = numel (nan_elts); | |
1437 k = 1; | |
1438 for i = 1:n | |
1439 if (have_nans && i == nan_elts(k)) | |
1440 fputs (plot_stream, "\n"); | |
1441 have_nans = ++k <= num_nan_elts; | |
1442 else | |
1443 fprintf (plot_stream, fmt, data(:,i)); | |
1444 endif | |
1445 endfor | |
1446 endif | |
7109 | 1447 elseif (nd == 3) |
6510 | 1448 ## FIXME -- handle NaNs here too? |
1449 if (parametric) | |
6914 | 1450 fprintf (plot_stream, "%.15g %.15g %.15g\n", data); |
6510 | 1451 else |
7170 | 1452 nr = rows (data); |
7119 | 1453 if (cdata) |
7170 | 1454 for j = 1:4:nr |
1455 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data(j:j+3,:)); | |
7119 | 1456 fputs (plot_stream, "\n"); |
1457 endfor | |
1458 else | |
7170 | 1459 for j = 1:3:nr |
1460 fprintf (plot_stream, "%.15g %.15g %.15g\n", data(j:j+2,:)); | |
7119 | 1461 fputs (plot_stream, "\n"); |
1462 endfor | |
1463 endif | |
7109 | 1464 endif |
6510 | 1465 endif |
1466 fputs (plot_stream, "e\n"); | |
1467 | |
1468 endfunction | |
6745 | 1469 |
7269 | 1470 function do_tics (obj, plot_stream, ymirror, mono) |
6809 | 1471 if (strcmpi (obj.xaxislocation, "top")) |
1472 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7321 | 1473 obj.xcolor, "x2", plot_stream, true, mono, "border"); |
6809 | 1474 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7321 | 1475 obj.xcolor, "x", plot_stream, true, mono, "border"); |
1476 elseif (strcmpi (obj.xaxislocation, "zero")) | |
1477 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
1478 obj.xcolor, "x", plot_stream, true, mono, "axis"); | |
1479 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, | |
1480 obj.xcolor, "x2", plot_stream, true, mono, "axis"); | |
6809 | 1481 else |
1482 do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel, | |
7321 | 1483 obj.xcolor, "x", plot_stream, true, mono, "border"); |
6809 | 1484 do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel, |
7321 | 1485 obj.xcolor, "x2", plot_stream, true, mono, "border"); |
6809 | 1486 endif |
1487 if (strcmpi (obj.yaxislocation, "right")) | |
1488 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7321 | 1489 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); |
6809 | 1490 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7321 | 1491 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); |
1492 elseif (strcmpi (obj.xaxislocation, "zero")) | |
1493 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
1494 obj.ycolor, "y", plot_stream, ymirror, mono, "axis"); | |
1495 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, | |
1496 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis"); | |
6809 | 1497 else |
1498 do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel, | |
7321 | 1499 obj.ycolor, "y", plot_stream, ymirror, mono, "border"); |
6809 | 1500 do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel, |
7321 | 1501 obj.ycolor, "y2", plot_stream, ymirror, mono, "border"); |
6809 | 1502 endif |
6745 | 1503 do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel, |
7321 | 1504 obj.zcolor, "z", plot_stream, true, mono, "border"); |
6745 | 1505 endfunction |
1506 | |
7269 | 1507 function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, |
7321 | 1508 plot_stream, mirror, mono, axispos) |
7269 | 1509 colorspec = get_text_colorspec (color, mono); |
6758 | 1510 if (strcmpi (ticmode, "manual")) |
6745 | 1511 if (isempty (tics)) |
1512 fprintf (plot_stream, "unset %stics;\n", ax); | |
6758 | 1513 elseif (strcmpi (labelmode, "manual") && ! isempty (labels)) |
6751 | 1514 if (ischar (labels)) |
1515 labels = cellstr (labels); | |
1516 endif | |
6745 | 1517 if (iscellstr (labels)) |
6751 | 1518 k = 1; |
1519 ntics = numel (tics); | |
1520 nlabels = numel (labels); | |
6745 | 1521 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); |
7206 | 1522 if (mirror) |
7321 | 1523 fprintf (plot_stream, "set %stics %s (", ax, axispos); |
7206 | 1524 else |
7321 | 1525 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); |
7206 | 1526 endif |
7228 | 1527 labels = regexprep(labels, "%", "%%"); |
6745 | 1528 for i = 1:ntics |
11685
61244c9d99b3
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
11684
diff
changeset
|
1529 fprintf (plot_stream, " \"%s\" %g", labels{k++}, tics(i)); |
6745 | 1530 if (i < ntics) |
1531 fputs (plot_stream, ", "); | |
1532 endif | |
1533 if (k > nlabels) | |
1534 k = 1; | |
1535 endif | |
1536 endfor | |
7220 | 1537 fprintf (plot_stream, ") %s;\n", colorspec); |
6745 | 1538 else |
1539 error ("unsupported type of ticklabel"); | |
1540 endif | |
1541 else | |
6920 | 1542 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1543 if (mirror) |
7321 | 1544 fprintf (plot_stream, "set %stics %s (", ax, axispos ); |
7206 | 1545 else |
7321 | 1546 fprintf (plot_stream, "set %stics %s nomirror (", ax, axispos); |
7206 | 1547 endif |
6920 | 1548 fprintf (plot_stream, " %g,", tics(1:end-1)); |
1549 fprintf (plot_stream, " %g);\n", tics(end)); | |
6745 | 1550 endif |
1551 else | |
6920 | 1552 fprintf (plot_stream, "set format %s \"%%g\";\n", ax); |
7206 | 1553 if (mirror) |
7321 | 1554 fprintf (plot_stream, "set %stics %s %s;\n", ax, axispos, colorspec); |
7206 | 1555 else |
7321 | 1556 fprintf (plot_stream, "set %stics %s nomirror %s;\n", ax, |
1557 axispos, colorspec); | |
7206 | 1558 endif |
7194 | 1559 endif |
1560 endfunction | |
1561 | |
7269 | 1562 function colorspec = get_text_colorspec (color, mono) |
7194 | 1563 persistent have_newer_gnuplot ... |
1564 = compare_versions (__gnuplot_version__ (), "4.0", ">"); | |
1565 | |
1566 if (have_newer_gnuplot) | |
7269 | 1567 if (mono) |
1568 colorspec = ""; | |
1569 else | |
1570 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"", | |
1571 round (255*color)); | |
1572 endif | |
7194 | 1573 else |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
1574 typ = get_old_gnuplot_color (color); |
7194 | 1575 colorspec = sprintf ("textcolor lt %d", typ); |
6745 | 1576 endif |
1577 endfunction | |
7163 | 1578 |
7189 | 1579 function [f, s, fnt, it, bld] = get_fontname_and_size (t) |
7163 | 1580 if (isempty (t.fontname)) |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1581 fnt = "Helvetica"; |
7163 | 1582 else |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1583 fnt = t.fontname; |
7168 | 1584 endif |
7189 | 1585 f = fnt; |
1586 it = false; | |
1587 bld = false; | |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1588 if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold")) |
7168 | 1589 if (! isempty(t.fontangle) |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1590 && (strcmpi (t.fontangle, "italic") |
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1591 || strcmpi (t.fontangle, "oblique"))) |
7168 | 1592 f = strcat (f, "-bolditalic"); |
7189 | 1593 it = true; |
1594 bld = true; | |
7168 | 1595 else |
1596 f = strcat (f, "-bold"); | |
7189 | 1597 bld = true; |
7168 | 1598 endif |
1599 elseif (! isempty(t.fontangle) | |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1600 && (strcmpi (t.fontangle, "italic") |
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1601 || strcmpi (t.fontangle, "oblique"))) |
7168 | 1602 f = strcat (f, "-italic"); |
7189 | 1603 it = true; |
7163 | 1604 endif |
1605 if (isempty (t.fontsize)) | |
1606 s = 10; | |
1607 else | |
1608 s = t.fontsize; | |
1609 endif | |
1610 endfunction | |
7189 | 1611 |
1612 function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld, | |
1613 have_newer_gnuplot) | |
1614 persistent warned_latex = false; | |
1615 | |
1616 if (strcmp (fld, "string")) | |
1617 [f, s, fnt, it, bld] = get_fontname_and_size (obj); | |
1618 else | |
11666
93d17b1e756f
use Helvetica, not helvetica; don't downcase user-supplied font names
jwe
parents:
11658
diff
changeset
|
1619 f = "Helvetica"; |
7189 | 1620 s = 10; |
1621 fnt = f; | |
1622 it = false; | |
1623 bld = false; | |
1624 endif | |
1625 | |
1626 str = getfield (obj, fld); | |
1627 if (enhanced) | |
1628 if (strcmp (obj.interpreter, "tex")) | |
1629 str = __tex2enhanced__ (str, fnt, it, bld); | |
1630 if (! have_newer_gnuplot) | |
1631 ## Set the font to work around gnuplot 4.0 X11 enhanced terminal bug | |
1632 str = strcat ('{/', f, ' ', str, ' }'); | |
1633 endif | |
1634 elseif (strcmp (obj.interpreter, "latex")) | |
1635 if (! warned_latex) | |
1636 warning ("latex text objects not supported"); | |
1637 warned_latex = true; | |
1638 endif | |
1639 endif | |
1640 endif | |
1641 endfunction | |
1642 | |
1643 function str = __tex2enhanced__ (str, fnt, it, bld) | |
1644 persistent sym = __setup_sym_table__ (); | |
1645 persistent flds = fieldnames (sym); | |
1646 | |
1647 [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches'); | |
1648 | |
1649 for i = length (s) : -1 : 1 | |
1650 ## special case for "\0" and replace with "{/Symbol \306}' | |
1651 if (strncmp (m{i}, '\0', 2)) | |
7190 | 1652 str = strcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); |
7189 | 1653 else |
1654 f = m{i}(2:end); | |
1655 if (isfield (sym, f)) | |
1656 g = getfield(sym, f); | |
1657 ## FIXME The symbol font doesn't seem to support bold or italic | |
1658 ##if (bld) | |
1659 ## if (it) | |
1660 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1661 ## else | |
1662 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1663 ## endif | |
1664 ##elseif (it) | |
1665 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1666 ##endif | |
1667 str = strcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); | |
1668 elseif (strncmp (f, "rm", 2)) | |
1669 bld = false; | |
1670 it = false; | |
1671 str = strcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); | |
1672 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) | |
1673 it = true; | |
1674 if (bld) | |
1675 str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', | |
1676 str(s(i) + 3:end)); | |
1677 else | |
1678 str = strcat (str(1:s(i) - 1), '/', fnt, '-italic ', | |
1679 str(s(i) + 3:end)); | |
1680 endif | |
1681 elseif (strncmp (f, "bf", 2)) | |
1682 bld = true; | |
1683 if (it) | |
1684 str = strcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', | |
1685 str(2(i) + 3:end)); | |
1686 else | |
1687 str = strcat (str(1:s(i) - 1), '/', fnt, '-bold ', | |
1688 str(s(i) + 3:end)); | |
1689 endif | |
1690 elseif (strcmp (f, "color")) | |
1691 ## FIXME Ignore \color but remove trailing {} block as well | |
1692 d = strfind(str(e(i) + 1:end),'}'); | |
1693 if (isempty (d)) | |
1694 warning ('syntax error in \color argument'); | |
1695 else | |
1696 str = strcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); | |
1697 endif | |
1698 elseif(strcmp (f, "fontname")) | |
1699 b1 = strfind(str(e(i) + 1:end),'{'); | |
1700 b2 = strfind(str(e(i) + 1:end),'}'); | |
1701 if (isempty(b1) || isempty(b2)) | |
1702 warning ('syntax error in \fontname argument'); | |
1703 else | |
1704 str = strcat (str(1:s(i) - 1), '/', | |
1705 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', | |
1706 str(e(i) + b2(1) + 1:end)); | |
1707 endif | |
1708 elseif(strcmp (f, "fontsize")) | |
1709 b1 = strfind(str(e(i) + 1:end),'{'); | |
1710 b2 = strfind(str(e(i) + 1:end),'}'); | |
1711 if (isempty(b1) || isempty(b2)) | |
1712 warning ('syntax error in \fontname argument'); | |
1713 else | |
1714 str = strcat (str(1:s(i) - 1), '/=', | |
1715 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', | |
1716 str(e(i) + b2(1) + 1:end)); | |
1717 endif | |
1718 else | |
1719 ## Last desperate attempt to treat the symbol. Look for things | |
1720 ## like \pix, that should be translated to the symbol Pi and x | |
1721 for j = 1 : length (flds) | |
1722 if (strncmp (flds{j}, f, length (flds{j}))) | |
1723 g = getfield(sym, flds{j}); | |
1724 ## FIXME The symbol font doesn't seem to support bold or italic | |
1725 ##if (bld) | |
1726 ## if (it) | |
1727 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
1728 ## else | |
1729 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
1730 ## endif | |
1731 ##elseif (it) | |
1732 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
1733 ##endif | |
1734 str = strcat (str(1:s(i) - 1), g, | |
1735 str(s(i) + length (flds{j}) + 1:end)); | |
1736 break; | |
1737 endif | |
1738 endfor | |
1739 endif | |
1740 endif | |
1741 endfor | |
1742 | |
1743 ## Prepend @ to things things like _0^x or _{-100}^{100} for alignment | |
1744 ## But need to put the shorter of the two arguments first. Carful of | |
1745 ## nested {} and unprinted characters when defining shortest.. Don't | |
1746 ## have to worry about things like ^\theta as they are already converted to | |
1747 ## ^{/Symbol q}. | |
1748 | |
1749 ## FIXME.. This is a mess... Is it worth it just for a "@" character? | |
1750 | |
1751 [s, m] = regexp(str,'[_\^]','start','matches'); | |
1752 i = 1; | |
1753 p = 0; | |
1754 while (i < length (s)) | |
1755 if (i < length(s)) | |
1756 if (str(s(i) + p + 1) == "{") | |
1757 s1 = strfind(str(s(i) + p + 2:end),'{'); | |
1758 si = 1; | |
1759 l1 = strfind(str(s(i) + p + 1:end),'}'); | |
1760 li = 1; | |
1761 while (li <= length (l1) && si <= length (s1)) | |
1762 if (l1(li) < s1(si)) | |
1763 if (li == si) | |
1764 break; | |
1765 endif | |
1766 li++; | |
1767 else | |
1768 si++; | |
1769 endif | |
1770 endwhile | |
1771 l1 = l1 (min (length(l1), si)); | |
1772 if (s(i) + l1 + 1 == s(i+1)) | |
1773 if (str(s(i + 1) + p + 1) == "{") | |
1774 s2 = strfind(str(s(i + 1) + p + 2:end),'{'); | |
1775 si = 1; | |
1776 l2 = strfind(str(s(i + 1) + p + 1:end),'}'); | |
1777 li = 1; | |
1778 while (li <= length (l2) && si <= length (s2)) | |
1779 if (l2(li) < s2(si)) | |
1780 if (li == si) | |
1781 break; | |
1782 endif | |
1783 li++; | |
1784 else | |
1785 si++; | |
1786 endif | |
1787 endwhile | |
1788 l2 = l2 (min (length(l2), si)); | |
1789 if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= | |
1790 length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) | |
1791 ## shortest already first! | |
1792 str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
1793 else | |
1794 ## Have to swap sub/super-script to get shortest first | |
1795 str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), | |
1796 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); | |
1797 endif | |
1798 else | |
1799 ## Have to swap sub/super-script to get shortest first | |
1800 str = strcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), | |
1801 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); | |
1802 endif | |
1803 i += 2; | |
1804 p ++; | |
1805 else | |
1806 i++; | |
1807 endif | |
1808 else | |
1809 if (s(i+1) == s(i) + 2) | |
1810 ## shortest already first! | |
1811 str = strcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
1812 p ++; | |
1813 i += 2; | |
1814 else | |
1815 i ++; | |
1816 endif | |
1817 endif | |
1818 else | |
1819 i ++; | |
1820 endif | |
1821 endwhile | |
1822 | |
1823 endfunction | |
1824 | |
1825 function l = length_string (s) | |
1826 l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}')); | |
1827 m = regexp (s, '/([\w\-]+|[\w\-]+=\d+)', 'matches'); | |
1828 if (!isempty (m)) | |
1829 l = l - sum (cellfun (@length, m)); | |
1830 endif | |
1831 endfunction | |
1832 | |
1833 function sym = __setup_sym_table__ () | |
1834 ## Setup the translation table for TeX to gnuplot enhanced mode. | |
1835 sym.forall = '{/Symbol \042}'; | |
1836 sym.exists = '{/Symbol \044}'; | |
1837 sym.ni = '{/Symbol \047}'; | |
1838 sym.cong = '{/Symbol \100}'; | |
1839 sym.Delta = '{/Symbol D}'; | |
1840 sym.Phi = '{/Symbol F}'; | |
1841 sym.Gamma = '/Symbol G}'; | |
7190 | 1842 sym.vartheta = '{/Symbol J}'; |
7189 | 1843 sym.Lambda = '{/Symbol L}'; |
1844 sym.Pi = '{/Symbol P}'; | |
1845 sym.Theta = '{/Symbol Q}'; | |
1846 sym.Sigma = '{/Symbol S}'; | |
1847 sym.varsigma = '{/Symbol V}'; | |
11622 | 1848 sym.Omega = '{/Symbol W}'; |
7189 | 1849 sym.Xi = '{/Symbol X}'; |
1850 sym.Psi = '{/Symbol Y}'; | |
1851 sym.perp = '{/Symbol \136}'; | |
1852 sym.alpha = '{/Symbol a}'; | |
1853 sym.beta = '{/Symbol b}'; | |
1854 sym.chi = '{/Symbol c}'; | |
1855 sym.delta = '{/Symbol d}'; | |
1856 sym.epsilon = '{/Symbol e}'; | |
1857 sym.phi = '{/Symbol f}'; | |
1858 sym.gamma = '/Symbol g}'; | |
1859 sym.eta = '{/Symbol h}'; | |
1860 sym.iota = '{/Symbol i}'; | |
1861 sym.kappa = '{/Symbol k}'; | |
1862 sym.lambda = '{/Symbol l}'; | |
1863 sym.mu = '{/Symbol m}'; | |
1864 sym.nu = '{/Symbol n}'; | |
1865 sym.o = '{/Symbol o}'; | |
1866 sym.pi = '{/Symbol p}'; | |
1867 sym.theta = '{/Symbol q}'; | |
1868 sym.rho = '{/Symbol r}'; | |
1869 sym.sigma = '{/Symbol s}'; | |
1870 sym.tau = '{/Symbol t}'; | |
1871 sym.upsilon = '{/Symbol u}'; | |
1872 sym.varpi = '{/Symbol v}'; | |
1873 sym.omega = '{/Symbol w}'; | |
1874 sym.xi = '{/Symbol x}'; | |
1875 sym.psi = '{/Symbol y}'; | |
1876 sym.zeta = '{/Symbol z}'; | |
1877 sym.sim = '{/Symbol \176}'; | |
1878 sym.Upsilon = '{/Symbol \241}'; | |
1879 sym.prime = '{/Symbol \242}'; | |
1880 sym.leq = '{/Symbol \243}'; | |
1881 sym.infty = '{/Symbol \245}'; | |
1882 sym.clubsuit = '{/Symbol \247}'; | |
1883 sym.diamondsuit = '{/Symbol \250}'; | |
1884 sym.heartsuit = '{/Symbol \251}'; | |
1885 sym.spadesuit = '{/Symbol \252}'; | |
1886 sym.leftrightarrow = '{/Symbol \253}'; | |
1887 sym.leftarrow = '{/Symbol \254}'; | |
1888 sym.uparrow = '{/Symbol \255}'; | |
1889 sym.rightarrow = '{/Symbol \256}'; | |
1890 sym.downarrow = '{/Symbol \257}'; | |
1891 sym.circ = '{/Symbol \260}'; | |
1892 sym.pm = '{/Symbol \261}'; | |
1893 sym.geq = '{/Symbol \263}'; | |
1894 sym.times = '{/Symbol \264}'; | |
1895 sym.propto = '{/Symbol \265}'; | |
1896 sym.partial = '{/Symbol \266}'; | |
1897 sym.bullet = '{/Symbol \267}'; | |
1898 sym.div = '{/Symbol \270}'; | |
1899 sym.neq = '{/Symbol \271}'; | |
1900 sym.equiv = '{/Symbol \272}'; | |
1901 sym.approx = '{/Symbol \273}'; | |
1902 sym.ldots = '{/Symbol \274}'; | |
1903 sym.mid = '{/Symbol \275}'; | |
1904 sym.aleph = '{/Symbol \300}'; | |
1905 sym.Im = '{/Symbol \301}'; | |
1906 sym.Re = '{/Symbol \302}'; | |
1907 sym.wp = '{/Symbol \303}'; | |
1908 sym.otimes = '{/Symbol \304}'; | |
1909 sym.oplus = '{/Symbol \305}'; | |
1910 sym.oslash = '{/Symbol \306}'; | |
1911 sym.cap = '{/Symbol \307}'; | |
1912 sym.cup = '{/Symbol \310}'; | |
1913 sym.supset = '{/Symbol \311}'; | |
1914 sym.supseteq = '{/Symbol \312}'; | |
1915 sym.subset = '{/Symbol \314}'; | |
1916 sym.subseteq = '{/Symbol \315}'; | |
1917 sym.in = '{/Symbol \316}'; | |
1918 sym.langle = '{/Symbol \320}'; | |
1919 sym.rangle = '{/Symbol \320}'; | |
1920 sym.nabla = '{/Symbol \321}'; | |
1921 sym.surd = '{/Symbol \326}'; | |
1922 sym.cdot = '{/Symbol \327}'; | |
1923 sym.neg = '{/Symbol \330}'; | |
1924 sym.wedge = '{/Symbol \331}'; | |
1925 sym.vee = '{/Symbol \332}'; | |
1926 sym.copyright = '{/Symbol \343}'; | |
1927 sym.rfloor = '{/Symbol \353}'; | |
1928 sym.lceil = '{/Symbol \351}'; | |
1929 sym.lfloor = '{/Symbol \373}'; | |
1930 sym.rceil = '{/Symbol \371}'; | |
1931 sym.int = '{/Symbol \362}'; | |
1932 endfunction | |
1933 | |
1934 function [pos, orient, sz, origin, mirr] = gnuplot_postion_colorbox (pos, cbox) | |
1935 ## This is an emprically derived function that | |
1936 | |
1937 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
1938 scl = pos([2,4]); | |
1939 else | |
1940 scl = pos([1,3]); | |
1941 endif | |
1942 | |
1943 if (length(cbox) > 7 && strncmp (cbox(end-6:end), "outside", 7)) | |
1944 scl(2) -= 0.2 * scl(2); | |
1945 if (strncmp (cbox, "west", 4) || strncmp (cbox, "south", 5)) | |
1946 scl(1) += 0.2 * scl(2); | |
1947 endif | |
1948 endif | |
1949 | |
1950 switch (cbox) | |
1951 case "northoutside" | |
1952 sz = pos(3:4) - 0.08; | |
1953 origin = [0.05, 0.06] + [0.00, 0.88] .* sz + pos(1:2); | |
1954 mirr = true; | |
1955 orient = "horizontal"; | |
1956 case "north" | |
1957 sz = pos(3:4) - 0.16; | |
1958 origin = [0.09, 0.09] + [0.00, 0.94] .* sz + pos(1:2); | |
1959 mirr = false; | |
1960 orient = "horizontal"; | |
1961 case "southoutside" | |
1962 sz = pos(3:4) - 0.08; | |
1963 origin = [0.05, 0.06] + [0.00, 0.00] .* sz + pos(1:2); | |
1964 mirr = false; | |
1965 orient = "horizontal"; | |
1966 case "south" | |
1967 sz = pos(3:4) - 0.16; | |
1968 origin = [0.08, 0.09] + [0.03, 0.05] .* sz + pos(1:2); | |
1969 mirr = true; | |
1970 orient = "horizontal"; | |
1971 case "eastoutside" | |
1972 sz = pos(3:4) - 0.08; | |
1973 origin = [0.00, 0.06] + [0.94, 0.00] .* sz + pos(1:2); | |
1974 mirr = false; | |
1975 orient = "vertical"; | |
1976 case "east" | |
1977 sz = pos(3:4) - 0.16; | |
1978 origin = [0.09, 0.10] + [0.91, 0.01] .* sz + pos(1:2); | |
1979 mirr = true; | |
1980 orient = "vertical"; | |
1981 case "westoutside" | |
1982 sz = pos(3:4) - 0.08; | |
1983 origin = [0.00, 0.06] + [0.06, 0.00] .* sz + pos(1:2); | |
1984 mirr = true; | |
1985 orient = "vertical"; | |
1986 case "west" | |
1987 sz = pos(3:4) - 0.16; | |
1988 origin = [0.06, 0.09] + [0.04, 0.03] .* sz + pos(1:2); | |
1989 mirr = false; | |
1990 orient = "vertical"; | |
1991 endswitch | |
1992 | |
1993 if (strncmp (cbox, "north", 5) || strncmp (cbox, "south", 5)) | |
1994 sz = sz .* [1, 0.07]; | |
1995 pos([2,4]) = scl; | |
1996 else | |
1997 sz = sz .* [0.07, 1]; | |
1998 pos([1,3]) = scl; | |
1999 endif | |
2000 | |
2001 endfunction | |
11615 | 2002 |
2003 function retval = __do_enhanced_option__ (enhanced, obj) | |
2004 retval = ""; | |
2005 if (enhanced) | |
2006 if (strcmpi (obj.interpreter, "none")) | |
2007 retval = "noenhanced"; | |
2008 else | |
2009 retval = "enhanced"; | |
2010 endif | |
2011 endif | |
2012 endfunction | |
11684
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2013 |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2014 function typ = get_old_gnuplot_color (color) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2015 if (isequal (color, [0, 0, 0])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2016 typ = -1; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2017 elseif (isequal (color, [1, 0, 0])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2018 typ = 1; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2019 elseif (isequal (color, [0, 1, 0])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2020 typ = 2; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2021 elseif (isequal (color, [0, 0, 1])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2022 typ = 3; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2023 elseif (isequal (color, [1, 0, 1])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2024 typ = 4; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2025 elseif (isequal (color, [0, 1, 1])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2026 typ = 5; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2027 elseif (isequal (color, [1, 1, 1])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2028 typ = -1; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2029 elseif (isequal (color, [1, 1, 0])) |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2030 typ = 7; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2031 else |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2032 typ = -1; |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2033 endif |
e77150aa1ac2
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
John W. Eaton <jwe@octave.org>
parents:
11673
diff
changeset
|
2034 endfunction |