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