-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShadeDist
76 lines (71 loc) · 2.42 KB
/
ShadeDist
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
function h = ShadeDist(x, y, C, alfa, SEM, shadeSEM, soloplot)
% h = ShadeDist(x, y, C, alfa, SEM, shadeSEM, soloplot)
%
% plot of x,y with color C and transparency alfa (usar alfa=0.5 para empezar)
% y suele ser una matriz de length(x) X n donde n es el número de réplicas
% plots the entire distribution with transparency and the non-transparent line with mean and
% SEM or the prefferred error (see below)
%
% SEM indica qué poner como barra de error en cada punto
% SEM = 0; usa los valores máximo y mínimo
% SEM = 1; usa el error estándar de la media
% SEM = 2; intervalos de confianza del 95% =1.96SEM
% SEM = 4; solo linea de la media sin error
%
% shadeSEM indica qué usar para hacer la sombra alrededor de la media
% shadeSEM = 0; usa los valores máximo y mínimo
% shadeSEM = 1; usa el error estándar de la media
% shadeSEM = 2; intervalos de confianza del 95% =1.96SEM
%
% soloplot = 1; solo los contornos
% soloplot = 0; Sombra coloreada
% soloplot = 2; sin sombra y sin contorno
%
% C tiene que estar en formato [R G B] p ej [0.5 .1 1]
%
if nargin < 5 %para asignar valores por default
SEM = 0;
shadeSEM = 0;
soloplot=0;
elseif nargin < 6
shadeSEM = 0;
soloplot=0;
elseif nargin<7;
soloplot=0;
end
desv=nanstd(y);
sterr= desv./sum(not(isnan(y))).^(1/2);
media=nanmean(y);
if shadeSEM==0
minY=min(y);
maxY=max(y);
elseif shadeSEM==1
minY=media-sterr;
maxY=media+sterr;
elseif shadeSEM==2
minY=media-((sterr*1.96));
maxY=media+((sterr*1.96));
end
if soloplot ==1
plot([x fliplr(x)],[minY fliplr(maxY)], '-', 'color',C*.8)
hold on
elseif soloplot==2
else
%a=fill([x fliplr(x)],[minY fliplr(maxY)],C, 'edgecolor','none');
a=patch([x fliplr(x)],[minY fliplr(maxY)],C, 'edgecolor','none');
% h=fill([x x],[min(y) max(y)], C); %así funcionaba para la s antigua antes de hacer
% curvas de muerte
set(a,'faceAlpha', alfa)
hold on
end
if SEM == 0
h=PlotConError(x, media, media+desv./2, media-desv./2, C, 'o-',3,.001 );
elseif SEM ==1
h=PlotConError(x, media, media+sterr./2, media-sterr./2, C, 'o-',3,.001 );
elseif SEM == 2
h=PlotConError(x, media, media+((sterr*1.96)./2), media-((sterr*1.96)./2), C, 'o',3,.01 );
elseif SEM==4
h=plot(x, media, 'o-', 'color', C, 'markersize',3);
hold on
end
end