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