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