Mercurial > repos > public > sbplib
comparison Color.m @ 122:54cf593d6643
Added method for showing plotting samples in Color.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Dec 2015 11:28:53 +0100 |
parents | 1770689d6c31 |
children | 51d818bc8915 |
comparison
equal
deleted
inserted
replaced
121:ceba6be0389f | 122:54cf593d6643 |
---|---|
8 lightblue = [0.301 0.745 0.933]; | 8 lightblue = [0.301 0.745 0.933]; |
9 darkred = [0.635 0.078 0.184]; | 9 darkred = [0.635 0.078 0.184]; |
10 black = [0.000 0.000 0.000]; | 10 black = [0.000 0.000 0.000]; |
11 white = [1.000 1.000 1.000]; | 11 white = [1.000 1.000 1.000]; |
12 end | 12 end |
13 | |
14 methods(Static) | |
15 function sample() | |
16 markers ={'+', 'o', '*', '.', 'x', 'square', 'diamond', 'v', '^', '>', '<', 'pentagram', 'hexagram'}; | |
17 % Filled and non-filled markers? | |
18 lineStyles = {'-', '--', ':', '-.'}; | |
19 colors = { Color.blue, Color.red, Color.yellow, Color.purple, Color.green, Color.lightblue, Color.darkred, Color.black, Color.white}; | |
20 | |
21 | |
22 function showMarkers(x0, y0, lx, ly, color, filled) | |
23 n = length(markers); | |
24 s = ceil(sqrt(n)); | |
25 | |
26 x = linspace(x0, x0 + lx, s); | |
27 y = linspace(y0, y0 + ly, s); | |
28 | |
29 [X,Y] = meshgrid(x,y); | |
30 | |
31 for i = 1:n | |
32 lh = line(X(i),Y(i)); | |
33 lh.Marker = markers{i}; | |
34 lh.MarkerSize = 12; | |
35 lh.Color = color; | |
36 | |
37 if filled | |
38 lh.MarkerFaceColor = color; | |
39 end | |
40 end | |
41 end | |
42 | |
43 function showColors(x0, y0, lx, ly) | |
44 n = length(colors); | |
45 s = ceil(sqrt(n)); | |
46 | |
47 x = linspace(x0, x0 + lx, s); | |
48 y = linspace(y0, y0 + ly, s); | |
49 | |
50 [X,Y] = meshgrid(x,y); | |
51 | |
52 for i = 1:n | |
53 lh = line(X(i),Y(i)); | |
54 lh.Marker = 'o'; | |
55 lh.MarkerFaceColor = colors{i}; | |
56 lh.Color = colors{i}; | |
57 lh.MarkerSize = 12; | |
58 end | |
59 end | |
60 | |
61 function showLines(y0, ly, A, w) | |
62 n = length(lineStyles); | |
63 x = linspace(0,1,100); | |
64 y = linspace(y0, y0+ ly, n); | |
65 for i = 1:n | |
66 lh = line(x, y(i) + A*sin(pi*x*w)); | |
67 lh.LineWidth = 2; | |
68 lh.LineStyle = lineStyles{i}; | |
69 end | |
70 end | |
71 | |
72 | |
73 fh = figure(); | |
74 | |
75 y0 = 0.1; | |
76 dl = 0.15; | |
77 margin = 0.07; | |
78 showMarkers( 0.1, y0, dl, dl, Color.blue, false); | |
79 showMarkers( 0.9-dl, y0, dl, dl, Color.blue, true); | |
80 showColors( 0.5-dl/2, y0, dl, dl); | |
81 | |
82 showLines(0.6, 0.2, 0.1, 5); | |
83 | |
84 xlim([0 1]) | |
85 ylim([0 1]) | |
86 axis square | |
87 | |
88 end | |
89 end | |
13 end | 90 end |