annotate scripts/plot/private/__next_line_style__.m @ 16942:78a2f43bbc69

Implemented line color and style rotation across multiple axes (bug #39344).
author costerwisch@costerwisch-lt1
date Tue, 25 Jun 2013 14:48:33 -0400
parents b7667fcb9fbc
children 0dab17e69a55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13939
diff changeset
1 ## Copyright (C) 2010-2012 David Bateman
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
20 ## @deftypefn {Function File} {@var{style} =} __next_line_style__ (@var{reset})
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
21 ## Undocumented internal function.
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
22 ## @end deftypefn
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
23
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 ## Return the next line style in the rotation.
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
25
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
26
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
27 function [linestyle, marker] = __next_line_style__ (reset)
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
28
16942
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
29 persistent reset_style = true;
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
30
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
31 if (nargin < 2)
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
32 if (nargin == 1)
16942
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
33 % Indicates whether the next call will increment or not
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
34 reset_style = reset;
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
35 else
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
36 % Find and return the next line style
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
37 ca = gca();
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
38 style_rotation = get (ca, "linestyleorder");
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
39 if (ischar (style_rotation))
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
40 style_rotation = strsplit (style_rotation, "|");
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
41 endif
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
42 nStyles = length (style_rotation);
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
43 if reset_style || (nStyles < 2)
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
44 style_index = 1;
16942
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
45 else
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
46 % Executed when "hold all" is active
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
47 nChildren = length(get(ca, "Children"));
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
48 nColors = length(get(ca, "ColorOrder"));
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 16724
diff changeset
49 style_index = mod(floor(nChildren/nColors), nStyles) + 1;
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
51 options = __pltopt__ ("__next_line_style__",
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 style_rotation (style_index));
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 linestyle = options.linestyle;
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
54 marker = options.marker;
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 endif
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
56 else
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 print_usage ();
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
58 endif
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
59 endfunction