annotate scripts/plot/util/__next_line_style__.m @ 19697:4197fc428c7d

maint: Update copyright notices for 2015.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Feb 2015 14:19:08 -0500
parents 702aa79dc482
children 516bb87ea72e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19171
diff changeset
1 ## Copyright (C) 2010-2015 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
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
31 if (nargin == 1)
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
32 ## Indicates whether the next call will increment or not
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
33 reset_style = reset;
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
34 else
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
35 ## Find and return the next line style
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
36 ca = gca ();
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
37 style_rotation = get (ca, "linestyleorder");
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
38 if (ischar (style_rotation))
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
39 style_rotation = strsplit (style_rotation, "|");
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
40 endif
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
41 nStyles = length (style_rotation);
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
42 if (reset_style || (nStyles < 2))
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
43 style_index = 1;
16959
22ec459cf7ba Correction to allow multi-line plots to have multiple colors (bug #16955).
Carl Osterwisch <costerwisch@generalcompression.com>
parents: 16943
diff changeset
44 reset_style = false;
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
45 else
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
46 ## Executed when "hold all" is active
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
47 nChildren = length (get (ca, "Children"));
17315
3abed16370ad Fix LineStyleOrder cycling when ColorOrder is a single value (bug #39854)
Stefan Mahr <dac922@gmx.de>
parents: 17176
diff changeset
48 nColors = rows (get (ca, "ColorOrder"));
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
49 style_index = mod (floor (nChildren/nColors), nStyles) + 1;
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
50 endif
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
51 options = __pltopt__ ("__next_line_style__",
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
52 style_rotation(style_index));
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
53 linestyle = options.linestyle;
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
54 marker = options.marker;
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
55 endif
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
56
10135
4516a0c97ced Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17315
diff changeset
58
19171
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
59
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
60 %!test
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
61 %! hf = figure ("visible", "off");
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
62 %! unwind_protect
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
63 %! hax = axes ();
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 %! set (hax, "colororder", [0 0 1]);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
65 %! set (hax, "linestyleorder", {"-", ":", "--"});
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
66 %! hold on;
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
67 %! h = plot (1:5,1:5, 1:4,1:4, 1:3,1:3);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
68 %! assert (get (h, "linestyle"), {"-"; ":"; "--"});
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
69 %! cla (hax);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
70 %! hold all;
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
71 %! h1 = plot (1:5,1:5);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
72 %! h2 = plot (1:4,1:4);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
73 %! h3 = plot (1:3,1:3);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
74 %! assert (get ([h1;h2;h3], "linestyle"), {"-"; ":"; "--"});
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
75 %! unwind_protect_cleanup
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
76 %! close (hf);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
77 %! end_unwind_protect
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
78