-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcolorpix_example.m
More file actions
72 lines (62 loc) · 2.13 KB
/
colorpix_example.m
File metadata and controls
72 lines (62 loc) · 2.13 KB
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
% script for colorpix example
% nature journal link: https://webvpn.xmu.edu.cn/https/77726476706e69737468656265737421e7e056d229317c456c0dc7af9758/articles/s41586-020-03119-1/figures/2
Moderate = [253,163,98] ./ 255;
Strong = [254,112,85] ./ 255;
Severe = [207,47,51] ./ 255;
Extreme = [133,52,61] ./ 255;
x = linspace(1, 10, 100);
rd = rand(size(x));
y1 = log(x) * 0.5 + rd;
y2 = log(x) + rd;
y3 = log(x) * 2 + rd;
y4 = log(x) * 3 + rd;
figure
hold on
fill([x, fliplr(x)], [y1, zeros(size(y1))], Moderate,...
'EdgeColor', 'None', 'FaceAlpha', 0.5)
fill([x, fliplr(x)], [y2, fliplr(y1)], Strong,...
'EdgeColor', 'None', 'FaceAlpha', 0.9)
fill([x, fliplr(x)], [y3, fliplr(y2)], Severe,...
'EdgeColor', 'None', 'FaceAlpha', 0.9)
fill([x, fliplr(x)], [y4, fliplr(y3)], Extreme,...
'EdgeColor', 'None', 'FaceAlpha', 0.9)
plot(x, y1, 'color', Severe - 0.1, 'LineWidth', 1.5)
plot(x, y2, 'color', Severe - 0.1, 'LineWidth', 1.5)
plot(x, y3, 'color', Extreme - 0.1, 'LineWidth', 1.5)
plot(x, y4, 'color', Extreme - 0.1, 'LineWidth', 1.5)
set(gca, 'linewidth', 1.25, 'fontsize', 16,...
'xcolor', 'k', 'ycolor', 'k', ...
'xlim', [0.9, 10.1])
box on
% print(gcf, '-djpeg', '-r300', 'imitation.jpg')
%% scatter
rng(0)
light_blue = [216,220,254] ./ 255;
light_red = [250,220,218] ./ 255;
x = 1 : 10;
y = randn(size(x)) * 3;
y2 = rand(size(x)) * 3;
figure
hold on
x_l = 0 : 11;
ml = zeros(size(x_l));
ul = ones(size(x_l)) * 5;
ll = ones(size(x_l)) * -5;
plot(x_l, ml, 'color', light_red - 0.1, 'LineWidth', 1.5)
plot(x_l, ul, 'color', light_blue - 0.1, 'LineWidth', 1.5)
plot(x_l, ll, 'color', light_blue - 0.1, 'LineWidth', 1.5)
fill([x_l, fliplr(x_l)], [ul, ll], light_blue, ...
'EdgeColor', 'None', 'FaceAlpha', 0.3)
scatter(x, y, 150, ...
'MarkerFaceColor', light_blue,...
'MarkerEdgeColor', light_blue - 0.1,'LineWidth', 1.5)
hold on
scatter(x, y2, 150, ...
'MarkerFaceColor', light_red,...
'MarkerEdgeColor', light_red - 0.1,'LineWidth', 1.5, ...
'Marker', 's')
set(gca, 'linewidth', 1.25, 'fontsize', 16,...
'xcolor', 'k', 'ycolor', 'k', ...
'xlim', [0, 11])
box on
% print(gcf, '-djpeg', '-r300', 'light_scatter.jpg')