annotate scripts/plot/util/__next_line_color__.m @ 20602:af5591ef9790 stable

__gnuplot_drawnow__.m: Use "screenpixelsperinch" instead of constant value (bug #46122).
author ederag <edera@gmx.fr>
date Tue, 06 Oct 2015 11:07:10 +0200
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19205
diff changeset
1 ## Copyright (C) 2013-2015 Carl Osterwisch
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19205
diff changeset
2 ## Copyright (C) 2007-2015 John W. Eaton
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
3 ##
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
4 ## This file is part of Octave.
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
5 ##
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
7 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
9 ## your option) any later version.
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
10 ##
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
14 ## General Public License for more details.
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
15 ##
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
18 ## <http://www.gnu.org/licenses/>.
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
19
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 7016
diff changeset
20 ## -*- texinfo -*-
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 7016
diff changeset
21 ## @deftypefn {Function File} {@var{rgb} =} __next_line_color__ (@var{reset})
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6265
diff changeset
22 ## Undocumented internal function.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 7016
diff changeset
23 ## @end deftypefn
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6265
diff changeset
24
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
25 ## Return the next line color in the rotation.
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
26
16942
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 14138
diff changeset
27 ## Author: Carl Osterwisch
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
28 ## Author: jwe
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
29
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
30 function rgb = __next_line_color__ (reset)
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
31
16942
78a2f43bbc69 Implemented line color and style rotation across multiple axes (bug #39344).
costerwisch@costerwisch-lt1
parents: 14138
diff changeset
32 persistent reset_colors = true;
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
33
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
34 if (nargin == 1)
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
35 ## 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
36 reset_colors = reset;
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
37 else
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
38 ## Find and return the next line color
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
39 ca = gca ();
17436
47269b03a946 __next_line_color__.m: Remove use of CamelCase.
Rik <rik@octave.org>
parents: 17176
diff changeset
40 colororder = 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
41 if (reset_colors)
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
42 color_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
43 reset_colors = false;
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
44 else
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
45 ## Executed when "hold all" is active
17436
47269b03a946 __next_line_color__.m: Remove use of CamelCase.
Rik <rik@octave.org>
parents: 17176
diff changeset
46 n_kids = length (get (ca, "children"));
47269b03a946 __next_line_color__.m: Remove use of CamelCase.
Rik <rik@octave.org>
parents: 17176
diff changeset
47 n_colors = rows (colororder);
47269b03a946 __next_line_color__.m: Remove use of CamelCase.
Rik <rik@octave.org>
parents: 17176
diff changeset
48 color_index = mod (n_kids, n_colors) + 1;
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
49 endif
17436
47269b03a946 __next_line_color__.m: Remove use of CamelCase.
Rik <rik@octave.org>
parents: 17176
diff changeset
50 rgb = colororder(color_index,:);
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
51 endif
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
52
6264
cc2bee854d23 [project @ 2007-02-01 10:00:05 by jwe]
jwe
parents:
diff changeset
53 endfunction
16943
0dab17e69a55 Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents: 16942
diff changeset
54
19205
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
55
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
56 %!test
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
57 %! hf = figure ("visible", "off");
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
58 %! unwind_protect
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
59 %! hax = axes ();
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
60 %! set (hax, "colororder", [1 0 0; 0 1 0; 0 0 1]);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
61 %! hold on;
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
62 %! h = plot (1:5,1:5,'o', 1:4,1:4, "x", 1:3,1:3, "d");
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
63 %! assert (get (h, "color"), {[1 0 0]; [0 1 0]; [0 0 1]});
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 %! cla (hax);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
65 %! hold all;
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
66 %! h1 = plot (1:5,1:5,'o');
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
67 %! h2 = plot (1:4,1:4, "x");
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
68 %! h3 = plot (1:3,1:3, "d");
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
69 %! assert (get ([h1;h2;h3], "color"), {[1 0 0]; [0 1 0]; [0 0 1]});
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
70 %! unwind_protect_cleanup
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
71 %! close (hf);
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
72 %! end_unwind_protect
702aa79dc482 Add BIST tests for various quasi-internal m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
73