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