Mercurial > hg > octave-lyh
annotate scripts/plot/private/__next_line_style__.m @ 16959:22ec459cf7ba
Correction to allow multi-line plots to have multiple colors (bug #16955).
author | Carl Osterwisch <costerwisch@generalcompression.com> |
---|---|
date | Thu, 11 Jul 2013 13:55:10 -0400 |
parents | 0dab17e69a55 |
children | abf384f5d243 |
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 |
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) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
32 print_usage (); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
33 endif |
16943
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
34 |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
35 if (nargin == 1) |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
36 ## 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
|
37 reset_style = reset; |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
38 else |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
39 ## 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
|
40 ca = gca (); |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
41 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
|
42 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
|
43 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
|
44 endif |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 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
|
49 else |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
50 ## 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
|
51 nChildren = length (get (ca, "Children")); |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
52 nColors = length (get (ca, "ColorOrder")); |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
53 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
|
54 endif |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
55 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
|
56 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
|
57 linestyle = options.linestyle; |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
58 marker = options.marker; |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
59 endif |
0dab17e69a55
Implement line color and style rotation across multiple axes (bug #39344).
Carl Osterwisch <costerwisch@costerwisch-lt1>
parents:
16942
diff
changeset
|
60 |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
61 endfunction |