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