-
Notifications
You must be signed in to change notification settings - Fork 10
/
fs_scatter.m
79 lines (73 loc) · 2.21 KB
/
fs_scatter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%% Matlab Graph Scatter Plot Examples
% *back to* <https://fanwangecon.github.io *Fan*>*'s* <https://fanwangecon.github.io/Math4Econ/
% *Intro Math for Econ*>*,* <https://fanwangecon.github.io/M4Econ/ *Matlab Examples*>*,
% or* <https://fanwangecon.github.io/MEconTools/ *MEconTools*> *Repositories*
%% Scatter Plot Example
% The plot below as square scatter points, each one with think border. Can set
% transparency of border/edge and inside separately.
close all;
figure();
size = 100;
s = scatter(1:10,1:10,size);
s.Marker = 's';
% color picked by using: uisetcolor
s.MarkerEdgeColor = [0 0.4471 0.7412];
s.MarkerEdgeAlpha = 0.5;
s.MarkerFaceColor = [.61 .51 .74];
s.MarkerFaceAlpha = 1.0;
s.LineWidth = 10;
grid on;
grid minor;
% 'o' Circle
% '+' Plus sign
% '*' Asterisk
% '.' Point
% 'x' Cross
% 'square' or 's' Square
% 'diamond' or 'd' Diamond
% '^' Upward-pointing triangle
% 'v' Downward-pointing triangle
% '>' Right-pointing triangle
% '<' Left-pointing triangle
% 'pentagram' or 'p' Five-pointed star (pentagram)
% 'hexagram' or 'h' Six-pointed star (hexagram)
% 'none' No markers
%% Scatter with Edge and Face Color and Transparency
% Here is another way to Set Scatter Edge and Fac Colors and Transparencies.
% Generate Data
rng(123);
it_x_n = 10;
it_x_groups_n = 3;
mat_y = rand([it_x_n, it_x_groups_n]);
mat_y = mat_y + sqrt(1:it_x_groups_n);
mat_y = mat_y + log(1:it_x_n)';
ar_x = 1:1:it_x_n;
% Colors
blue = [57 106 177]./255;
red = [204 37 41]./255;
black = [83 81 84]./255;
green = [62 150 81]./255;
brown = [146 36 40]./255;
purple = [107 76 154]./255;
cl_colors = {blue, red, black, ...
green, brown, purple};
% Scatter Shapes
cl_scatter_shapes = {'s','x','o','d','p','*'};
% Scatter Sizes
cl_scatter_sizes = {100,100,50,50,50,50};
% Legend Keys
cl_legend = {'For Borr', 'Inf Borr', 'For+Inf Br'};
% Plot
figure();
hold on;
for it_m = 1:it_x_groups_n
scatter(ar_x, mat_y(:,it_m), cl_scatter_sizes{it_m}, ...
'Marker', cl_scatter_shapes{it_m}, ...
'MarkerEdgeColor', cl_colors{it_m}, 'MarkerFaceAlpha', 0.8, ...
'MarkerFaceColor', cl_colors{it_m}, 'MarkerEdgeAlpha', 0.8);
cl_legend{it_m} = cl_legend{it_m};
end
legend(cl_legend, 'Location', 'best');
grid on;
grid minor;
%%