Mercurial > hg > octave-lyh
annotate scripts/plot/__go_draw_axes__.m @ 10635:d1978e7364ad
Print name of function in error() string messages.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 16 May 2010 22:26:54 -0700 |
parents | ba346313bdc1 |
children | 40cf7cc4ea62 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2005, 2007, 2008, 2009 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 | |
10528
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
26 function __go_draw_axes__ (h, plot_stream, enhanced, mono, implicit_margin, bg_is_set) |
6405 | 27 |
10528
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
28 if (nargin >= 4 && nargin <= 6) |
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); | |
9257
ab952265ad06
__go_draw_axes__.m: Properly render TeX symbols for x11.
Ben Abbott <bpabbott@mac.com>
parents:
9191
diff
changeset
|
39 gnuplot_term = __gnuplot_get_var__ (axis_obj.parent, "GPVAL_TERM"); |
6405 | 40 |
8208 | 41 ## Set to false for plotyy axes. |
42 if (strcmp (axis_obj.tag, "plotyy")) | |
8102 | 43 ymirror = false; |
8208 | 44 else |
45 ymirror = true; | |
7189 | 46 endif |
47 | |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
48 nd = __calc_dimensions__ (axis_obj); |
10532
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
49 if (strcmpi (axis_obj.plotboxaspectratiomode, "manual")) |
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
50 pos = __actual_axis_position__ (axis_obj); |
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
51 else |
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
52 pos = axis_obj.position; |
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
53 endif |
10561
5f46cc552ce5
__go_draw_axes__.m: Consistent placement of axes for ps vs other gnuplot terminals.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
54 pos(1:2) = pos(1:2) - implicit_margin .* [0.75, 0.5]; |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
55 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
|
56 if (nd == 2) |
10549 | 57 x = [1, 1]; |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
58 else |
10549 | 59 ## 3D plots need to be sized down to fit in the window. |
60 x = 1.0 ./ sqrt([2, 2.5]); | |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
61 endif |
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 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
|
63 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
|
64 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
|
65 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
|
66 else |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
67 ## 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
|
68 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
|
69 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
|
70 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
|
71 fprintf (plot_stream, "set rmargin 0;\n"); |
7189 | 72 |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
73 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
|
74 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
|
75 |
10532
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
76 if (strcmpi (axis_obj.dataaspectratiomode, "manual")) |
568c7c041fac
colorbar.m: Consistent treatment of plotboxaspectratio. Add listener for plotboxaspectratiomode.
Ben Abbott <bpabbott@mac.com>
parents:
10528
diff
changeset
|
77 r = axis_obj.dataaspectratio; |
8889
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
78 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
|
79 else |
665b264b6a50
Compatible support of figure paper properties and resolution for the gnuplot backend.
Ben Abbott <bpabbott@mac.com>
parents:
8812
diff
changeset
|
80 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
|
81 endif |
6405 | 82 endif |
83 | |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
84 ## Reset all labels, axis-labels, tick-labels, and title |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
85 ## FIXME - We should have an function to initialize the axis. |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
86 ## Presently, this is dispersed in this function. |
6778 | 87 fputs (plot_stream, "unset label;\n"); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
88 fputs (plot_stream, "unset xtics;\n"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
89 fputs (plot_stream, "unset ytics;\n"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
90 fputs (plot_stream, "unset ztics;\n"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
91 fputs (plot_stream, "unset x2tics;\n"); |
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
92 fputs (plot_stream, "unset x2tics;\n"); |
6778 | 93 |
6405 | 94 if (! isempty (axis_obj.title)) |
95 t = get (axis_obj.title); | |
96 if (isempty (t.string)) | |
10549 | 97 fputs (plot_stream, "unset title;\n"); |
6405 | 98 else |
10549 | 99 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string"); |
100 fontspec = create_fontspec (f, s, gnuplot_term); | |
101 fprintf (plot_stream, "set title \"%s\" %s %s", | |
102 undo_string_escapes (tt), fontspec, | |
103 __do_enhanced_option__ (enhanced, t)); | |
104 if (nd == 3 && __gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin")) | |
105 fprintf (plot_stream, " offset screen 0, screen %.3f;\n", pos(4)/5); | |
106 else | |
107 fprintf (plot_stream, ";\n"); | |
108 endif | |
6405 | 109 endif |
110 endif | |
111 | |
112 if (! isempty (axis_obj.xlabel)) | |
113 t = get (axis_obj.xlabel); | |
6737 | 114 angle = t.rotation; |
7269 | 115 colorspec = get_text_colorspec (axis_obj.xcolor, mono); |
6405 | 116 if (isempty (t.string)) |
10549 | 117 fprintf (plot_stream, "unset xlabel;\n"); |
118 fprintf (plot_stream, "unset x2label;\n"); | |
6405 | 119 else |
10549 | 120 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string"); |
121 fontspec = create_fontspec (f, s, gnuplot_term); | |
122 if (strcmpi (axis_obj.xaxislocation, "top")) | |
123 fprintf (plot_stream, "set x2label \"%s\" %s %s %s", | |
124 undo_string_escapes (tt), colorspec, fontspec, | |
125 __do_enhanced_option__ (enhanced, t)); | |
126 else | |
127 fprintf (plot_stream, "set xlabel \"%s\" %s %s %s", | |
128 undo_string_escapes (tt), colorspec, fontspec, | |
129 __do_enhanced_option__ (enhanced, t)); | |
130 endif | |
131 fprintf (plot_stream, " rotate by %f;\n", angle); | |
132 if (strcmpi (axis_obj.xaxislocation, "top")) | |
133 fprintf (plot_stream, "unset xlabel;\n"); | |
134 else | |
135 fprintf (plot_stream, "unset x2label;\n"); | |
136 endif | |
6405 | 137 endif |
138 endif | |
139 | |
140 if (! isempty (axis_obj.ylabel)) | |
141 t = get (axis_obj.ylabel); | |
6737 | 142 angle = t.rotation; |
7269 | 143 colorspec = get_text_colorspec (axis_obj.ycolor, mono); |
6405 | 144 if (isempty (t.string)) |
10549 | 145 fprintf (plot_stream, "unset ylabel;\n"); |
146 fprintf (plot_stream, "unset y2label;\n"); | |
6405 | 147 else |
10549 | 148 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string"); |
149 fontspec = create_fontspec (f, s, gnuplot_term); | |
150 if (strcmpi (axis_obj.yaxislocation, "right")) | |
151 fprintf (plot_stream, "set y2label \"%s\" %s %s %s", | |
152 undo_string_escapes (tt), colorspec, fontspec, | |
153 __do_enhanced_option__ (enhanced, t)); | |
154 else | |
155 fprintf (plot_stream, "set ylabel \"%s\" %s %s %s", | |
156 undo_string_escapes (tt), colorspec, fontspec, | |
157 __do_enhanced_option__ (enhanced, t)); | |
158 endif | |
159 fprintf (plot_stream, " rotate by %f;\n", angle); | |
160 if (strcmpi (axis_obj.yaxislocation, "right")) | |
161 fprintf (plot_stream, "unset ylabel;\n"); | |
162 else | |
163 fprintf (plot_stream, "unset y2label;\n"); | |
164 endif | |
6405 | 165 endif |
166 endif | |
167 | |
168 if (! isempty (axis_obj.zlabel)) | |
169 t = get (axis_obj.zlabel); | |
6737 | 170 angle = t.rotation; |
7269 | 171 colorspec = get_text_colorspec (axis_obj.zcolor, mono); |
6405 | 172 if (isempty (t.string)) |
10549 | 173 fputs (plot_stream, "unset zlabel;\n"); |
6405 | 174 else |
10549 | 175 [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string"); |
176 fontspec = create_fontspec (f, s, gnuplot_term); | |
177 fprintf (plot_stream, "set zlabel \"%s\" %s %s %s", | |
178 undo_string_escapes (tt), colorspec, fontspec, | |
179 __do_enhanced_option__ (enhanced, t)); | |
180 fprintf (plot_stream, " rotate by %f;\n", angle); | |
6405 | 181 endif |
182 endif | |
183 | |
6809 | 184 if (strcmpi (axis_obj.xaxislocation, "top")) |
185 xaxisloc = "x2"; | |
186 xaxisloc_using = "x2"; | |
187 else | |
188 xaxisloc = "x"; | |
189 xaxisloc_using = "x1"; | |
7321 | 190 if (strcmpi (axis_obj.xaxislocation, "zero")) |
10549 | 191 fputs (plot_stream, "set xzeroaxis;\n"); |
7321 | 192 endif |
6809 | 193 endif |
194 if (strcmpi (axis_obj.yaxislocation, "right")) | |
195 yaxisloc = "y2"; | |
196 yaxisloc_using = "y2"; | |
197 else | |
198 yaxisloc = "y"; | |
199 yaxisloc_using = "y1"; | |
7321 | 200 if (strcmpi (axis_obj.yaxislocation, "zero")) |
10549 | 201 fputs (plot_stream, "set yzeroaxis;\n"); |
7321 | 202 endif |
6809 | 203 endif |
204 | |
7274 | 205 have_grid = false; |
206 | |
6758 | 207 if (strcmpi (axis_obj.xgrid, "on")) |
7274 | 208 have_grid = true; |
6809 | 209 fprintf (plot_stream, "set grid %stics;\n", xaxisloc); |
6405 | 210 else |
6809 | 211 fprintf (plot_stream, "set grid no%stics;\n", xaxisloc); |
6405 | 212 endif |
213 | |
6758 | 214 if (strcmpi (axis_obj.ygrid, "on")) |
7274 | 215 have_grid = true; |
6809 | 216 fprintf (plot_stream, "set grid %stics;\n", yaxisloc); |
6405 | 217 else |
6809 | 218 fprintf (plot_stream, "set grid no%stics;\n", yaxisloc); |
6405 | 219 endif |
220 | |
6758 | 221 if (strcmpi (axis_obj.zgrid, "on")) |
7274 | 222 have_grid = true; |
6405 | 223 fputs (plot_stream, "set grid ztics;\n"); |
224 else | |
7085 | 225 fputs (plot_stream, "set grid noztics;\n"); |
6405 | 226 endif |
227 | |
6758 | 228 if (strcmpi (axis_obj.xminorgrid, "on")) |
7274 | 229 have_grid = true; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
230 if (strcmp (axis_obj.xscale, "log")) |
10549 | 231 m = 10; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
232 else |
10549 | 233 m = 5; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
234 endif |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
235 fprintf (plot_stream, "set m%stics %d;\n", xaxisloc, m); |
6809 | 236 fprintf (plot_stream, "set grid m%stics;\n", xaxisloc); |
6405 | 237 else |
6809 | 238 fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc); |
6405 | 239 endif |
240 | |
6758 | 241 if (strcmpi (axis_obj.yminorgrid, "on")) |
7274 | 242 have_grid = true; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
243 if (strcmp (axis_obj.yscale, "log")) |
10549 | 244 m = 10; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
245 else |
10549 | 246 m = 5; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
247 endif |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
248 fprintf (plot_stream, "set m%stics %d;\n", yaxisloc, m); |
6809 | 249 fprintf (plot_stream, "set grid m%stics;\n", yaxisloc); |
6405 | 250 else |
6809 | 251 fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc); |
6405 | 252 endif |
253 | |
6758 | 254 if (strcmpi (axis_obj.zminorgrid, "on")) |
7274 | 255 have_grid = true; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
256 if (strcmp (axis_obj.zscale, "log")) |
10549 | 257 m = 10; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
258 else |
10549 | 259 m = 5; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
260 endif |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
261 fprintf (plot_stream, "set mztics %d;\n", m); |
6405 | 262 fputs (plot_stream, "set grid mztics;\n"); |
263 else | |
264 fputs (plot_stream, "set grid nomztics;\n"); | |
265 endif | |
266 | |
7307 | 267 ## The grid front/back/layerdefault option also controls the |
268 ## appearance of tics, so it is used even if the grid is absent. | |
269 if (strcmpi (axis_obj.layer, "top")) | |
270 fputs (plot_stream, "set grid front;\n"); | |
9438
bac81ac76a57
__go_draw_axes__.m: also use layer property for plot border
John W. Eaton <jwe@octave.org>
parents:
9374
diff
changeset
|
271 fputs (plot_stream, "set border front;\n"); |
7307 | 272 else |
273 fputs (plot_stream, "set grid layerdefault;\n"); | |
9438
bac81ac76a57
__go_draw_axes__.m: also use layer property for plot border
John W. Eaton <jwe@octave.org>
parents:
9374
diff
changeset
|
274 ## FIXME -- the gnuplot help says that "layerdefault" should work |
bac81ac76a57
__go_draw_axes__.m: also use layer property for plot border
John W. Eaton <jwe@octave.org>
parents:
9374
diff
changeset
|
275 ## for set border too, but it fails for me with gnuplot 4.2.5. So |
bac81ac76a57
__go_draw_axes__.m: also use layer property for plot border
John W. Eaton <jwe@octave.org>
parents:
9374
diff
changeset
|
276 ## use "back" instead. |
bac81ac76a57
__go_draw_axes__.m: also use layer property for plot border
John W. Eaton <jwe@octave.org>
parents:
9374
diff
changeset
|
277 fputs (plot_stream, "set border back;\n"); |
7307 | 278 endif |
7297 | 279 if (! have_grid) |
280 fputs (plot_stream, "unset grid;\n"); | |
7274 | 281 endif |
282 | |
9257
ab952265ad06
__go_draw_axes__.m: Properly render TeX symbols for x11.
Ben Abbott <bpabbott@mac.com>
parents:
9191
diff
changeset
|
283 do_tics (axis_obj, plot_stream, ymirror, mono, gnuplot_term); |
6405 | 284 |
10451
348b26872fc8
Fix bug with logscale in combination with colorbar
Petr Mikulik <mikulik@physics.muni.cz>
parents:
10238
diff
changeset
|
285 fputs (plot_stream, "unset logscale;\n"); |
6758 | 286 xlogscale = strcmpi (axis_obj.xscale, "log"); |
10451
348b26872fc8
Fix bug with logscale in combination with colorbar
Petr Mikulik <mikulik@physics.muni.cz>
parents:
10238
diff
changeset
|
287 ylogscale = strcmpi (axis_obj.yscale, "log"); |
348b26872fc8
Fix bug with logscale in combination with colorbar
Petr Mikulik <mikulik@physics.muni.cz>
parents:
10238
diff
changeset
|
288 zlogscale = strcmpi (axis_obj.zscale, "log"); |
6405 | 289 if (xlogscale) |
6809 | 290 fprintf (plot_stream, "set logscale %s;\n", xaxisloc); |
6405 | 291 endif |
292 if (ylogscale) | |
6809 | 293 fprintf (plot_stream, "set logscale %s;\n", yaxisloc); |
6405 | 294 endif |
295 if (zlogscale) | |
296 fputs (plot_stream, "set logscale z;\n"); | |
297 endif | |
298 | |
6758 | 299 xautoscale = strcmpi (axis_obj.xlimmode, "auto"); |
300 yautoscale = strcmpi (axis_obj.ylimmode, "auto"); | |
301 zautoscale = strcmpi (axis_obj.zlimmode, "auto"); | |
7109 | 302 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
|
303 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
|
304 truecolor = false; |
6405 | 305 |
8360
32d9c0299e99
Set gnuplot two point clipping
David Bateman <dbateman@free.fr>
parents:
8354
diff
changeset
|
306 fputs (plot_stream, "set clip two;\n"); |
32d9c0299e99
Set gnuplot two point clipping
David Bateman <dbateman@free.fr>
parents:
8354
diff
changeset
|
307 |
6405 | 308 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
|
309 ## 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
|
310 ## 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
|
311 [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
|
312 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
|
313 kids = kids (sort (k)); |
6405 | 314 |
7316 | 315 if (nd == 3) |
316 fputs (plot_stream, "set parametric;\n"); | |
317 fputs (plot_stream, "set style data lines;\n"); | |
318 fputs (plot_stream, "set surface;\n"); | |
319 fputs (plot_stream, "unset contour;\n"); | |
320 endif | |
321 | |
6405 | 322 data_idx = 0; |
323 data = cell (); | |
6464 | 324 is_image_data = []; |
7175 | 325 hidden_removal = NaN; |
7271 | 326 view_map = false; |
6405 | 327 |
7223 | 328 xlim = axis_obj.xlim; |
329 ylim = axis_obj.ylim; | |
330 zlim = axis_obj.zlim; | |
331 clim = axis_obj.clim; | |
6405 | 332 |
7222 | 333 if (! cautoscale && clim(1) == clim(2)) |
334 clim(2)++; | |
7189 | 335 endif |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
336 addedcmap = []; |
7189 | 337 |
6405 | 338 [view_cmd, view_fcn, view_zoom] = image_viewer (); |
339 use_gnuplot_for_images = (ischar (view_fcn) | |
10549 | 340 && strcmpi (view_fcn, "gnuplot_internal")); |
6405 | 341 |
342 ximg_data = {}; | |
343 ximg_data_idx = 0; | |
344 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
345 while (! isempty (kids)) |
6405 | 346 |
8344
b5f10b123440
__go_draw_axes__.m: Correct order for rendering children.
Ben Abbott <bpabbott@mac.com>
parents:
8322
diff
changeset
|
347 obj = get (kids(end)); |
b5f10b123440
__go_draw_axes__.m: Correct order for rendering children.
Ben Abbott <bpabbott@mac.com>
parents:
8322
diff
changeset
|
348 kids = kids(1:(end-1)); |
6405 | 349 |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8171
diff
changeset
|
350 if (strcmpi (obj.visible, "off")) |
10549 | 351 continue; |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8048
diff
changeset
|
352 endif |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8048
diff
changeset
|
353 |
8171
15ffb9836c01
__go_draw_axes__.m: Remove depdenence on gnuplot version.
Ben Abbott <bpabbott@mac.com>
parents:
8166
diff
changeset
|
354 ## 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
|
355 doing_interp_color = ... |
15ffb9836c01
__go_draw_axes__.m: Remove depdenence on gnuplot version.
Ben Abbott <bpabbott@mac.com>
parents:
8166
diff
changeset
|
356 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
|
357 |
6405 | 358 switch (obj.type) |
10549 | 359 case "image" |
360 img_data = obj.cdata; | |
361 img_xdata = obj.xdata; | |
362 img_ydata = obj.ydata; | |
6405 | 363 |
10549 | 364 if (use_gnuplot_for_images) |
6405 | 365 |
10549 | 366 if (ndims (img_data) == 3) |
367 truecolor = true; | |
368 elseif (strcmpi (obj.cdatamapping, "direct")) | |
369 cdatadirect = true; | |
370 endif | |
371 data_idx++; | |
372 is_image_data(data_idx) = true; | |
373 parametric(data_idx) = false; | |
374 have_cdata(data_idx) = false; | |
375 have_3d_patch(data_idx) = false; | |
6405 | 376 |
10549 | 377 [y_dim, x_dim] = size (img_data(:,:,1)); |
378 if (x_dim > 1) | |
379 dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1); | |
380 else | |
381 x_dim = 2; | |
382 img_data = [img_data, img_data]; | |
383 dx = abs (img_xdata(2)-img_xdata(1)); | |
384 endif | |
385 if (y_dim > 1) | |
386 dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1); | |
387 else | |
388 y_dim = 2; | |
389 img_data = [img_data; img_data]; | |
390 dy = abs (img_ydata(2)-img_ydata(1)); | |
391 endif | |
392 x_origin = min (img_xdata); | |
393 y_origin = min (img_ydata); | |
6405 | 394 |
10549 | 395 if (ndims (img_data) == 3) |
396 data{data_idx} = permute (img_data, [3, 1, 2])(:); | |
397 format = "1:2:3"; | |
398 imagetype = "rgbimage"; | |
399 else | |
400 data{data_idx} = img_data(:); | |
401 format = "1"; | |
402 imagetype = "image"; | |
403 endif | |
6405 | 404 |
10549 | 405 titlespec{data_idx} = "title \"\""; |
406 usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s", | |
407 x_dim, y_dim, x_origin, y_origin, dx, dy, format); | |
408 withclause{data_idx} = sprintf ("with %s;", imagetype); | |
6405 | 409 |
10549 | 410 else |
411 ximg_data{++ximg_data_idx} = img_data; | |
412 endif | |
6405 | 413 |
10549 | 414 case "line" |
415 if (strncmp (obj.linestyle, "none", 4) | |
416 && (! isfield (obj, "marker") | |
417 || (isfield (obj, "marker") | |
418 && strncmp (obj.marker, "none", 4)))) | |
419 continue; | |
420 endif | |
421 data_idx++; | |
422 is_image_data(data_idx) = false; | |
423 parametric(data_idx) = true; | |
424 have_cdata(data_idx) = false; | |
425 have_3d_patch(data_idx) = false; | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
426 |
10549 | 427 if (isempty (obj.keylabel)) |
428 titlespec{data_idx} = "title \"\""; | |
429 else | |
430 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); | |
431 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); | |
432 endif | |
433 usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata)); | |
434 errbars = ""; | |
435 if (nd == 3) | |
436 xdat = obj.xdata(:); | |
437 ydat = obj.ydata(:); | |
438 if (! isempty (obj.zdata)) | |
439 zdat = obj.zdata(:); | |
440 else | |
441 zdat = zeros (size (xdat)); | |
442 endif | |
443 data{data_idx} = [xdat, ydat, zdat]'; | |
444 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", numel (xdat)); | |
445 ## fputs (plot_stream, "set parametric;\n"); | |
446 else | |
447 xdat = obj.xdata(:); | |
448 ydat = obj.ydata(:); | |
10597
ba346313bdc1
__go_draw_axes__.m: Remove gnuplot errorbar code.
Ben Abbott <bpabbott@mac.com>
parents:
10582
diff
changeset
|
449 data{data_idx} = [xdat, ydat]'; |
ba346313bdc1
__go_draw_axes__.m: Remove gnuplot errorbar code.
Ben Abbott <bpabbott@mac.com>
parents:
10582
diff
changeset
|
450 usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s", |
ba346313bdc1
__go_draw_axes__.m: Remove gnuplot errorbar code.
Ben Abbott <bpabbott@mac.com>
parents:
10582
diff
changeset
|
451 rows(xdat), xaxisloc_using, yaxisloc_using); |
10549 | 452 endif |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
453 |
10549 | 454 style = do_linestyle_command (obj, obj.color, data_idx, mono, |
455 plot_stream, errbars); | |
7510
f3e6ada67d9e
improve handling line style for errorbar plots
John W. Eaton <jwe@octave.org>
parents:
7472
diff
changeset
|
456 |
10111
b52cba8be2eb
Fix for markerfacecolor and markeredgecolor properties with unfillable markers like '+'
David Bateman <dbateman@free.fr>
parents:
10089
diff
changeset
|
457 withclause{data_idx} = sprintf ("with %s linestyle %d", |
10549 | 458 style{1}, data_idx); |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
459 |
10549 | 460 if (length (style) > 1) |
461 data_idx++; | |
462 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
463 parametric(data_idx) = parametric(data_idx - 1); | |
464 have_cdata(data_idx) = have_cdata(data_idx - 1); | |
465 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
466 titlespec{data_idx} = "title \"\""; | |
467 usingclause{data_idx} = usingclause{data_idx - 1}; | |
468 data{data_idx} = data{data_idx - 1}; | |
469 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
470 style{2}, data_idx); | |
471 endif | |
472 if (length (style) > 2) | |
473 data_idx++; | |
474 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
475 parametric(data_idx) = parametric(data_idx - 1); | |
476 have_cdata(data_idx) = have_cdata(data_idx - 1); | |
477 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
478 titlespec{data_idx} = "title \"\""; | |
479 usingclause{data_idx} = usingclause{data_idx - 1}; | |
480 data{data_idx} = data{data_idx - 1}; | |
481 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
482 style{3}, data_idx); | |
483 endif | |
6405 | 484 |
6790 | 485 case "patch" |
6885 | 486 cmap = parent_figure_obj.colormap; |
10549 | 487 [nr, nc] = size (obj.xdata); |
7189 | 488 |
10549 | 489 if (! isempty (obj.cdata)) |
490 cdat = obj.cdata; | |
491 if (strcmpi (obj.cdatamapping, "direct")) | |
492 cdatadirect = true; | |
493 endif | |
494 else | |
495 cdat = []; | |
496 endif | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
497 |
10549 | 498 data_3d_idx = NaN; |
499 for i = 1:nc | |
500 xcol = obj.xdata(:,i); | |
501 ycol = obj.ydata(:,i); | |
502 if (nd == 3) | |
503 if (! isempty (obj.zdata)) | |
504 zcol = obj.zdata(:,i); | |
505 else | |
506 zcol = zeros (size (xcol)); | |
507 endif | |
508 endif | |
509 | |
510 if (! isnan (xcol) && ! isnan (ycol)) | |
511 ## Is the patch closed or not | |
512 if (strncmp (obj.facecolor, "none", 4)) | |
513 hidden_removal = false; | |
514 else | |
7170 | 515 |
10549 | 516 if (isnan (hidden_removal)) |
517 hidden_removal = true; | |
518 endif | |
519 if (nd == 3) | |
520 if (numel (xcol) > 3) | |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10597
diff
changeset
|
521 error ("__go_draw_axes__: gnuplot (as of v4.2) only supports 3D filled triangular patches"); |
10549 | 522 else |
523 if (isnan (data_3d_idx)) | |
524 data_idx++; | |
525 data_3d_idx = data_idx; | |
526 is_image_data(data_idx) = false; | |
527 parametric(data_idx) = false; | |
528 have_cdata(data_idx) = true; | |
529 have_3d_patch(data_idx) = true; | |
530 withclause{data_3d_idx} = sprintf ("with pm3d"); | |
531 usingclause{data_3d_idx} = "using 1:2:3:4"; | |
532 data{data_3d_idx} = []; | |
533 endif | |
534 local_idx = data_3d_idx; | |
535 ccdat = NaN; | |
536 endif | |
7170 | 537 else |
10549 | 538 data_idx++; |
539 local_idx = data_idx; | |
540 is_image_data(data_idx) = false; | |
541 parametric(data_idx) = false; | |
542 have_cdata(data_idx) = false; | |
543 have_3d_patch(data_idx) = false; | |
7170 | 544 endif |
545 | |
10549 | 546 if (i > 1 || isempty (obj.keylabel)) |
547 titlespec{local_idx} = "title \"\""; | |
548 else | |
549 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); | |
550 titlespec{local_idx} = cstrcat ("title \"", tmp, "\""); | |
551 endif | |
552 if (isfield (obj, "facecolor")) | |
553 if ((strncmp (obj.facecolor, "flat", 4) | |
554 || strncmp (obj.facecolor, "interp", 6)) | |
555 && isfield (obj, "cdata")) | |
556 if (ndims (obj.cdata) == 2 | |
557 && (size (obj.cdata, 2) == nc | |
558 && (size (obj.cdata, 1) == 1 | |
559 || size (obj.cdata, 1) == 3))) | |
560 ccol = cdat (:, i); | |
561 elseif (ndims (obj.cdata) == 2 | |
562 && (size (obj.cdata, 1) == nc | |
563 && (size (obj.cdata, 2) == 1 | |
564 || size (obj.cdata, 2) == 3))) | |
565 ccol = cdat (i, :); | |
566 elseif (ndims (obj.cdata) == 3) | |
567 ccol = permute (cdat (:, i, :), [1, 3, 2]); | |
568 else | |
569 ccol = cdat; | |
570 endif | |
571 if (strncmp (obj.facecolor, "flat", 4)) | |
572 if (numel(ccol) == 3) | |
573 color = ccol; | |
574 elseif (nd == 3 && numel (xcol) == 3) | |
575 ccdat = ccol * ones (3,1); | |
576 else | |
577 r = 1 + round ((size (cmap, 1) - 1) | |
578 * (ccol - clim(1))/(clim(2) - clim(1))); | |
579 r = max (1, min (r, size (cmap, 1))); | |
580 color = cmap(r, :); | |
581 endif | |
582 elseif (strncmp (obj.facecolor, "interp", 6)) | |
583 if (nd == 3 && numel (xcol) == 3) | |
584 ccdat = ccol; | |
585 if (! isvector (ccdat)) | |
586 tmp = rows(cmap) + rows(addedcmap) + ... | |
587 [1 : rows(ccdat)]; | |
588 addedcmap = [addedcmap; ccdat]; | |
589 ccdat = tmp(:); | |
590 else | |
591 ccdat = ccdat(:); | |
592 endif | |
593 else | |
594 warning ("\"interp\" not supported, using 1st entry of cdata"); | |
595 r = 1 + round ((size (cmap, 1) - 1) * ccol(1)); | |
596 r = max (1, min (r, size (cmap, 1))); | |
597 color = cmap(r,:); | |
598 endif | |
599 endif | |
600 elseif (isnumeric (obj.facecolor)) | |
601 color = obj.facecolor; | |
602 else | |
603 color = [0, 1, 0]; | |
604 endif | |
605 else | |
606 color = [0, 1, 0]; | |
607 endif | |
608 | |
609 if (nd == 3 && numel (xcol) == 3) | |
610 if (isnan (ccdat)) | |
611 ccdat = (rows (cmap) + rows(addedcmap) + 1) * ones(3, 1); | |
612 addedcmap = [addedcmap; reshape(color, 1, 3)]; | |
613 endif | |
614 data{data_3d_idx} = [data{data_3d_idx}, ... | |
615 [[xcol; xcol(end)], [ycol; ycol(end)], ... | |
616 [zcol; zcol(end)], [ccdat; ccdat(end)]]']; | |
617 else | |
618 if (mono) | |
619 colorspec = ""; | |
620 elseif (__gnuplot_has_feature__ ("transparent_patches") | |
621 && isscalar (obj.facealpha)) | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
622 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\" fillstyle transparent solid %f", |
10549 | 623 round (255*color), obj.facealpha); |
624 else | |
625 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
626 round (255*color)); | |
627 endif | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
628 |
10549 | 629 withclause{data_idx} = sprintf ("with filledcurve %s", |
630 colorspec); | |
631 data{data_idx} = [xcol, ycol]'; | |
632 usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", | |
633 numel (xcol)); | |
634 endif | |
635 endif | |
636 endif | |
7170 | 637 |
638 ## patch outline | |
10549 | 639 if (!(strncmp (obj.edgecolor, "none", 4) |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
640 && strncmp (obj.markeredgecolor, "none", 4) |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
641 && strncmp (obj.markerfacecolor, "none", 4))) |
7170 | 642 |
10549 | 643 data_idx++; |
7170 | 644 is_image_data(data_idx) = false; |
645 parametric(data_idx) = false; | |
10549 | 646 have_cdata(data_idx) = false; |
647 have_3d_patch(data_idx) = false; | |
7170 | 648 titlespec{data_idx} = "title \"\""; |
10549 | 649 usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata)); |
7189 | 650 |
10549 | 651 if (isfield (obj, "markersize")) |
652 mdat = obj.markersize / 3; | |
653 endif | |
7189 | 654 |
655 if (isfield (obj, "edgecolor")) | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
656 ## FIXME |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
657 ## This is the wrong thing to do as edgecolor, markeredgecolor |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
658 ## and markerfacecolor can have different values and we should |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
659 ## treat them seperately. However, the below allow the scatter |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
660 ## functions to work as expected, where only one of these values |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
661 ## is set |
10549 | 662 if (strncmp (obj.edgecolor, "none", 4)) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
663 if (strncmp (obj.markeredgecolor, "none", 4)) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
664 ec = obj.markerfacecolor; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
665 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
666 ec = obj.markeredgecolor; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
667 endif |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
668 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
669 ec = obj.edgecolor; |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
670 endif |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10121
diff
changeset
|
671 |
10549 | 672 if ((strncmp (ec, "flat", 4) |
673 || strncmp (ec, "interp", 6)) | |
674 && isfield (obj, "cdata")) | |
675 if (ndims (obj.cdata) == 2 | |
676 && (size (obj.cdata, 2) == nc | |
677 && (size (obj.cdata, 1) == 1 | |
678 || size (obj.cdata, 1) == 3))) | |
679 ccol = cdat (:, i); | |
680 elseif (ndims (obj.cdata) == 2 | |
681 && (size (obj.cdata, 1) == nc | |
682 && (size (obj.cdata, 2) == 1 | |
683 || size (obj.cdata, 2) == 3))) | |
684 ccol = cdat (i, :); | |
685 elseif (ndims (obj.cdata) == 3) | |
686 ccol = permute (cdat (:, i, :), [1, 3, 2]); | |
687 else | |
688 ccol = cdat; | |
689 endif | |
690 if (strncmp (ec, "flat", 4)) | |
691 if (numel(ccol) == 3) | |
692 color = ccol; | |
693 else | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
694 if (isscalar (ccol)) |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
695 ccol = repmat(ccol, numel (xcol), 1); |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
696 endif |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
697 color = "flat"; |
10549 | 698 have_cdata(data_idx) = true; |
699 endif | |
700 elseif (strncmp (ec, "interp", 6)) | |
701 if (numel(ccol) == 3) | |
702 warning ("\"interp\" not supported, using 1st entry of cdata"); | |
703 color = ccol(1,:); | |
704 else | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
705 if (isscalar (ccol)) |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
706 ccol = repmat(ccol, numel (xcol), 1); |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
707 endif |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
708 color = "interp"; |
10549 | 709 have_cdata(data_idx) = true; |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
710 endif |
10549 | 711 endif |
712 elseif (isnumeric (ec)) | |
713 color = ec; | |
714 else | |
715 color = [0, 0, 0]; | |
716 endif | |
7020 | 717 else |
10549 | 718 color = [0, 0, 0]; |
719 endif | |
720 | |
721 if (isfield (obj, "linestyle")) | |
722 switch (obj.linestyle) | |
723 case "-" | |
724 lt = "lt 1"; | |
725 case "--" | |
726 lt = "lt 2"; | |
727 case ":" | |
728 lt = "lt 3"; | |
729 case "-." | |
730 lt = "lt 6"; | |
731 case "none" | |
732 lt = ""; | |
733 otherwise | |
734 lt = ""; | |
735 endswitch | |
736 else | |
737 lt = ""; | |
738 endif | |
739 | |
740 if (isfield (obj, "linewidth")) | |
741 lw = sprintf("linewidth %f", obj.linewidth); | |
742 else | |
743 lw = ""; | |
7020 | 744 endif |
7189 | 745 |
10549 | 746 if (isfield (obj, "marker")) |
747 if (isfield (obj, "marker")) | |
748 switch (obj.marker) | |
749 case "+" | |
750 pt = pt2 = "pt 1"; | |
751 case "o" | |
752 pt = "pt 6"; | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
753 pt2 = "pt 7"; |
10549 | 754 case "*" |
755 pt = pt2 = "pt 3"; | |
756 case "." | |
757 pt = pt2 = "pt 0"; | |
758 case "x" | |
759 pt = pt2 = "pt 2"; | |
760 case {"square", "s"} | |
761 pt = "pt 4"; | |
762 pt2 = "pt 5"; | |
763 case {"diamond", "d"} | |
10563
f5a652a101b0
Correct fill of diamond markers for gnuplot backend
David Bateman <dbateman@free.fr>
parents:
10561
diff
changeset
|
764 pt = "pt 12"; |
f5a652a101b0
Correct fill of diamond markers for gnuplot backend
David Bateman <dbateman@free.fr>
parents:
10561
diff
changeset
|
765 pt2 = "pt 13"; |
10549 | 766 case "^" |
767 pt = "pt 8"; | |
768 pt2 = "pt 9"; | |
769 case "v" | |
770 pt = "pt 10"; | |
771 pt2 = "pt 11"; | |
772 case ">" | |
773 ## FIXME missing point type | |
774 pt = "pt 8"; | |
775 pt2 = "pt 9"; | |
776 case "<" | |
777 ## FIXME missing point type | |
778 pt = "pt 10"; | |
779 pt2 = "pt 11"; | |
780 case {"pentagram", "p"} | |
781 ## FIXME missing point type | |
782 pt = pt2 = "pt 3"; | |
783 case {"hexagram", "h"} | |
784 pt = pt2 = "pt 3"; | |
785 case "none" | |
786 pt = pt2 = ""; | |
787 otherwise | |
788 pt = pt2 = ""; | |
789 endswitch | |
790 endif | |
791 else | |
792 pt = pt2 = ""; | |
793 endif | |
7189 | 794 |
10549 | 795 if (mono) |
796 colorspec = ""; | |
797 else | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
798 if (ischar (color)) |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
799 colorspec = "palette"; |
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
800 else |
10549 | 801 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", |
802 round (255*color)); | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
803 endif |
10549 | 804 endif |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
805 |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
806 sidx = 1; |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
807 if (isempty (lt)) |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
808 style = ""; |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
809 else |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
810 style = "lines"; |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
811 endif |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
812 tmpwith = {}; |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
813 |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
814 facesame = true; |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
815 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") |
10549 | 816 && !strncmp (obj.markerfacecolor, "none", 4)) |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
817 if (strncmp (obj.markerfacecolor, "auto", 4) |
10549 | 818 || ! isnumeric (obj.markerfacecolor) |
819 || (isnumeric (obj.markerfacecolor) | |
820 && isequal (color, obj.markerfacecolor))) | |
821 style = strcat (style, "points"); | |
822 if (isfield (obj, "markersize")) | |
823 if (length (mdat) == nc) | |
824 m = mdat(i); | |
825 else | |
826 m = mdat; | |
827 endif | |
828 ps = sprintf("pointsize %f", m / 3); | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
829 else |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
830 ps = ""; |
10549 | 831 endif |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
832 |
10549 | 833 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", |
834 style, lw, pt2, lt, ps, | |
835 colorspec); | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
836 else |
10549 | 837 facesame = false; |
838 if (! isempty (style)) | |
839 tmpwith{sidx} = sprintf ("with %s %s %s %s", | |
840 style, lw, lt, | |
841 colorspec); | |
842 sidx ++; | |
843 endif | |
844 if (isnumeric (obj.markerfacecolor) && ! mono) | |
845 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
846 round (255*obj.markerfacecolor)); | |
847 endif | |
848 style = "points"; | |
849 if (isfield (obj, "markersize")) | |
850 if (length (mdat) == nc) | |
851 m = mdat(i); | |
852 else | |
853 m = mdat; | |
854 endif | |
855 ps = sprintf("pointsize %f", m / 3); | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
856 else |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
857 ps = ""; |
10549 | 858 endif |
859 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", | |
860 style, lw, pt2, lt, ps, | |
861 colorspec); | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
862 endif |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
863 endif |
6790 | 864 |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
865 if (isfield (obj, "markeredgecolor") |
10549 | 866 && !strncmp (obj.markeredgecolor, "none", 4)) |
10137
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
867 if (facesame && !isempty (pt) |
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
868 && (strncmp (obj.markeredgecolor, "auto", 4) |
10549 | 869 || ! isnumeric (obj.markeredgecolor) |
870 || (isnumeric (obj.markeredgecolor) | |
871 && isequal (color, obj.markeredgecolor)))) | |
872 if (sidx == 1 && ((length (style) == 5 | |
873 && strncmp (style, "lines", 5)) | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
874 || isempty (style))) |
10549 | 875 style = strcat (style, "points"); |
876 if (isfield (obj, "markersize")) | |
877 if (length (mdat) == nc) | |
878 m = mdat(i); | |
879 else | |
880 m = mdat; | |
881 endif | |
882 ps = sprintf("pointsize %f", m / 3); | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
883 else |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
884 ps = ""; |
10549 | 885 endif |
886 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", | |
887 style, lw, pt, lt, ps, | |
888 colorspec); | |
889 endif | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
890 else |
10549 | 891 if (!isempty (style)) |
10137
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
892 if (length(tmpwith) < sidx || isempty (tmpwith{sidx})) |
10549 | 893 tmpwith{sidx} = sprintf ("with %s %s %s %s", |
894 style, lw, lt, | |
895 colorspec); | |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
896 endif |
10549 | 897 sidx ++; |
898 endif | |
10137
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
899 |
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
900 if (!isempty (pt)) |
10549 | 901 if (! mono) |
902 if (strncmp (obj.markeredgecolor, "auto", 4)) | |
903 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
904 round (255*color)); | |
905 elseif (isnumeric (obj.markeredgecolor) && ! mono) | |
906 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", | |
907 round (255*obj.markeredgecolor)); | |
908 endif | |
909 endif | |
910 style = "points"; | |
911 if (isfield (obj, "markersize")) | |
912 if (length (mdat) == nc) | |
913 m = mdat(i); | |
914 else | |
915 m = mdat; | |
916 endif | |
917 ps = sprintf("pointsize %f", m / 3); | |
10137
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
918 else |
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
919 ps = ""; |
10549 | 920 endif |
921 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s", | |
922 style, lw, pt, lt, ps, | |
923 colorspec); | |
10137
cf6a01e0e93f
Fix unrequested markers for patch objects
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
924 endif |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
925 endif |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
926 endif |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
927 |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
928 if (isempty (tmpwith)) |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
929 withclause{data_idx} = sprintf ("with %s %s %s %s %s", |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
930 style, lw, pt, lt, |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
931 colorspec); |
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
932 else |
10549 | 933 withclause{data_idx} = tmpwith{1}; |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
934 endif |
10549 | 935 if (nd == 3) |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
936 if (ischar (color)) |
10549 | 937 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) |
938 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... | |
939 [zcol; zcol(1)], [ccol; ccol(1)]]'; | |
940 else | |
941 data{data_idx} = [xcol, ycol, zcol, ccol]'; | |
942 endif | |
943 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", columns (data{data_idx})); | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
944 else |
10549 | 945 if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol)) |
946 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... | |
947 [zcol; zcol(1)]]'; | |
948 else | |
949 data{data_idx} = [xcol, ycol, zcol]'; | |
950 endif | |
951 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx})); | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
952 endif |
10549 | 953 else |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
954 if (ischar (color)) |
10549 | 955 if (! isnan (xcol) && ! isnan (ycol)) |
956 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ... | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
957 [ccol; ccol(1)]]'; |
10549 | 958 else |
959 data{data_idx} = [xcol, ycol, ccol]'; | |
960 endif | |
961 usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx})); | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
962 else |
10549 | 963 if (! isnan (xcol) && ! isnan (ycol)) |
964 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]'; | |
965 else | |
966 data{data_idx} = [xcol, ycol]'; | |
967 endif | |
968 usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx})); | |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10226
diff
changeset
|
969 endif |
10549 | 970 endif |
10089
dd70982c81a3
Allow markerfacecolor and markeredgecolor to be set and used for patch objects
David Bateman <dbateman@free.fr>
parents:
9793
diff
changeset
|
971 |
10549 | 972 if (length (tmpwith) > 1) |
973 data_idx++; | |
974 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
975 parametric(data_idx) = parametric(data_idx - 1); | |
976 have_cdata(data_idx) = have_cdata(data_idx - 1); | |
977 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
978 titlespec{data_idx} = "title \"\""; | |
979 usingclause{data_idx} = usingclause{data_idx - 1}; | |
980 data{data_idx} = data{data_idx - 1}; | |
981 withclause{data_idx} = tmpwith{2}; | |
982 endif | |
983 if (length (tmpwith) > 2) | |
984 data_idx++; | |
985 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
986 parametric(data_idx) = parametric(data_idx - 1); | |
987 have_cdata(data_idx) = have_cdata(data_idx - 1); | |
988 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
989 titlespec{data_idx} = "title \"\""; | |
990 usingclause{data_idx} = usingclause{data_idx - 1}; | |
991 data{data_idx} = data{data_idx - 1}; | |
992 withclause{data_idx} = tmpwith{3}; | |
993 endif | |
994 endif | |
995 endfor | |
6790 | 996 |
10549 | 997 case "surface" |
998 view_map = true; | |
7110 | 999 if (! (strncmp (obj.edgecolor, "none", 4) |
10549 | 1000 && strncmp (obj.facecolor, "none", 4))) |
1001 data_idx++; | |
1002 is_image_data(data_idx) = false; | |
1003 parametric(data_idx) = false; | |
1004 have_cdata(data_idx) = true; | |
1005 have_3d_patch(data_idx) = false; | |
1006 style = do_linestyle_command (obj, obj.edgecolor, | |
1007 data_idx, mono, | |
1008 plot_stream); | |
1009 if (isempty (obj.keylabel)) | |
1010 titlespec{data_idx} = "title \"\""; | |
1011 else | |
1012 tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel")); | |
1013 titlespec{data_idx} = cstrcat ("title \"", tmp, "\""); | |
1014 endif | |
1015 withclause{data_idx} = sprintf ("with pm3d linestyle %d", | |
1016 data_idx); | |
1017 withpm3d = true; | |
1018 pm3didx = data_idx; | |
7109 | 1019 |
10549 | 1020 xdat = obj.xdata; |
1021 ydat = obj.ydata; | |
1022 zdat = obj.zdata; | |
1023 cdat = obj.cdata; | |
7110 | 1024 |
10549 | 1025 err = false; |
7109 | 1026 if (! size_equal(zdat, cdat)) |
6405 | 1027 err = true; |
7109 | 1028 endif |
10549 | 1029 if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) |
1030 if (rows (zdat) == length (ydat) | |
1031 && columns (zdat) == length (xdat)) | |
7109 | 1032 [xdat, ydat] = meshgrid (xdat, ydat); |
10549 | 1033 else |
7109 | 1034 err = true; |
10549 | 1035 endif |
1036 elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat)) | |
1037 if (! size_equal (xdat, ydat, zdat)) | |
7109 | 1038 err = true; |
10549 | 1039 endif |
1040 else | |
1041 err = true; | |
1042 endif | |
1043 if (err) | |
1044 error ("__go_draw_axes__: invalid grid data"); | |
1045 endif | |
1046 xlen = columns (zdat); | |
1047 ylen = rows (zdat); | |
1048 if (xlen == columns (xdat) && xlen == columns (ydat) | |
1049 && ylen == rows (xdat) && ylen == rows (ydat)) | |
1050 len = 4 * xlen; | |
1051 zz = zeros (ylen, len); | |
1052 k = 1; | |
1053 for kk = 1:4:len | |
1054 zz(:,kk) = xdat(:,k); | |
1055 zz(:,kk+1) = ydat(:,k); | |
1056 zz(:,kk+2) = zdat(:,k); | |
1057 zz(:,kk+3) = cdat(:,k); | |
1058 k++; | |
1059 endfor | |
1060 data{data_idx} = zz.'; | |
1061 endif | |
7109 | 1062 |
10549 | 1063 if (doing_interp_color) |
1064 interp_str = "interpolate 0, 0"; | |
1065 else | |
1066 ## No interpolation of facecolors. | |
1067 interp_str = ""; | |
1068 endif | |
1069 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
|
1070 |
7119 | 1071 flat_interp_face = (strncmp (obj.facecolor, "flat", 4) |
10549 | 1072 || strncmp (obj.facecolor, "interp", 6)); |
7119 | 1073 flat_interp_edge = (strncmp (obj.edgecolor, "flat", 4) |
10549 | 1074 || strncmp (obj.edgecolor, "interp", 6)); |
7154 | 1075 |
10549 | 1076 facecolor_none_or_white = (strncmp (obj.facecolor, "none", 4) |
1077 || (isnumeric (obj.facecolor) | |
1078 && all (obj.facecolor == 1))); | |
1079 hidden_removal = false; | |
7592 | 1080 fputs (plot_stream, "set style increment default;\n"); |
7318 | 1081 if (flat_interp_edge && facecolor_none_or_white) |
10549 | 1082 withpm3d = false; |
1083 withclause{data_idx} = sprintf ("with %s palette", style {1}); | |
1084 fputs (plot_stream, "unset pm3d\n"); | |
1085 if (all (obj.facecolor == 1)) | |
7592 | 1086 hidden_removal = true; |
7582 | 1087 endif |
10549 | 1088 elseif (facecolor_none_or_white) |
1089 if (all (obj.facecolor == 1)) | |
8164
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
1090 hidden_removal = true; |
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
1091 endif |
10549 | 1092 fputs(plot_stream,"unset pm3d;\n"); |
1093 fputs(plot_stream,"set style increment user;\n"); | |
1094 withpm3d = false; | |
1095 withclause{data_idx} = sprintf("with %s linestyle %d", | |
1096 style{1}, data_idx); | |
1097 fputs (plot_stream, "unset pm3d\n"); | |
7119 | 1098 endif |
7109 | 1099 |
10549 | 1100 if (doing_interp_color) |
1101 ## "depthorder" interferes with interpolation of colors. | |
1102 dord = "scansautomatic"; | |
1103 else | |
1104 dord = "depthorder"; | |
1105 endif | |
7109 | 1106 |
10549 | 1107 if (flat_interp_face && strncmp (obj.edgecolor, "flat", 4)) |
7318 | 1108 fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", |
10549 | 1109 interp_str, dord); |
7318 | 1110 elseif (!facecolor_none_or_white) |
7119 | 1111 if (strncmp (obj.edgecolor, "none", 4)) |
8645 | 1112 if (__gnuplot_has_feature__ ("transparent_surface") |
1113 && isscalar (obj.facealpha)) | |
1114 fprintf (plot_stream, | |
1115 "set style fill transparent solid %f;\n", | |
1116 obj.facealpha); | |
1117 endif | |
7318 | 1118 fprintf (plot_stream, "set pm3d explicit at s %s corners2color c3;\n", |
10549 | 1119 interp_str, dord); |
7109 | 1120 else |
7318 | 1121 fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", |
10549 | 1122 data_idx, interp_str, dord); |
7119 | 1123 |
8645 | 1124 if (__gnuplot_has_feature__ ("transparent_surface") |
1125 && isscalar (obj.facealpha)) | |
1126 fprintf (plot_stream, | |
1127 "set style fill transparent solid %f;\n", | |
1128 obj.facealpha); | |
1129 endif | |
7109 | 1130 endif |
7119 | 1131 endif |
10549 | 1132 |
1133 zz = []; | |
1134 if (length (style) > 1) | |
1135 len = 3 * xlen; | |
1136 zz = zeros (ylen, len); | |
1137 k = 1; | |
1138 for kk = 1:3:len | |
1139 zz(:,kk) = xdat(:,k); | |
1140 zz(:,kk+1) = ydat(:,k); | |
1141 zz(:,kk+2) = zdat(:,k); | |
1142 k++; | |
1143 endfor | |
1144 zz = zz.'; | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1145 |
10549 | 1146 data_idx++; |
1147 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
1148 parametric(data_idx) = parametric(data_idx - 1); | |
1149 have_cdata(data_idx) = false; | |
1150 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
1151 titlespec{data_idx} = "title \"\""; | |
1152 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); | |
1153 data{data_idx} = zz; | |
1154 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
1155 style{2}, data_idx); | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1156 |
10549 | 1157 endif |
1158 if (length (style) > 2) | |
1159 data_idx++; | |
1160 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
1161 parametric(data_idx) = parametric(data_idx - 1); | |
1162 have_cdata(data_idx) = false; | |
1163 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
1164 titlespec{data_idx} = "title \"\""; | |
1165 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); | |
1166 data{data_idx} = zz; | |
1167 withclause{data_idx} = sprintf ("with %s linestyle %d", | |
1168 style{3}, data_idx); | |
1169 endif | |
1170 if (withpm3d && strncmp (style {1}, "linespoints", 11)) | |
1171 if (isempty(zz)) | |
1172 len = 3 * xlen; | |
1173 zz = zeros (ylen, len); | |
1174 k = 1; | |
1175 for kk = 1:3:len | |
1176 zz(:,kk) = xdat(:,k); | |
1177 zz(:,kk+1) = ydat(:,k); | |
1178 zz(:,kk+2) = zdat(:,k); | |
1179 k++; | |
1180 endfor | |
1181 zz = zz.'; | |
1182 endif | |
1183 data_idx++; | |
1184 is_image_data(data_idx) = is_image_data(data_idx - 1); | |
1185 parametric(data_idx) = parametric(data_idx - 1); | |
1186 have_cdata(data_idx) = false; | |
1187 have_3d_patch(data_idx) = have_3d_patch(data_idx - 1); | |
1188 titlespec{data_idx} = "title \"\""; | |
1189 usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen); | |
1190 data{data_idx} = zz; | |
1191 withclause{data_idx} = sprintf ("with points linestyle %d", | |
1192 pm3didx); | |
1193 endif | |
1194 endif | |
6405 | 1195 |
10549 | 1196 case "text" |
1197 [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string"); | |
1198 fontspec = create_fontspec (f, s, gnuplot_term); | |
1199 lpos = obj.position; | |
1200 halign = obj.horizontalalignment; | |
1201 angle = obj.rotation; | |
6752 | 1202 units = obj.units; |
10549 | 1203 color = obj.color; |
6758 | 1204 if (strcmpi (units, "normalized")) |
6752 | 1205 units = "graph"; |
1206 else | |
1207 units = ""; | |
1208 endif | |
10549 | 1209 |
1210 if (isnumeric (color)) | |
1211 colorspec = get_text_colorspec (color, mono); | |
1212 endif | |
6829 | 1213 |
10549 | 1214 if (nd == 3) |
1215 fprintf (plot_stream, | |
1216 "set label \"%s\" at %s %.15g,%.15g,%.15g %s rotate by %f %s %s front %s;\n", | |
1217 undo_string_escapes (label), units, lpos(1), | |
1218 lpos(2), lpos(3), halign, angle, fontspec, | |
1219 __do_enhanced_option__ (enhanced, obj), colorspec); | |
1220 else | |
1221 fprintf (plot_stream, | |
1222 "set label \"%s\" at %s %.15g,%.15g %s rotate by %f %s %s front %s;\n", | |
1223 undo_string_escapes (label), units, | |
1224 lpos(1), lpos(2), halign, angle, fontspec, | |
1225 __do_enhanced_option__ (enhanced, obj), colorspec); | |
1226 endif | |
6405 | 1227 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1228 case "hggroup" |
10549 | 1229 ## Push group children into the kid list. |
1230 if (isempty (kids)) | |
1231 kids = obj.children; | |
1232 elseif (! isempty (obj.children)) | |
1233 kids = [kids; obj.children]; | |
1234 endif | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1235 |
10549 | 1236 otherwise |
1237 error ("__go_draw_axes__: unknown object class, %s", | |
1238 obj.type); | |
6405 | 1239 endswitch |
1240 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1241 endwhile |
6405 | 1242 |
7692
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1243 ## This is need to prevent warnings for rotations in 3D plots, while |
8506 | 1244 ## 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
|
1245 if (nd == 2 || (data_idx > 1 && !view_map)) |
7692
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1246 fputs (plot_stream, "set pm3d implicit;\n"); |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1247 else |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1248 fputs (plot_stream, "set pm3d explicit;\n"); |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1249 endif |
da1f4bc7cbe8
Conditionally set 'set pm3d implicit'
David Bateman <dbateman@free.fr>
parents:
7676
diff
changeset
|
1250 |
7175 | 1251 if (isnan(hidden_removal) || hidden_removal) |
7149 | 1252 fputs (plot_stream, "set hidden3d;\n"); |
1253 else | |
1254 fputs (plot_stream, "unset hidden3d;\n"); | |
1255 endif | |
1256 | |
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
|
1257 have_data = (! (isempty (data) || all (cellfun (@isempty, data)))); |
6405 | 1258 |
8208 | 1259 ## Note we don't use the [xy]2range of gnuplot as we don't use the |
8506 | 1260 ## dual axis plotting features of gnuplot. |
7222 | 1261 if (isempty (xlim)) |
1262 return; | |
6405 | 1263 endif |
6758 | 1264 if (strcmpi (axis_obj.xdir, "reverse")) |
6405 | 1265 xdir = "reverse"; |
1266 else | |
1267 xdir = "noreverse"; | |
1268 endif | |
8208 | 1269 fprintf (plot_stream, "set xrange [%.15e:%.15e] %s;\n", xlim, xdir); |
9281
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
1270 if (strcmpi (axis_obj.xaxislocation, "top")) |
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
1271 fprintf (plot_stream, "set x2range [%.15e:%.15e] %s;\n", xlim, xdir); |
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
1272 endif |
6405 | 1273 |
7222 | 1274 if (isempty (ylim)) |
1275 return; | |
6405 | 1276 endif |
6758 | 1277 if (strcmpi (axis_obj.ydir, "reverse")) |
6405 | 1278 ydir = "reverse"; |
1279 else | |
1280 ydir = "noreverse"; | |
1281 endif | |
8208 | 1282 fprintf (plot_stream, "set yrange [%.15e:%.15e] %s;\n", ylim, ydir); |
9281
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
1283 if (strcmpi (axis_obj.yaxislocation, "right")) |
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
1284 fprintf (plot_stream, "set y2range [%.15e:%.15e] %s;\n", ylim, ydir); |
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
1285 endif |
6405 | 1286 |
7119 | 1287 if (nd == 3) |
7222 | 1288 if (isempty (zlim)) |
10549 | 1289 return; |
6405 | 1290 endif |
6758 | 1291 if (strcmpi (axis_obj.zdir, "reverse")) |
10549 | 1292 zdir = "reverse"; |
6405 | 1293 else |
10549 | 1294 zdir = "noreverse"; |
6405 | 1295 endif |
8171
15ffb9836c01
__go_draw_axes__.m: Remove depdenence on gnuplot version.
Ben Abbott <bpabbott@mac.com>
parents:
8166
diff
changeset
|
1296 fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); |
6405 | 1297 endif |
7110 | 1298 |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1299 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
|
1300 cmap_sz = rows(cmap); |
7189 | 1301 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
|
1302 if (truecolor || ! cdatadirect) |
10549 | 1303 if (rows(addedcmap) > 0) |
1304 for i = 1:data_idx | |
1305 if (have_3d_patch(i)) | |
1306 data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz; | |
1307 endif | |
1308 endfor | |
1309 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim(1), clim(2) * | |
1310 (cmap_sz + rows(addedcmap)) / cmap_sz); | |
1311 else | |
1312 fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); | |
1313 endif | |
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
|
1314 else |
10549 | 1315 fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz + |
1316 rows (addedcmap)); | |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7462
diff
changeset
|
1317 endif |
7189 | 1318 endif |
1319 | |
6758 | 1320 if (strcmpi (axis_obj.box, "on")) |
7119 | 1321 if (nd == 3) |
10549 | 1322 fputs (plot_stream, "set border 4095;\n"); |
6405 | 1323 else |
10549 | 1324 fputs (plot_stream, "set border 431;\n"); |
6405 | 1325 endif |
1326 else | |
7119 | 1327 if (nd == 3) |
10549 | 1328 fputs (plot_stream, "set border 895;\n"); |
6405 | 1329 else |
10549 | 1330 if (strcmpi (axis_obj.yaxislocation, "right")) |
1331 fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n", | |
1332 axis_obj.tickdir); | |
1333 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1334 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", | |
1335 axis_obj.tickdir); | |
1336 fputs (plot_stream, "set border 12;\n"); | |
1337 else | |
1338 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", | |
1339 axis_obj.tickdir); | |
1340 fputs (plot_stream, "set border 9;\n"); | |
1341 endif | |
1342 else | |
1343 fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n", | |
1344 axis_obj.tickdir); | |
1345 if (strcmpi (axis_obj.xaxislocation, "top")) | |
1346 fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n", | |
1347 axis_obj.tickdir); | |
1348 fputs (plot_stream, "set border 6;\n"); | |
1349 else | |
1350 fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n", | |
1351 axis_obj.tickdir); | |
1352 fputs (plot_stream, "set border 3;\n"); | |
1353 endif | |
1354 endif | |
6405 | 1355 endif |
1356 endif | |
1357 | |
7060 | 1358 if (strcmpi (axis_obj.visible, "off")) |
1359 fputs (plot_stream, "unset border; unset tics\n"); | |
7565
1e6443ff960f
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
7564
diff
changeset
|
1360 else |
1e6443ff960f
handle axes linewidth property
John W. Eaton <jwe@octave.org>
parents:
7564
diff
changeset
|
1361 fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth); |
7060 | 1362 endif |
1363 | |
6758 | 1364 if (strcmpi (axis_obj.key, "on")) |
1365 if (strcmpi (axis_obj.keybox, "on")) | |
10549 | 1366 box = "box"; |
6405 | 1367 else |
10549 | 1368 box = "nobox"; |
6405 | 1369 endif |
8291
53f35799b235
Add support for left/right argument to the legend function
David Bateman <dbateman@free.fr>
parents:
8242
diff
changeset
|
1370 if (strcmpi (axis_obj.keyreverse, "on")) |
10549 | 1371 reverse = "reverse"; |
8291
53f35799b235
Add support for left/right argument to the legend function
David Bateman <dbateman@free.fr>
parents:
8242
diff
changeset
|
1372 else |
10549 | 1373 reverse = "noreverse"; |
8291
53f35799b235
Add support for left/right argument to the legend function
David Bateman <dbateman@free.fr>
parents:
8242
diff
changeset
|
1374 endif |
6405 | 1375 inout = "inside"; |
6977 | 1376 keypos = axis_obj.keypos; |
1377 if (ischar (keypos)) | |
10549 | 1378 keypos = lower (keypos); |
1379 keyout = findstr (keypos, "outside"); | |
1380 if (! isempty (keyout)) | |
1381 inout = "outside"; | |
1382 keypos = keypos(1:keyout-1); | |
1383 endif | |
6977 | 1384 endif |
1385 switch (keypos) | |
10549 | 1386 case -1 |
1387 pos = "right top"; | |
1388 inout = "outside"; | |
1389 case 1 | |
1390 pos = "right top"; | |
1391 case 2 | |
1392 pos = "left top"; | |
1393 case 3 | |
1394 pos = "left bottom"; | |
1395 case {4, 0} | |
1396 pos = "right bottom"; | |
1397 case "north" | |
1398 pos = "center top"; | |
1399 case "south" | |
1400 pos = "center bottom"; | |
1401 case "east" | |
1402 pos = "right center"; | |
1403 case "west" | |
1404 pos = "left center"; | |
1405 case "northeast" | |
1406 pos = "right top"; | |
1407 case "northwest" | |
1408 pos = "left top"; | |
1409 case "southeast" | |
1410 pos = "right bottom"; | |
1411 case "southwest" | |
1412 pos = "left bottom"; | |
1413 case "best" | |
1414 pos = ""; | |
1415 warning ("legend: 'Best' not yet implemented for location specifier.\n"); | |
1416 ## Least conflict with data in plot. | |
1417 ## Least unused space outside plot. | |
1418 otherwise | |
1419 pos = ""; | |
6405 | 1420 endswitch |
9191
ad33527d2e51
Have 'legend' inherit font properties from the parent axis.
Ben Abbott <bpabbott@mac.com>
parents:
9110
diff
changeset
|
1421 if (__gnuplot_has_feature__ ("key_has_font_properties")) |
9257
ab952265ad06
__go_draw_axes__.m: Properly render TeX symbols for x11.
Ben Abbott <bpabbott@mac.com>
parents:
9191
diff
changeset
|
1422 fontspec = create_fontspec (axis_obj.fontname, axis_obj.fontsize, gnuplot_term); |
9191
ad33527d2e51
Have 'legend' inherit font properties from the parent axis.
Ben Abbott <bpabbott@mac.com>
parents:
9110
diff
changeset
|
1423 else |
10549 | 1424 fontspec = ""; |
9191
ad33527d2e51
Have 'legend' inherit font properties from the parent axis.
Ben Abbott <bpabbott@mac.com>
parents:
9110
diff
changeset
|
1425 endif |
ad33527d2e51
Have 'legend' inherit font properties from the parent axis.
Ben Abbott <bpabbott@mac.com>
parents:
9110
diff
changeset
|
1426 fprintf (plot_stream, "set key %s %s %s %s %s;\n", inout, pos, box, |
ad33527d2e51
Have 'legend' inherit font properties from the parent axis.
Ben Abbott <bpabbott@mac.com>
parents:
9110
diff
changeset
|
1427 reverse, fontspec); |
6405 | 1428 else |
1429 fputs (plot_stream, "unset key;\n"); | |
1430 endif | |
1431 | |
1432 fputs (plot_stream, "set style data lines;\n"); | |
1433 | |
1434 if (! use_gnuplot_for_images) | |
1435 for i = 1:ximg_data_idx | |
10549 | 1436 view_fcn (xlim, ylim, ximg_data{i}, view_zoom, view_cmd); |
6405 | 1437 endfor |
1438 endif | |
1439 | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
1440 cmap = [cmap; addedcmap]; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
1441 cmap_sz = cmap_sz + rows(addedcmap); |
7189 | 1442 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
|
1443 fprintf (plot_stream, |
10549 | 1444 "set palette positive color model RGB maxcolors %i;\n", |
1445 cmap_sz); | |
8164
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
1446 fprintf (plot_stream, |
10549 | 1447 "set palette file \"-\" binary record=%d using 1:2:3:4;\n", |
1448 cmap_sz); | |
8164
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
1449 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
|
1450 fwrite (plot_stream, "\n"); |
7189 | 1451 endif |
8208 | 1452 |
1453 fputs (plot_stream, "unset colorbox;\n"); | |
7189 | 1454 |
6405 | 1455 if (have_data) |
1456 if (nd == 2) | |
10549 | 1457 plot_cmd = "plot"; |
6405 | 1458 else |
10549 | 1459 plot_cmd = "splot"; |
1460 rot_x = 90 - axis_obj.view(2); | |
1461 rot_z = axis_obj.view(1); | |
1462 while (rot_z < 0) | |
1463 rot_z += 360; | |
1464 endwhile | |
1465 fputs (plot_stream, "set ticslevel 0;\n"); | |
1466 if (view_map && rot_x == 0 && rot_z == 0) | |
1467 fputs (plot_stream, "set view map;\n"); | |
1468 else | |
1469 fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z); | |
1470 endif | |
6405 | 1471 endif |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
1472 if (have_3d_patch (1)) |
10549 | 1473 fputs (plot_stream, "set pm3d depthorder\n"); |
1474 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, | |
1475 usingclause{1}, titlespec{1}, withclause{1}); | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
1476 elseif (is_image_data (1)) |
10549 | 1477 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
1478 usingclause{1}, titlespec{1}, withclause{1}); | |
8226
50fa927b4e49
Fix for images with new gnuplot/binary transfer code
David Bateman <dbateman@free.fr>
parents:
8222
diff
changeset
|
1479 else |
10549 | 1480 fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n", plot_cmd, |
1481 usingclause{1}, titlespec{1}, withclause{1}); | |
8226
50fa927b4e49
Fix for images with new gnuplot/binary transfer code
David Bateman <dbateman@free.fr>
parents:
8222
diff
changeset
|
1482 endif |
6405 | 1483 for i = 2:data_idx |
10549 | 1484 if (have_3d_patch (i)) |
1485 fprintf (plot_stream, ", \"-\" %s %s %s \\\n", | |
1486 usingclause{i}, titlespec{i}, withclause{i}); | |
1487 elseif (is_image_data (i)) | |
1488 if (! is_image_data (i-1)) | |
1489 fputs (plot_stream, "; "); | |
10528
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1490 if (bg_is_set) |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1491 fputs (plot_stream, "unset obj 1; \\\n"); |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1492 bg_is_set = false; |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1493 endif |
10549 | 1494 endif |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9098
diff
changeset
|
1495 fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd, |
10549 | 1496 usingclause{i}, titlespec{i}, withclause{i}); |
1497 elseif (is_image_data (i-1)) | |
10528
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1498 if (bg_is_set) |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1499 fputs (plot_stream, "unset obj 1; \\\n"); |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1500 bg_is_set = false; |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1501 endif |
10549 | 1502 fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n", plot_cmd, |
1503 usingclause{i}, titlespec{i}, withclause{i}); | |
1504 else | |
1505 fprintf (plot_stream, ", \"-\" binary format='%%float64' %s %s %s \\\n", | |
1506 usingclause{i}, titlespec{i}, withclause{i}); | |
1507 endif | |
6405 | 1508 endfor |
1509 fputs (plot_stream, ";\n"); | |
1510 for i = 1:data_idx | |
10549 | 1511 if (have_3d_patch (i)) |
1512 ## Can't write 3d patch data as binary as can't plot more than | |
1513 ## a single patch at a time and have to plot all patches together | |
1514 ## so that the gnuplot depth ordering is done correctly | |
1515 for j = 1 : 4 : columns(data{i}) | |
1516 if (j != 1) | |
1517 fputs (plot_stream, "\n\n"); | |
1518 endif | |
1519 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j).'); | |
1520 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n\n", data{i}(:,j+1).'); | |
1521 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+2).'); | |
1522 fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+3).'); | |
1523 endfor | |
1524 fputs (plot_stream, "e\n"); | |
1525 elseif (is_image_data(i)) | |
1526 fwrite (plot_stream, data{i}, "float32"); | |
1527 else | |
1528 __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i), | |
1529 have_cdata(i)); | |
1530 endif | |
6405 | 1531 endfor |
6431 | 1532 else |
1533 fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n"); | |
6405 | 1534 endif |
1535 | |
8506 | 1536 ## Needed to allow mouse rotation with pcolor. |
7271 | 1537 if (view_map) |
1538 fputs (plot_stream, "unset view;\n"); | |
1539 endif | |
10528
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1540 |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1541 if (bg_is_set) |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1542 fputs (plot_stream, "unset obj 1;\n"); |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1543 bg_is_set = false; |
6a2e4e464d38
Unset figure color in __go_draw_axes__ (partial fix for bug #29060)
David Bateman <dbateman@free.fr>
parents:
10451
diff
changeset
|
1544 endif |
7271 | 1545 |
6405 | 1546 fflush (plot_stream); |
1547 | |
1548 else | |
1549 print_usage (); | |
7109 | 1550 endif |
6405 | 1551 |
1552 endfunction | |
1553 | |
9257
ab952265ad06
__go_draw_axes__.m: Properly render TeX symbols for x11.
Ben Abbott <bpabbott@mac.com>
parents:
9191
diff
changeset
|
1554 function fontspec = create_fontspec (f, s, gp_term) |
9468
5af462716bff
Add support for gnuplot's Lua-TikZ terminal.
Ben Abbott <bpabbott@mac.com>
parents:
9438
diff
changeset
|
1555 if (strcmp (f, "*") || strcmp (gp_term, "tikz")) |
9098
5ecdb3d3568f
Allow fontsize to be specified for all objects with fontname == "*".
Ben Abbott <bpabbott@mac.com>
parents:
9083
diff
changeset
|
1556 fontspec = sprintf ("font \",%d\"", s); |
9063
a6cf0ad87eee
__go_draw_axes__.m: New subfunction create_fontspec(). Allow fontsize to be specified when the fontname is anonymous.
Ben Abbott <bpabbott@mac.com>
parents:
9050
diff
changeset
|
1557 else |
a6cf0ad87eee
__go_draw_axes__.m: New subfunction create_fontspec(). Allow fontsize to be specified when the fontname is anonymous.
Ben Abbott <bpabbott@mac.com>
parents:
9050
diff
changeset
|
1558 fontspec = sprintf ("font \"%s,%d\"", f, s); |
a6cf0ad87eee
__go_draw_axes__.m: New subfunction create_fontspec(). Allow fontsize to be specified when the fontname is anonymous.
Ben Abbott <bpabbott@mac.com>
parents:
9050
diff
changeset
|
1559 endif |
a6cf0ad87eee
__go_draw_axes__.m: New subfunction create_fontspec(). Allow fontsize to be specified when the fontname is anonymous.
Ben Abbott <bpabbott@mac.com>
parents:
9050
diff
changeset
|
1560 endfunction |
a6cf0ad87eee
__go_draw_axes__.m: New subfunction create_fontspec(). Allow fontsize to be specified when the fontname is anonymous.
Ben Abbott <bpabbott@mac.com>
parents:
9050
diff
changeset
|
1561 |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1562 function style = do_linestyle_command (obj, linecolor, idx, mono, |
10549 | 1563 plot_stream, errbars = "") |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1564 style = {}; |
6405 | 1565 |
8164
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
1566 fprintf (plot_stream, "set style line %d default;\n", idx); |
6405 | 1567 fprintf (plot_stream, "set style line %d", idx); |
1568 | |
1569 found_style = false; | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1570 if (isnumeric (linecolor)) |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1571 color = linecolor; |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1572 if (! mono) |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1573 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", |
10549 | 1574 round (255*color)); |
6405 | 1575 endif |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1576 else |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1577 color = [0, 0, 0]; |
6405 | 1578 endif |
1579 | |
1580 if (isfield (obj, "linestyle")) | |
1581 switch (obj.linestyle) | |
1582 case "-" | |
10549 | 1583 lt = "1"; |
6405 | 1584 case "--" |
10549 | 1585 lt = "2"; |
6405 | 1586 case ":" |
10549 | 1587 lt = "3"; |
6405 | 1588 case "-." |
10549 | 1589 lt = "6"; |
6405 | 1590 case "none" |
10549 | 1591 lt = ""; |
6405 | 1592 otherwise |
10549 | 1593 lt = ""; |
6405 | 1594 endswitch |
6843 | 1595 |
1596 ## FIXME -- linetype is currently broken, since it disables the | |
1597 ## gnuplot default dashed and solid linestyles with the only | |
1598 ## benefit of being able to specify '--' and get a single sized | |
1599 ## dashed line of identical dash pattern for all called this way. | |
1600 ## All dash patterns are a subset of "with lines" and none of the | |
1601 ## lt specifications will correctly propagate into the x11 terminal | |
1602 ## or the print command. Therefore, it is currently disabled in | |
1603 ## order to allow print (..., "-dashed") etc. to work correctly. | |
1604 | |
1605 ## if (! isempty (lt)) | |
1606 ## fprintf (plot_stream, " linetype %s", lt); | |
1607 ## endif | |
1608 | |
6405 | 1609 else |
1610 lt = ""; | |
1611 endif | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1612 if (! isempty (errbars)) |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1613 found_style = true; |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1614 endif |
6405 | 1615 |
1616 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
|
1617 fprintf (plot_stream, " linewidth %f", obj.linewidth); |
6405 | 1618 found_style = true; |
1619 endif | |
1620 | |
1621 if (isfield (obj, "marker")) | |
1622 switch (obj.marker) | |
1623 case "+" | |
10549 | 1624 pt = pt2 = "1"; |
6405 | 1625 case "o" |
10549 | 1626 pt = "6"; |
1627 pt2 = "7"; | |
6405 | 1628 case "*" |
10549 | 1629 pt = pt2 = "3"; |
6405 | 1630 case "." |
10549 | 1631 pt = pt2 = "0"; |
6405 | 1632 case "x" |
10549 | 1633 pt = pt2 = "2"; |
6405 | 1634 case {"square", "s"} |
10549 | 1635 pt = "4"; |
1636 pt2 = "5"; | |
6405 | 1637 case {"diamond", "d"} |
10563
f5a652a101b0
Correct fill of diamond markers for gnuplot backend
David Bateman <dbateman@free.fr>
parents:
10561
diff
changeset
|
1638 pt = "12"; |
f5a652a101b0
Correct fill of diamond markers for gnuplot backend
David Bateman <dbateman@free.fr>
parents:
10561
diff
changeset
|
1639 pt2 = "13"; |
6405 | 1640 case "^" |
10549 | 1641 pt = "8"; |
1642 pt2 = "9"; | |
6405 | 1643 case "v" |
10549 | 1644 pt = "10"; |
1645 pt2 = "11"; | |
6405 | 1646 case ">" |
10549 | 1647 ## FIXME missing point type |
1648 pt = "8"; | |
1649 pt2 = "9"; | |
6405 | 1650 case "<" |
10549 | 1651 ## FIXME missing point type |
1652 pt = "10"; | |
1653 pt2 = "11"; | |
6405 | 1654 case {"pentagram", "p"} |
10549 | 1655 ## FIXME missing point type |
1656 pt = pt2 = "3"; | |
6405 | 1657 case {"hexagram", "h"} |
10549 | 1658 pt = pt2 = "3"; |
6405 | 1659 case "none" |
10549 | 1660 pt = pt2 = ""; |
6405 | 1661 otherwise |
10549 | 1662 pt = pt2 = ""; |
6405 | 1663 endswitch |
1664 else | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1665 pt = pt2 = ""; |
6405 | 1666 endif |
1667 | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1668 if (! isempty (pt)) |
6465 | 1669 found_style = true; |
1670 endif | |
1671 | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1672 sidx = 1; |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1673 if (isempty (errbars)) |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1674 if (isempty (lt)) |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1675 style {sidx} = ""; |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1676 else |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1677 style {sidx} = "lines"; |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1678 endif |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1679 |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1680 facesame = true; |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1681 if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") |
10549 | 1682 && !strncmp (obj.markerfacecolor, "none", 4)) |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1683 if (strncmp (obj.markerfacecolor, "auto", 4) |
10549 | 1684 || ! isnumeric (obj.markerfacecolor) |
1685 || (isnumeric (obj.markerfacecolor) | |
1686 && isequal (color, obj.markerfacecolor))) | |
1687 if (! isempty (pt2)) | |
1688 fprintf (plot_stream, " pointtype %s", pt2); | |
1689 style {sidx} = strcat (style{sidx}, "points"); | |
1690 endif | |
1691 if (isfield (obj, "markersize")) | |
1692 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1693 endif | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1694 else |
10549 | 1695 facesame = false; |
1696 if (! found_style) | |
1697 fputs (plot_stream, " default"); | |
1698 endif | |
1699 fputs (plot_stream, ";\n"); | |
1700 if (! isempty (style {sidx})) | |
1701 sidx ++; | |
1702 idx ++; | |
1703 else | |
1704 fputs (plot_stream, ";\n"); | |
1705 endif | |
1706 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1707 fprintf (plot_stream, "set style line %d", idx); | |
1708 if (isnumeric (obj.markerfacecolor) && ! mono) | |
1709 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1710 round (255*obj.markerfacecolor)); | |
1711 endif | |
1712 if (! isempty (pt2)) | |
1713 style {sidx} = "points"; | |
1714 fprintf (plot_stream, " pointtype %s", pt2); | |
1715 endif | |
1716 if (isfield (obj, "markersize")) | |
1717 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1718 endif | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1719 endif |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1720 endif |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1721 if (isfield (obj, "markeredgecolor") |
10549 | 1722 && !strncmp (obj.markeredgecolor, "none", 4)) |
10157
cf17f22f1fd4
trivial fix to durface and lines for empty markers
David Bateman <dbateman@free.fr>
parents:
10137
diff
changeset
|
1723 if (facesame && !isempty (pt) |
cf17f22f1fd4
trivial fix to durface and lines for empty markers
David Bateman <dbateman@free.fr>
parents:
10137
diff
changeset
|
1724 && (strncmp (obj.markeredgecolor, "auto", 4) |
10549 | 1725 || ! isnumeric (obj.markeredgecolor) |
1726 || (isnumeric (obj.markeredgecolor) | |
1727 && isequal (color, obj.markeredgecolor)))) | |
1728 if (sidx == 1 && ((length (style {sidx}) == 5 | |
1729 && strncmp (style {sidx}, "lines", 5)) || isempty (style {sidx}))) | |
1730 if (! isempty (pt)) | |
1731 style {sidx} = strcat (style{sidx}, "points"); | |
1732 fprintf (plot_stream, " pointtype %s", pt); | |
1733 endif | |
1734 if (isfield (obj, "markersize")) | |
1735 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1736 endif | |
1737 endif | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1738 else |
10549 | 1739 if (! found_style) |
1740 fputs (plot_stream, " default"); | |
1741 endif | |
1742 fputs (plot_stream, ";\n"); | |
1743 if (!isempty (style {sidx})) | |
1744 sidx ++; | |
1745 idx ++; | |
1746 else | |
1747 fputs (plot_stream, ";\n"); | |
1748 endif | |
1749 fprintf (plot_stream, "set style line %d default;\n", idx); | |
1750 fprintf (plot_stream, "set style line %d", idx); | |
1751 if (! mono) | |
1752 if (strncmp (obj.markeredgecolor, "auto", 4)) | |
1753 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1754 round (255*color)); | |
1755 elseif (isnumeric (obj.markeredgecolor) && ! mono) | |
1756 fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"", | |
1757 round (255*obj.markeredgecolor)); | |
1758 endif | |
1759 endif | |
1760 if (! isempty (pt)) | |
1761 style {sidx} = "points"; | |
1762 fprintf (plot_stream, " pointtype %s", pt); | |
1763 endif | |
1764 if (isfield (obj, "markersize")) | |
1765 fprintf (plot_stream, " pointsize %f", obj.markersize / 3); | |
1766 endif | |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1767 endif |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1768 endif |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1769 else |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1770 style{1} = errbars; |
10582
9676d0255440
Use "." for marker when plotting with errorbars. (bug #29057)
Rik <octave@nomad.inbox5.com>
parents:
10563
diff
changeset
|
1771 fputs (plot_stream, " pointtype 0"); |
9729
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1772 endif |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1773 |
3b7e644bb46d
Treat markerfacecolor and markeredgecolor properties for lines and surfaces
David Bateman <dbateman@free.fr>
parents:
9472
diff
changeset
|
1774 if (! found_style && isempty (style {1})) |
6405 | 1775 fputs (plot_stream, " default"); |
1776 endif | |
1777 | |
1778 fputs (plot_stream, ";\n"); | |
1779 | |
1780 endfunction | |
6510 | 1781 |
7316 | 1782 function nd = __calc_dimensions__ (obj) |
1783 kids = obj.children; | |
1784 nd = 2; | |
1785 for i = 1:length (kids) | |
1786 obj = get (kids(i)); | |
1787 switch (obj.type) | |
1788 case {"image", "text"} | |
10549 | 1789 ## ignore as they |
7316 | 1790 case {"line", "patch"} |
10549 | 1791 if (! isempty (obj.zdata)) |
1792 nd = 3; | |
1793 endif | |
7316 | 1794 case "surface" |
10549 | 1795 nd = 3; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1796 case "hggroup" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1797 obj_nd = __calc_dimensions__ (obj); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1798 if (obj_nd == 3) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1799 nd = 3; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7726
diff
changeset
|
1800 endif |
7316 | 1801 endswitch |
1802 endfor | |
1803 endfunction | |
1804 | |
7119 | 1805 function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata) |
6510 | 1806 |
1807 ## DATA is already transposed. | |
1808 | |
1809 ## FIXME -- this may need to be converted to C++ for speed. | |
1810 | |
6605 | 1811 ## Convert NA elements to normal NaN values because fprintf writes |
1812 ## "NA" and that confuses gnuplot. | |
1813 idx = find (isna (data)); | |
1814 if (any (idx)) | |
1815 data(idx) = NaN; | |
1816 endif | |
1817 | |
6510 | 1818 if (nd == 2) |
8217
f74cb5e3a6c1
send binary data to gnuplot
Daniel J. Sebald <daniel.sebald@ieee.org>
parents:
8216
diff
changeset
|
1819 fwrite (plot_stream, data, "float64"); |
7109 | 1820 elseif (nd == 3) |
6510 | 1821 if (parametric) |
8217
f74cb5e3a6c1
send binary data to gnuplot
Daniel J. Sebald <daniel.sebald@ieee.org>
parents:
8216
diff
changeset
|
1822 fwrite (plot_stream, data, "float64"); |
6510 | 1823 else |
7170 | 1824 nr = rows (data); |
7119 | 1825 if (cdata) |
10549 | 1826 for j = 1:4:nr |
1827 fwrite (plot_stream, data(j:j+3,:), "float64"); | |
1828 endfor | |
7119 | 1829 else |
10549 | 1830 for j = 1:3:nr |
1831 fwrite (plot_stream, data(j:j+2,:), "float64"); | |
1832 endfor | |
7119 | 1833 endif |
7109 | 1834 endif |
6510 | 1835 endif |
1836 | |
1837 endfunction | |
6745 | 1838 |
9257
ab952265ad06
__go_draw_axes__.m: Properly render TeX symbols for x11.
Ben Abbott <bpabbott@mac.com>
parents:
9191
diff
changeset
|
1839 function do_tics (obj, plot_stream, ymirror, mono, gnuplot_term) |
8222
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1840 |
8518
c2c018d7c501
__go_draw_axes__.m: __go_draw_axes__.m: Support non-cell ticklabels.
Ben Abbott <bpabbott@mac.com>
parents:
8510
diff
changeset
|
1841 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
|
1842 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
|
1843 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
|
1844 |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1845 if (strcmp (obj.xminorgrid, "on")) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1846 obj.xminortick = "on"; |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1847 endif |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1848 if (strcmp (obj.yminorgrid, "on")) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1849 obj.yminortick = "on"; |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1850 endif |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1851 if (strcmp (obj.zminorgrid, "on")) |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1852 obj.zminortick = "on"; |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1853 endif |
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1854 |
8220
4e05ba66ead2
x/y/z-ticklabels respect axis font properties.
Ben Abbott <bpabbott@mac.com>
parents:
8218
diff
changeset
|
1855 [fontname, fontsize] = get_fontname_and_size (obj); |
9257
ab952265ad06
__go_draw_axes__.m: Properly render TeX symbols for x11.
Ben Abbott <bpabbott@mac.com>
parents:
9191
diff
changeset
|
1856 fontspec = create_fontspec (fontname, fontsize, gnuplot_term); |
8222
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1857 |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8665
diff
changeset
|
1858 ## 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
|
1859 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
|
1860 |
6809 | 1861 if (strcmpi (obj.xaxislocation, "top")) |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1862 do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode, |
10549 | 1863 obj.xticklabel, obj.xcolor, "x2", plot_stream, true, mono, |
1864 "border", obj.tickdir, ticklength, fontname, fontspec, | |
1865 obj.interpreter, obj.xscale); | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1866 do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel, |
10549 | 1867 obj.xcolor, "x", plot_stream, true, mono, "border", |
1868 "", "", fontname, fontspec, obj.interpreter, obj.xscale); | |
7321 | 1869 elseif (strcmpi (obj.xaxislocation, "zero")) |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1870 do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode, |
10549 | 1871 obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono, |
1872 "axis", obj.tickdir, ticklength, fontname, fontspec, | |
1873 obj.interpreter, obj.xscale); | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1874 do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel, |
10549 | 1875 obj.xcolor, "x2", plot_stream, true, mono, "axis", |
1876 "", "", fontname, fontspec, obj.interpreter, obj.xscale); | |
6809 | 1877 else |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1878 do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode, |
10549 | 1879 obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono, |
1880 "border", obj.tickdir, ticklength, fontname, fontspec, | |
1881 obj.interpreter, obj.xscale); | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1882 do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel, |
10549 | 1883 obj.xcolor, "x2", plot_stream, true, mono, "border", |
1884 "", "", fontname, fontspec, obj.interpreter, obj.xscale); | |
6809 | 1885 endif |
1886 if (strcmpi (obj.yaxislocation, "right")) | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1887 do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode, |
10549 | 1888 obj.yticklabel, obj.ycolor, "y2", plot_stream, ymirror, mono, |
1889 "border", obj.tickdir, ticklength, fontname, fontspec, | |
1890 obj.interpreter, obj.yscale); | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1891 do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel, |
10549 | 1892 obj.ycolor, "y", plot_stream, ymirror, mono, "border", |
1893 "", "", fontname, fontspec, obj.interpreter, obj.yscale); | |
8943
4a312440b262
__go_draw_axes__.m (do_tics): fix typo
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
1894 elseif (strcmpi (obj.yaxislocation, "zero")) |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1895 do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode, |
10549 | 1896 obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono, |
1897 "axis", obj.tickdir, ticklength, fontname, fontspec, | |
1898 obj.interpreter, obj.yscale); | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1899 do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel, |
10549 | 1900 obj.ycolor, "y2", plot_stream, ymirror, mono, "axis", |
1901 "", "", fontname, fontspec, obj.interpreter, obj.yscale); | |
6809 | 1902 else |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1903 do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode, |
10549 | 1904 obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono, |
1905 "border", obj.tickdir, ticklength, fontname, fontspec, | |
1906 obj.interpreter, obj.yscale); | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1907 do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel, |
10549 | 1908 obj.ycolor, "y2", plot_stream, ymirror, mono, "border", |
1909 "", "", fontname, fontspec, obj.interpreter, obj.yscale); | |
6809 | 1910 endif |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1911 do_tics_1 (obj.ztickmode, obj.ztick, obj.zminortick, obj.zticklabelmode, |
10549 | 1912 obj.zticklabel, obj.zcolor, "z", plot_stream, true, mono, |
1913 "border", obj.tickdir, ticklength, fontname, fontspec, | |
1914 obj.interpreter, obj.yscale); | |
6745 | 1915 endfunction |
1916 | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1917 function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax, |
10549 | 1918 plot_stream, mirror, mono, axispos, tickdir, ticklength, |
1919 fontname, fontspec, interpreter, scale) | |
8222
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1920 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
|
1921 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
|
1922 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
|
1923 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
|
1924 endfor |
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1925 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
|
1926 if (! warned_latex) |
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1927 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
|
1928 warned_latex = true; |
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1929 endif |
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8220
diff
changeset
|
1930 endif |
9302
5542c40e40ac
__go_draw_axes__.m: Change strncmpi(scale,'lo') -> strcmp(scale,'log').
Ben Abbott <bpabbott@mac.com>
parents:
9301
diff
changeset
|
1931 if (strcmp (scale, "log")) |
9301
f2152fad3563
__go_draw_axes__.m: For log-scale axes use format '10^{%T}'.
Ben Abbott <bpabbott@mac.com>
parents:
9281
diff
changeset
|
1932 fmt = "10^{%T}"; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1933 num_mtics = 10; |
9301
f2152fad3563
__go_draw_axes__.m: For log-scale axes use format '10^{%T}'.
Ben Abbott <bpabbott@mac.com>
parents:
9281
diff
changeset
|
1934 else |
f2152fad3563
__go_draw_axes__.m: For log-scale axes use format '10^{%T}'.
Ben Abbott <bpabbott@mac.com>
parents:
9281
diff
changeset
|
1935 fmt = "%g"; |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1936 num_mtics = 5; |
9301
f2152fad3563
__go_draw_axes__.m: For log-scale axes use format '10^{%T}'.
Ben Abbott <bpabbott@mac.com>
parents:
9281
diff
changeset
|
1937 endif |
7269 | 1938 colorspec = get_text_colorspec (color, mono); |
8112
31e86163b752
Add the datetick function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1939 if (strcmpi (ticmode, "manual") || strcmpi (labelmode, "manual")) |
6745 | 1940 if (isempty (tics)) |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1941 fprintf (plot_stream, "unset %stics;\nunset m%stics;\n", ax, ax); |
8953
a6945f92b868
__go_draw_axes__.m: Unset the {x,y,z}ticks when initializing\n\teach axis. Set ticklabels when the ticklabels are empty and when\n\tticklabelmode=="manual".
Ben Abbott <bpabbott@mac.com>
parents:
8943
diff
changeset
|
1942 elseif (strcmpi (labelmode, "manual")) |
6751 | 1943 if (ischar (labels)) |
10549 | 1944 labels = cellstr (labels); |
6751 | 1945 endif |
8354
534fd216278c
__go_draw_axes__.m: xticklabel should accept a numeric vector.
Ben Abbott <bpabbott@mac.com>
parents:
8344
diff
changeset
|
1946 if (isnumeric (labels)) |
10549 | 1947 labels = num2str (real (labels(:))); |
8354
534fd216278c
__go_draw_axes__.m: xticklabel should accept a numeric vector.
Ben Abbott <bpabbott@mac.com>
parents:
8344
diff
changeset
|
1948 endif |
534fd216278c
__go_draw_axes__.m: xticklabel should accept a numeric vector.
Ben Abbott <bpabbott@mac.com>
parents:
8344
diff
changeset
|
1949 if (ischar (labels)) |
10549 | 1950 labels = permute (cellstr (labels), [2, 1]); |
8354
534fd216278c
__go_draw_axes__.m: xticklabel should accept a numeric vector.
Ben Abbott <bpabbott@mac.com>
parents:
8344
diff
changeset
|
1951 endif |
6745 | 1952 if (iscellstr (labels)) |
10549 | 1953 k = 1; |
1954 ntics = numel (tics); | |
1955 nlabels = numel (labels); | |
1956 fprintf (plot_stream, "set format %s \"%%s\";\n", ax); | |
1957 if (mirror) | |
1958 fprintf (plot_stream, "set %stics %s %s %s mirror (", ax, | |
1959 tickdir, ticklength, axispos); | |
1960 else | |
1961 fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax, | |
1962 tickdir, ticklength, axispos); | |
1963 endif | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1964 |
10549 | 1965 labels = regexprep(labels, "%", "%%"); |
1966 for i = 1:ntics | |
1967 fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i)); | |
1968 if (i < ntics) | |
1969 fputs (plot_stream, ", "); | |
1970 endif | |
1971 if (k > nlabels) | |
1972 k = 1; | |
1973 endif | |
1974 endfor | |
1975 fprintf (plot_stream, ") %s %s;\n", colorspec, fontspec); | |
1976 if (strcmp (mtics, "on")) | |
1977 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics); | |
1978 else | |
1979 fprintf (plot_stream, "unset m%stics;\n", ax); | |
1980 endif | |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1981 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10597
diff
changeset
|
1982 error ("__go_draw_axes__: unsupported type of ticklabel"); |
6745 | 1983 endif |
1984 else | |
9301
f2152fad3563
__go_draw_axes__.m: For log-scale axes use format '10^{%T}'.
Ben Abbott <bpabbott@mac.com>
parents:
9281
diff
changeset
|
1985 fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt); |
7206 | 1986 if (mirror) |
10549 | 1987 fprintf (plot_stream, "set %stics %s %s %s mirror (", ax, tickdir, |
1988 ticklength, axispos); | |
7206 | 1989 else |
10549 | 1990 fprintf (plot_stream, "set %stics %s %s %s nomirror (", ax, tickdir, |
1991 ticklength, axispos); | |
7206 | 1992 endif |
8112
31e86163b752
Add the datetick function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1993 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
|
1994 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
|
1995 if (strcmp (mtics, "on")) |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
1996 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics); |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1997 else |
10549 | 1998 fprintf (plot_stream, "unset m%stics;\n", ax); |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
1999 endif |
6745 | 2000 endif |
2001 else | |
9301
f2152fad3563
__go_draw_axes__.m: For log-scale axes use format '10^{%T}'.
Ben Abbott <bpabbott@mac.com>
parents:
9281
diff
changeset
|
2002 fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt); |
7206 | 2003 if (mirror) |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8665
diff
changeset
|
2004 fprintf (plot_stream, "set %stics %s %s %s mirror %s %s;\n", ax, |
10549 | 2005 axispos, tickdir, ticklength, colorspec, fontspec); |
7206 | 2006 else |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8665
diff
changeset
|
2007 fprintf (plot_stream, "set %stics %s %s %s nomirror %s %s;\n", ax, |
10549 | 2008 tickdir, ticklength, axispos, colorspec, fontspec); |
7206 | 2009 endif |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2010 if (strcmp (mtics, "on")) |
9374
6a035159ba0e
grid.m: Add missing semi-colon. Fix grid toggle. Allow minor grid when no minor tick.
Ben Abbott <bpabbott@mac.com>
parents:
9361
diff
changeset
|
2011 fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics); |
8322
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2012 else |
f32a91d99156
Respect the minortick property of the axis objects
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2013 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
|
2014 endif |
7194 | 2015 endif |
2016 endfunction | |
2017 | |
9281
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
2018 function ticklabel = ticklabel_to_cell (ticklabel) |
9472
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2019 if (isnumeric (ticklabel)) |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2020 ## Use upto 5 significant digits |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2021 ticklabel = num2str (ticklabel(:), 5); |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2022 endif |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2023 if (ischar (ticklabel)) |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2024 if (size (ticklabel, 1) == 1 && any (ticklabel == "|")) |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2025 n = setdiff (findstr (ticklabel, "|"), findstr (ticklabel, '\|')); |
9281
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
2026 ticklabel = strsplit (ticklabel, "|"); |
9280
40fb718a2e67
__go_draw_axes__.m: Add support for ticklabel separator '|'.
Ben Abbott <bpabbott@mac.com>
parents:
9272
diff
changeset
|
2027 else |
9281
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
2028 ticklabel = cellstr (ticklabel); |
9280
40fb718a2e67
__go_draw_axes__.m: Add support for ticklabel separator '|'.
Ben Abbott <bpabbott@mac.com>
parents:
9272
diff
changeset
|
2029 endif |
9472
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2030 elseif (isempty (ticklabel)) |
303f862a896d
__go_draw_axes__.m: Fix ticklabels specified as 2D character array.
Ben Abbott <bpabbott@mac.com>
parents:
9468
diff
changeset
|
2031 ticklabel = {""}; |
9280
40fb718a2e67
__go_draw_axes__.m: Add support for ticklabel separator '|'.
Ben Abbott <bpabbott@mac.com>
parents:
9272
diff
changeset
|
2032 else |
9281
02b16eeb3167
Fix yticklabels for log scale colorbar.
Ben Abbott <bpabbott@mac.com>
parents:
9280
diff
changeset
|
2033 ticklabel = ticklabel; |
8518
c2c018d7c501
__go_draw_axes__.m: __go_draw_axes__.m: Support non-cell ticklabels.
Ben Abbott <bpabbott@mac.com>
parents:
8510
diff
changeset
|
2034 endif |
c2c018d7c501
__go_draw_axes__.m: __go_draw_axes__.m: Support non-cell ticklabels.
Ben Abbott <bpabbott@mac.com>
parents:
8510
diff
changeset
|
2035 endfunction |
c2c018d7c501
__go_draw_axes__.m: __go_draw_axes__.m: Support non-cell ticklabels.
Ben Abbott <bpabbott@mac.com>
parents:
8510
diff
changeset
|
2036 |
7269 | 2037 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
|
2038 if (mono) |
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
2039 colorspec = ""; |
7194 | 2040 else |
8164
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
2041 colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"", |
10549 | 2042 round (255*color)); |
6745 | 2043 endif |
2044 endfunction | |
7163 | 2045 |
7189 | 2046 function [f, s, fnt, it, bld] = get_fontname_and_size (t) |
7163 | 2047 if (isempty (t.fontname)) |
7372 | 2048 fnt = "Helvetica"; |
7163 | 2049 else |
7372 | 2050 fnt = t.fontname; |
7168 | 2051 endif |
7189 | 2052 f = fnt; |
2053 it = false; | |
2054 bld = false; | |
7372 | 2055 if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold")) |
7168 | 2056 if (! isempty(t.fontangle) |
10549 | 2057 && (strcmpi (t.fontangle, "italic") |
2058 || 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
|
2059 f = cstrcat (f, "-bolditalic"); |
7189 | 2060 it = true; |
2061 bld = true; | |
7168 | 2062 else |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2063 f = cstrcat (f, "-bold"); |
7189 | 2064 bld = true; |
7168 | 2065 endif |
2066 elseif (! isempty(t.fontangle) | |
10549 | 2067 && (strcmpi (t.fontangle, "italic") |
2068 || 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
|
2069 f = cstrcat (f, "-italic"); |
7189 | 2070 it = true; |
7163 | 2071 endif |
2072 if (isempty (t.fontsize)) | |
2073 s = 10; | |
2074 else | |
2075 s = t.fontsize; | |
2076 endif | |
2077 endfunction | |
7189 | 2078 |
8164
0d37c99fc06f
__go_draw_axes__.m: eliminate have_newer_gnuplot variable
John W. Eaton <jwe@octave.org>
parents:
8112
diff
changeset
|
2079 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
|
2080 |
7189 | 2081 persistent warned_latex = false; |
2082 | |
2083 if (strcmp (fld, "string")) | |
2084 [f, s, fnt, it, bld] = get_fontname_and_size (obj); | |
2085 else | |
7372 | 2086 f = "Helvetica"; |
7189 | 2087 s = 10; |
2088 fnt = f; | |
2089 it = false; | |
2090 bld = false; | |
2091 endif | |
2092 | |
2093 str = getfield (obj, fld); | |
2094 if (enhanced) | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8171
diff
changeset
|
2095 if (strcmpi (obj.interpreter, "tex")) |
7189 | 2096 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
|
2097 elseif (strcmpi (obj.interpreter, "latex")) |
7189 | 2098 if (! warned_latex) |
10549 | 2099 warning ("latex markup not supported for text objects"); |
2100 warned_latex = true; | |
7189 | 2101 endif |
2102 endif | |
2103 endif | |
2104 endfunction | |
2105 | |
2106 function str = __tex2enhanced__ (str, fnt, it, bld) | |
2107 persistent sym = __setup_sym_table__ (); | |
2108 persistent flds = fieldnames (sym); | |
2109 | |
2110 [s, e, m] = regexp(str,'\\([a-zA-Z]+|0)','start','end','matches'); | |
2111 | |
2112 for i = length (s) : -1 : 1 | |
2113 ## special case for "\0" and replace with "{/Symbol \306}' | |
2114 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
|
2115 str = cstrcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end)); |
7189 | 2116 else |
2117 f = m{i}(2:end); | |
2118 if (isfield (sym, f)) | |
10549 | 2119 g = getfield(sym, f); |
2120 ## FIXME The symbol font doesn't seem to support bold or italic | |
2121 ##if (bld) | |
2122 ## if (it) | |
2123 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
2124 ## else | |
2125 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
2126 ## endif | |
2127 ##elseif (it) | |
2128 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
2129 ##endif | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2130 str = cstrcat (str(1:s(i) - 1), g, str(e(i) + 1:end)); |
7189 | 2131 elseif (strncmp (f, "rm", 2)) |
10549 | 2132 bld = false; |
2133 it = false; | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2134 str = cstrcat (str(1:s(i) - 1), '/', fnt, ' ', str(s(i) + 3:end)); |
7189 | 2135 elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) |
10549 | 2136 it = true; |
2137 if (bld) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2138 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', |
10549 | 2139 str(s(i) + 3:end)); |
7189 | 2140 else |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2141 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ', |
10549 | 2142 str(s(i) + 3:end)); |
7189 | 2143 endif |
2144 elseif (strncmp (f, "bf", 2)) | |
10549 | 2145 bld = true; |
2146 if (it) | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2147 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', |
10549 | 2148 str(2(i) + 3:end)); |
7189 | 2149 else |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2150 str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ', |
10549 | 2151 str(s(i) + 3:end)); |
7189 | 2152 endif |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8171
diff
changeset
|
2153 elseif (strcmpi (f, "color")) |
10549 | 2154 ## FIXME Ignore \color but remove trailing {} block as well |
2155 d = strfind(str(e(i) + 1:end),'}'); | |
7189 | 2156 if (isempty (d)) |
10549 | 2157 warning ('syntax error in \color argument'); |
2158 else | |
2159 str = cstrcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); | |
7189 | 2160 endif |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8171
diff
changeset
|
2161 elseif(strcmpi (f, "fontname")) |
10549 | 2162 b1 = strfind(str(e(i) + 1:end),'{'); |
2163 b2 = strfind(str(e(i) + 1:end),'}'); | |
7189 | 2164 if (isempty(b1) || isempty(b2)) |
10549 | 2165 warning ('syntax error in \fontname argument'); |
2166 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2167 str = cstrcat (str(1:s(i) - 1), '/', |
10549 | 2168 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', |
2169 str(e(i) + b2(1) + 1:end)); | |
7189 | 2170 endif |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8171
diff
changeset
|
2171 elseif(strcmpi (f, "fontsize")) |
10549 | 2172 b1 = strfind(str(e(i) + 1:end),'{'); |
2173 b2 = strfind(str(e(i) + 1:end),'}'); | |
7189 | 2174 if (isempty(b1) || isempty(b2)) |
10549 | 2175 warning ('syntax error in \fontname argument'); |
2176 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2177 str = cstrcat (str(1:s(i) - 1), '/=', |
10549 | 2178 str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', |
2179 str(e(i) + b2(1) + 1:end)); | |
7189 | 2180 endif |
2181 else | |
10549 | 2182 ## Last desperate attempt to treat the symbol. Look for things |
2183 ## like \pix, that should be translated to the symbol Pi and x | |
2184 for j = 1 : length (flds) | |
2185 if (strncmp (flds{j}, f, length (flds{j}))) | |
2186 g = getfield(sym, flds{j}); | |
2187 ## FIXME The symbol font doesn't seem to support bold or italic | |
2188 ##if (bld) | |
2189 ## if (it) | |
2190 ## g = regexprep (g, '/Symbol', '/Symbol-bolditalic'); | |
2191 ## else | |
2192 ## g = regexprep (g, '/Symbol', '/Symbol-bold'); | |
2193 ## endif | |
2194 ##elseif (it) | |
2195 ## g = regexprep (g, '/Symbol', '/Symbol-italic'); | |
2196 ##endif | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7513
diff
changeset
|
2197 str = cstrcat (str(1:s(i) - 1), g, |
10549 | 2198 str(s(i) + length (flds{j}) + 1:end)); |
2199 break; | |
2200 endif | |
2201 endfor | |
7189 | 2202 endif |
2203 endif | |
2204 endfor | |
2205 | |
8506 | 2206 ## Prepend @ to things things like _0^x or _{-100}^{100} for |
2207 ## alignment But need to put the shorter of the two arguments first. | |
2208 ## Carful of nested {} and unprinted characters when defining | |
2209 ## shortest.. Don't have to worry about things like ^\theta as they | |
2210 ## are already converted to ^{/Symbol q}. | |
7189 | 2211 |
8506 | 2212 ## FIXME -- This is a mess... Is it worth it just for a "@" character? |
7189 | 2213 |
2214 [s, m] = regexp(str,'[_\^]','start','matches'); | |
2215 i = 1; | |
2216 p = 0; | |
2217 while (i < length (s)) | |
2218 if (i < length(s)) | |
2219 if (str(s(i) + p + 1) == "{") | |
10549 | 2220 s1 = strfind(str(s(i) + p + 2:end),'{'); |
2221 si = 1; | |
2222 l1 = strfind(str(s(i) + p + 1:end),'}'); | |
7189 | 2223 li = 1; |
10549 | 2224 while (li <= length (l1) && si <= length (s1)) |
7189 | 2225 if (l1(li) < s1(si)) |
10549 | 2226 if (li == si) |
2227 break; | |
2228 endif | |
2229 li++; | |
2230 else | |
2231 si++; | |
2232 endif | |
2233 endwhile | |
2234 l1 = l1 (min (length(l1), si)); | |
7189 | 2235 if (s(i) + l1 + 1 == s(i+1)) |
10549 | 2236 if (str(s(i + 1) + p + 1) == "{") |
2237 s2 = strfind(str(s(i + 1) + p + 2:end),'{'); | |
2238 si = 1; | |
2239 l2 = strfind(str(s(i + 1) + p + 1:end),'}'); | |
7189 | 2240 li = 1; |
10549 | 2241 while (li <= length (l2) && si <= length (s2)) |
7189 | 2242 if (l2(li) < s2(si)) |
10549 | 2243 if (li == si) |
2244 break; | |
2245 endif | |
2246 li++; | |
2247 else | |
2248 si++; | |
2249 endif | |
2250 endwhile | |
2251 l2 = l2 (min (length(l2), si)); | |
2252 if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= | |
2253 length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) | |
2254 ## Shortest already first! | |
2255 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
2256 else | |
2257 ## Have to swap sub/super-script to get shortest first. | |
2258 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), | |
2259 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); | |
2260 endif | |
2261 else | |
2262 ## Have to swap sub/super-script to get shortest first. | |
2263 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), | |
2264 str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); | |
2265 endif | |
7189 | 2266 i += 2; |
10549 | 2267 p ++; |
2268 else | |
2269 i++; | |
2270 endif | |
7189 | 2271 else |
10549 | 2272 if (s(i+1) == s(i) + 2) |
2273 ## Shortest already first! | |
2274 str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); | |
2275 p ++; | |
7189 | 2276 i += 2; |
10549 | 2277 else |
2278 i ++; | |
2279 endif | |
7189 | 2280 endif |
2281 else | |
2282 i ++; | |
2283 endif | |
2284 endwhile | |
2285 | |
2286 endfunction | |
2287 | |
2288 function l = length_string (s) | |
2289 l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}')); | |
2290 m = regexp (s, '/([\w\-]+|[\w\-]+=\d+)', 'matches'); | |
2291 if (!isempty (m)) | |
2292 l = l - sum (cellfun (@length, m)); | |
2293 endif | |
2294 endfunction | |
2295 | |
2296 function sym = __setup_sym_table__ () | |
2297 ## Setup the translation table for TeX to gnuplot enhanced mode. | |
2298 sym.forall = '{/Symbol \042}'; | |
2299 sym.exists = '{/Symbol \044}'; | |
2300 sym.ni = '{/Symbol \047}'; | |
2301 sym.cong = '{/Symbol \100}'; | |
2302 sym.Delta = '{/Symbol D}'; | |
2303 sym.Phi = '{/Symbol F}'; | |
7608
49810341db91
Correct typos in __go_draw_axes__.m and update Manual
godfrey@qss.Stanford.EDU
parents:
7603
diff
changeset
|
2304 sym.Gamma = '{/Symbol G}'; |
7190 | 2305 sym.vartheta = '{/Symbol J}'; |
7189 | 2306 sym.Lambda = '{/Symbol L}'; |
2307 sym.Pi = '{/Symbol P}'; | |
2308 sym.Theta = '{/Symbol Q}'; | |
2309 sym.Sigma = '{/Symbol S}'; | |
2310 sym.varsigma = '{/Symbol V}'; | |
7420 | 2311 sym.Omega = '{/Symbol W}'; |
7189 | 2312 sym.Xi = '{/Symbol X}'; |
2313 sym.Psi = '{/Symbol Y}'; | |
2314 sym.perp = '{/Symbol \136}'; | |
2315 sym.alpha = '{/Symbol a}'; | |
2316 sym.beta = '{/Symbol b}'; | |
2317 sym.chi = '{/Symbol c}'; | |
2318 sym.delta = '{/Symbol d}'; | |
2319 sym.epsilon = '{/Symbol e}'; | |
2320 sym.phi = '{/Symbol f}'; | |
7608
49810341db91
Correct typos in __go_draw_axes__.m and update Manual
godfrey@qss.Stanford.EDU
parents:
7603
diff
changeset
|
2321 sym.gamma = '{/Symbol g}'; |
7189 | 2322 sym.eta = '{/Symbol h}'; |
2323 sym.iota = '{/Symbol i}'; | |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2324 sym.varphi = '{/Symbol j}'; |
7189 | 2325 sym.kappa = '{/Symbol k}'; |
2326 sym.lambda = '{/Symbol l}'; | |
2327 sym.mu = '{/Symbol m}'; | |
2328 sym.nu = '{/Symbol n}'; | |
2329 sym.o = '{/Symbol o}'; | |
2330 sym.pi = '{/Symbol p}'; | |
2331 sym.theta = '{/Symbol q}'; | |
2332 sym.rho = '{/Symbol r}'; | |
2333 sym.sigma = '{/Symbol s}'; | |
2334 sym.tau = '{/Symbol t}'; | |
2335 sym.upsilon = '{/Symbol u}'; | |
2336 sym.varpi = '{/Symbol v}'; | |
2337 sym.omega = '{/Symbol w}'; | |
2338 sym.xi = '{/Symbol x}'; | |
2339 sym.psi = '{/Symbol y}'; | |
2340 sym.zeta = '{/Symbol z}'; | |
2341 sym.sim = '{/Symbol \176}'; | |
2342 sym.Upsilon = '{/Symbol \241}'; | |
2343 sym.prime = '{/Symbol \242}'; | |
2344 sym.leq = '{/Symbol \243}'; | |
2345 sym.infty = '{/Symbol \245}'; | |
2346 sym.clubsuit = '{/Symbol \247}'; | |
2347 sym.diamondsuit = '{/Symbol \250}'; | |
2348 sym.heartsuit = '{/Symbol \251}'; | |
2349 sym.spadesuit = '{/Symbol \252}'; | |
2350 sym.leftrightarrow = '{/Symbol \253}'; | |
2351 sym.leftarrow = '{/Symbol \254}'; | |
2352 sym.uparrow = '{/Symbol \255}'; | |
2353 sym.rightarrow = '{/Symbol \256}'; | |
2354 sym.downarrow = '{/Symbol \257}'; | |
2355 sym.circ = '{/Symbol \260}'; | |
2356 sym.pm = '{/Symbol \261}'; | |
2357 sym.geq = '{/Symbol \263}'; | |
2358 sym.times = '{/Symbol \264}'; | |
2359 sym.propto = '{/Symbol \265}'; | |
2360 sym.partial = '{/Symbol \266}'; | |
2361 sym.bullet = '{/Symbol \267}'; | |
2362 sym.div = '{/Symbol \270}'; | |
2363 sym.neq = '{/Symbol \271}'; | |
2364 sym.equiv = '{/Symbol \272}'; | |
2365 sym.approx = '{/Symbol \273}'; | |
2366 sym.ldots = '{/Symbol \274}'; | |
2367 sym.mid = '{/Symbol \275}'; | |
2368 sym.aleph = '{/Symbol \300}'; | |
2369 sym.Im = '{/Symbol \301}'; | |
2370 sym.Re = '{/Symbol \302}'; | |
2371 sym.wp = '{/Symbol \303}'; | |
2372 sym.otimes = '{/Symbol \304}'; | |
2373 sym.oplus = '{/Symbol \305}'; | |
2374 sym.oslash = '{/Symbol \306}'; | |
2375 sym.cap = '{/Symbol \307}'; | |
2376 sym.cup = '{/Symbol \310}'; | |
2377 sym.supset = '{/Symbol \311}'; | |
2378 sym.supseteq = '{/Symbol \312}'; | |
2379 sym.subset = '{/Symbol \314}'; | |
2380 sym.subseteq = '{/Symbol \315}'; | |
2381 sym.in = '{/Symbol \316}'; | |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2382 sym.notin = '{/Symbol \317}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2383 sym.angle = '{/Symbol \320}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2384 sym.bigtriangledown = '{/Symbol \321}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2385 sym.langle = '{/Symbol \341}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2386 sym.rangle = '{/Symbol \361}'; |
7189 | 2387 sym.nabla = '{/Symbol \321}'; |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2388 sym.prod = '{/Symbol \325}'; |
7189 | 2389 sym.surd = '{/Symbol \326}'; |
2390 sym.cdot = '{/Symbol \327}'; | |
2391 sym.neg = '{/Symbol \330}'; | |
2392 sym.wedge = '{/Symbol \331}'; | |
2393 sym.vee = '{/Symbol \332}'; | |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2394 sym.Leftrightarrow = '{/Symbol \333}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2395 sym.Leftarrow = '{/Symbol \334}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2396 sym.Uparrow = '{/Symbol \335}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2397 sym.Rightarrow = '{/Symbol \336}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2398 sym.Downarrow = '{/Symbol \337}'; |
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2399 sym.diamond = '{/Symbol \340}'; |
7189 | 2400 sym.copyright = '{/Symbol \343}'; |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2401 sym.lfloor = '{/Symbol \353}'; |
7189 | 2402 sym.lceil = '{/Symbol \351}'; |
7593
fdb6ff523237
__go_draw_axes__: use correct symbol codes
Michael D. Godfrey
parents:
7592
diff
changeset
|
2403 sym.rfloor = '{/Symbol \373}'; |
7189 | 2404 sym.rceil = '{/Symbol \371}'; |
2405 sym.int = '{/Symbol \362}'; | |
2406 endfunction | |
2407 | |
7390 | 2408 function retval = __do_enhanced_option__ (enhanced, obj) |
2409 retval = ""; | |
2410 if (enhanced) | |
2411 if (strcmpi (obj.interpreter, "none")) | |
2412 retval = "noenhanced"; | |
2413 else | |
2414 retval = "enhanced"; | |
2415 endif | |
2416 endif | |
2417 endfunction |