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