Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
public
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tom Marshall
public
Commits
22afdba3
Commit
22afdba3
authored
Jan 24, 2019
by
Tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed y-axis label and autosizing density plots
parent
949fe68c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
toy_example_with_patch.m
raincloud_plots/toy_example_with_patch.m
+20
-10
No files found.
raincloud_plots/toy_example_with_patch.m
View file @
22afdba3
...
...
@@ -27,11 +27,7 @@ function h = toy_example_with_patch(d,cl)
assert
(
all
(
size
(
cl
)
==
[
nseries
3
]),
'number of colors does not match number of plot series'
);
%%
% TO-DO: These shouldn't be hard-coded, but calculated somehow. How?
% (spacings between rainclouds)
% ALSO NOTE: This way plots the first data in the series on the top
ks_offsets
=
[
2
1
0
];
% NOTE: This way plots the first data in the series on the *bottom*
% Probably okay to hard-code this as it just determines the granularity of
% the density estimate
...
...
@@ -43,9 +39,17 @@ for i = 1:nper
% calculate kernel densities
[
ks
{
i
,
j
},
x
{
i
,
j
}]
=
ksdensity
(
d
{
i
,
j
},
'NumPoints'
,
nbins
);
% TO-DO: Switch here to use alternative methods to estimate density (e.g. RASH)
end
end
spacing
=
2
*
mean
(
mean
(
cellfun
(
@
max
,
ks
)));
ks_offsets
=
[
0
:
nper
-
1
]
.*
spacing
;
for
i
=
1
:
nper
for
j
=
1
:
nseries
% calculate patch vertices from kernel density
verts
{
i
,
j
}
=
[
x
{
i
,
j
}
', ks{i,j}'
+
ks_offsets
(
i
);
x
{
i
,
j
}
'
,
ones
(
nbins
,
1
)
*
ks_offsets
(
i
)];
verts
{
i
,
j
}
=
[
x
{
i
,
j
}
', ks{i,j}'
+
ks_offsets
(
i
);
x
{
i
,
j
}
'
,
ones
(
nbins
,
1
)
*
ks_offsets
(
i
)];
end
end
...
...
@@ -58,7 +62,7 @@ faces = [q, q+1, q+nbins+1, q+nbins];
%% jitter for the raindrops
% TO-DO: These should probably not be hardcoded either...
jitwidth
=
0.15
;
jitwidth
=
spacing
/
8
;
sz
=
100
;
for
i
=
1
:
nper
...
...
@@ -88,18 +92,24 @@ for i = 1:nper
end
end
% mean lines
%
plot
mean lines
for
i
=
2
:
nper
% note 2, not 1. We have nper-1 lines because lines connect pairs of points
for
j
=
1
:
nseries
line
(
mnz
([
i
-
1
i
],
j
),
ks_offsets
([
i
-
1
i
]),
'LineWidth'
,
4
,
'Color'
,
cl
(
j
,:));
end
end
% mean dots
%
plot
mean dots
for
i
=
1
:
nper
for
j
=
1
:
nseries
h
.
m
(
i
,
j
)
=
scatter
(
mnz
(
i
,
j
),
ks_offsets
(
i
),
'MarkerFaceColor'
,
cl
(
j
,:),
'MarkerEdgeColor'
,[
0
0
0
],
'MarkerFaceAlpha'
,
1
,
'SizeData'
,
sz
*
2
,
'LineWidth'
,
2
);
end
end
% keyboard
%% clear up axis labels
set
(
gca
,
'YTick'
,
ks_offsets
);
set
(
gca
,
'YTickLabel'
,
1
:
nper
);
%%
keyboard
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment