-
Notifications
You must be signed in to change notification settings - Fork 5
/
plot_main_behav_between_trial.m
160 lines (127 loc) · 4.99 KB
/
plot_main_behav_between_trial.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
% plot main behavioral results (between-trial): choice1 accuracy and bet1 magnitude
% appears as Fig. 1H-I in Zhang & Gläscher (2020) [10.1126/sciadv.abb4159]
%% load data
load('data/behavioral/main_behav_data_between_trial.mat')
%% choice1 accuracy (Fig. 1H)
afs = 20; % axis font size
lfs = 24; % labels font size
f1 = figure;
set(f1,'color',[1 1 1])
set(f1,'position', [200 80 1000 700])
colors = cbrewer('qual', 'Set1', 10);
clr{1} = colors(2,:) ;
clr{2} = colors(1,:) ;
line_lw = 4;
errb_lw = 3;
subplot(1,2,1) % when switch
hold on
% with condition
o1 = plot(c1_switch.mean_with, '-');
set(o1,'color',clr{1},'LineWidth',line_lw)
% against condition
o2 = plot(c1_switch.mean_against, '-');
set(o2,'color',clr{2},'LineWidth',line_lw)
% errorbar
e1 = errorbar(c1_switch.mean_with, c1_switch.sem_with, 'color', clr{1});
set(e1, 'LineStyle', 'none'); set(e1, 'LineWidth', errb_lw);
e2 = errorbar(c1_switch.mean_against, c1_switch.sem_against, 'color', clr{2});
set(e2, 'LineStyle', 'none'); set(e2, 'LineWidth', errb_lw);
hold off
offsetAxes();
text(.8, .43, {'"Switch" trials:', 'C1(t+1) \neq C2(t)'}, 'FontSize', afs);
t = legend('With group','Against group','location','northwest');
set(t, 'FontSize',afs, 'box', 'off')
set(gca,'FontSize', afs)
xlabel('Group consensus', 'FontSize', lfs)
ylabel('Choice 1 accuracy on t+1 (%)','FontSize', lfs)
set(gca,'box','off' ,'TickDir','out', ...
'XTick',[1 2 3],'YTick',[.4:.05:.7], 'Xlim',[0.6 3], 'Ylim',[0.4 0.7], ...
'XTickLabel',{'2:2', '3:1', '4:0'}, ...
'YTickLabel',{'40','45','50','55','60','65','70'}, ...
'linewidth', 3, 'FontSize', afs)
subplot(1,2,2) % whey stay
hold on
% with condition
o1 = plot(c1_stay.mean_with, '-');
set(o1,'color',clr{1},'LineWidth',line_lw)
% against condition
o2 = plot(c1_stay.mean_against, '-');
set(o2,'color',clr{2},'LineWidth',line_lw)
% errorbar
e1 = errorbar(c1_stay.mean_with, c1_stay.sem_with, 'color', clr{1});
set(e1, 'LineStyle', 'none'); set(e1, 'LineWidth', errb_lw);
e2 = errorbar(c1_stay.mean_against, c1_stay.sem_against, 'color', clr{2});
set(e2, 'LineStyle', 'none'); set(e2, 'LineWidth', errb_lw);
hold off
offsetAxes();
text(.8, .43, {'"Stay" trials:', 'C1(t+1) = C2(t)'}, 'FontSize', afs);
set(gca,'FontSize', afs)
xlabel('Group consensus', 'FontSize', lfs)
ylabel('Choice accuracy (%)','FontSize', lfs)
set(gca,'box','off' ,'TickDir','out', ...
'XTick',[1 2 3],'YTick',[.4:.05:.7], 'Xlim',[0.6 3], 'Ylim',[0.4 0.7], ...
'XTickLabel',{'2:2', '3:1', '4:0'}, ...
'YTickLabel',{'40','45','50','55','60','65','70'}, ...
'linewidth', 3, 'FontSize', afs)
a = get(gca, 'YAxis');
a.Color = [1 1 1]; % make y-axis invisible
%% bet1 magnitude (Fig. 1I)
f2 = figure;
set(f2,'color',[1 1 1])
set(f2,'position', [200 80 1000 700])
colors = cbrewer('qual', 'Set1', 10);
clr{1} = colors(2,:) ;
clr{2} = colors(1,:) ;
line_lw = 4;
errb_lw = 3;
subplot(1,2,1) % when switch
hold on
% with condition
o1 = plot(b1_switch.mean_with, '-');
set(o1,'color',clr{1},'LineWidth',line_lw)
% against condition
o2 = plot(b1_switch.mean_against, '-');
set(o2,'color',clr{2},'LineWidth',line_lw)
% errorbar
e1 = errorbar(b1_switch.mean_with, b1_switch.sem_with, 'color', clr{1});
set(e1, 'LineStyle', 'none'); set(e1, 'LineWidth', errb_lw);
e2 = errorbar(b1_switch.mean_against, b1_switch.sem_against, 'color', clr{2});
set(e2, 'LineStyle', 'none'); set(e2, 'LineWidth', errb_lw);
hold off
offsetAxes();
text(.8, 1.752, {'"Switch" trials:', 'C1(t+1) \neq C2(t)'}, 'FontSize', afs);
t = legend('With group','Against group','location','northwest');
set(t, 'FontSize',afs, 'box', 'off')
xlabel('Group consensus', 'FontSize', lfs)
ylabel('Bet 1 magnitude on t+1','FontSize', lfs)
set(gca,'box','off' ,'TickDir','out', ...
'XTick',[1 2 3],'YTick',[1.7:.1:2.2], 'Xlim',[0.6 3], 'Ylim',[1.7 2.2], ...
'XTickLabel',{'2:2', '3:1', '4:0'}, ...
'YTickLabel',{'1.7', '1.8','1.9','2.0','2.1','2.2'}, ...
'linewidth', 3, 'FontSize', afs)
subplot(1,2,2) % whey stay
hold on
% with condition
o1 = plot(b1_stay.mean_with, '-');
set(o1,'color',clr{1},'LineWidth',line_lw)
% against condition
o2 = plot(b1_stay.mean_against, '-');
set(o2,'color',clr{2},'LineWidth',line_lw)
% errorbar
e1 = errorbar(b1_stay.mean_with, b1_stay.sem_with, 'color', clr{1});
set(e1, 'LineStyle', 'none'); set(e1, 'LineWidth', errb_lw);
e2 = errorbar(b1_stay.mean_against, b1_stay.sem_against, 'color', clr{2});
set(e2, 'LineStyle', 'none'); set(e2, 'LineWidth', errb_lw);
hold off
offsetAxes();
text(.8, 1.752, {'"Stay" trials:', 'C1(t+1) = C2(t)'}, 'FontSize', afs);
xlabel('Group consensus', 'FontSize', lfs)
ylabel('Bet 1 magnitude on t+1','FontSize', lfs)
set(gca,'box','off' ,'TickDir','out', ...
'XTick',[1 2 3],'YTick',[1.7:.1:2.2], 'Xlim',[0.6 3], 'Ylim',[1.7 2.2], ...
'XTickLabel',{'2:2', '3:1', '4:0'}, ...
'YTickLabel',{'1.7', '1.8','1.9','2.0','2.1','2.2'}, ...
'linewidth', 3, 'FontSize', afs)
a = get(gca, 'YAxis');
a.Color = [1 1 1]; % make y-axis invisible
% end of script