-
Notifications
You must be signed in to change notification settings - Fork 7
/
mplotmatrix.m
executable file
·130 lines (122 loc) · 3.78 KB
/
mplotmatrix.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
function mplotmatrix(haxes,info)
% by Guoxu ZHOU
definfo=struct('signal',rand(2,100),'xlabel','Index','ylabel','\itt','zlabel','\it{s}({\itt})','viewpoint',[25 45],'title','plotmatrix','linewidth',2,...
'linestyle','','plotfunc','plot3','colormap','hsv','tag','plotmatrix','opos',[0.01 0.01 0.98 0.98],'units','normalized','legend','none');
if ~exist('info','var')
info=struct;
end
info=scanparam(definfo,info);
if isempty(haxes);
figure('name',info.title,'units',info.units,'numbertitle','off','outerposition',info.opos,'tag',info.tag);
haxes=gca;
else
set(get(haxes,'parent'),'units',info.units);
end
axes(haxes);
set(gca,'fontname','Times New Roman');
cla;
info.signal=real(info.signal);
[M T]=size(info.signal);
for m=1:M
% complabel{m}=['Comp. ' num2str(m)];
complabel{m}=[num2str(m)];
end
if min(M,T)>50
imagesc(info.signal);
axis equal;
axis tight;
colormap gray;
title(info.title);
return;
end
switch info.plotfunc
case 'plot'
view(2);
plot(info.signal',info.linestyle,'linewidth',info.linewidth');
grid on;
xlabel(info.ylabel);
ylabel(info.zlabel);
axis tight;
if ~strcmpi(info.legend,'none')
c=regexp(info.legend,'\s*\|\s*','split');
c=strtrim(c);
c=c(~cellfun('isempty', c));
legend(c);
end
case 'mplot'
view(2);
plot(bsxfun(@plus,datanormalize(info.signal',inf)./2,1:M),info.linestyle,'linewidth',info.linewidth');
grid on;
xlabel(info.ylabel);
ylabel('Components');
set(gca,'YTick',1:M);
axis tight;
case 'plot3'
view(3);
for m=1:M
plot3(m(ones(1,T)),1:T,info.signal(m,:),info.linestyle,'linewidth',info.linewidth);
hold on;
end
axis tight;
L=axis;
fv.FaceColor='interp';
fv.Faces=[1 2 3 4];
fv.EdgeColor='none';
for m=1:M
fv.Vertices=[m,L(3),L(5);m,L(4),L(5);m,L(4),L(6);m,L(3),L(6)];
fv.facevertexcdata=rand(length(fv.Vertices),3);
fv.FaceAlpha=max(0.85-m/4,0.2);
patch(fv);
end
hold off;
% xlabel(info.xlabel);
ylabel(info.ylabel);
zlabel(info.zlabel);
set(gca,'XTick',1:M,'XTickLabel',complabel);
xlabel('Components');
grid on;
view(info.viewpoint);
case 'stem3'
view(3);
stem3(info.signal,'o-');
axis tight;
xlabel(info.ylabel);
% ylabel(info.ylabel);
zlabel(info.zlabel);
grid on;
view(info.viewpoint);
set(gca,'YTick',1:M,'YTickLabel',complabel);
case 'ribbon'
view(3);
hrib=ribbon(info.signal');
set(hrib,'LineStyle','none');
% get(hrib(1))
axis tight;
% xlabel(info.xlabel);
ylabel(info.ylabel);
zlabel(info.zlabel);
grid on;
set(gca,'XTick',1:M,'XTickLabel',complabel);
view(info.viewpoint);
case 'waterfall'
h=waterfall(info.signal);
axis tight;
set(h,'facevertexcdata',rand(length(get(h,'Vertices')),3),'FaceAlpha',0.4,'FaceColor','flat','linewidth',info.linewidth,...
'Edgecolor','none');
colormap(info.colormap);
hold on;
for m=1:M
plot3(1:T,m(ones(1,T)),info.signal(m,:),'linewidth',info.linewidth);
hold on;
end
axis tight;
% ylabel(info.xlabel);
xlabel(info.ylabel);
zlabel(info.zlabel);
grid on;
view(info.viewpoint);
set(gca,'YTick',1:M,'YTickLabel',complabel);
ylabel('Components');
end
title(info.title);
end