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