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