我正在尝试在由虚线连接的3个不同平面中制作带有点的3d图。 数据分为两组:
第1组我正在尝试连接黑色半透明虚线 - 这里我遇到了麻烦。
第2组我试图用黑色半透明虚线连接 - 效果很好。
在第1组中,似乎matlab在彼此的顶部绘制了两条线,一条半透明的法线,顶部有一条虚线不透明线。两条线的代码相同,只有数据和颜色不同。
这是我的整个代码:
data = xlsread('rdata.xlsx','PCOA','A2:E43');
weight = xlsread('rdata.xlsx','PCOA','A45:C45');
data(:,1)= -data(:,1);
depl0 = data(1:7,[1,2]);
deol4 = data(8:14,[1,2]);
depl9 = data(15:21,[1,2]);
undepl0 = data(22:28,[1,2]);
undepl4 = data(29:35,[1,2]);
undepl9 = data(36:42,[1,2]);
depl0 = [ones(7,1),depl0];
deol4 = [2*ones(7,1),deol4];
depl9 = [3*ones(7,1),depl9];
undepl0 = [ones(7,1),undepl0];
undepl4 = [2*ones(7,1),undepl4];
undepl9 = [3*ones(7,1),undepl9];
hold on
s1 = plot3(depl0(:,1),depl0(:,2),depl0(:,3),'.','MarkerSize',20);
s2 = plot3(undepl0(:,1),undepl0(:,2),undepl0(:,3),'s','MarkerSize',5,'MarkerEdgeColor',[0 1/255 127/255],'MarkerFaceColor',[0 1/255 127/255]);
set(s1,'color',[0 0 0]);
set(s2,'color',[0 1/255 127/255]);
l = legend('FoxP3-DTR^+','FoxP3-DTR^-');
set(l,'box','off','Location','NorthOutside','Orientation','horizontal');
s1 = plot3(deol4(:,1),deol4(:,2),deol4(:,3),'.','MarkerSize',20);
s2 = plot3(undepl4(:,1),undepl4(:,2),undepl4(:,3),'s','MarkerSize',5,'MarkerEdgeColor',[0 1/255 127/255],'MarkerFaceColor',[0 1/255 127/255]);
set(s1,'color',[0 0 0]);
set(s2,'color',[0 1/255 127/255]);
s1 = plot3(depl9(:,1),depl9(:,2),depl9(:,3),'.','MarkerSize',20);
s2 = plot3(undepl9(:,1),undepl9(:,2),undepl9(:,3),'s','MarkerSize',5,'MarkerEdgeColor',[0 1/255 127/255],'MarkerFaceColor',[0 1/255 127/255]);
set(s1,'color',[0 0 0]);
set(s2,'color',[0 1/255 127/255]);
% Line depleted (7 instance)
for i = 1:7
X = [depl0(i,1), deol4(i,1), depl9(i,1)];
Y = [depl0(i,2), deol4(i,2), depl9(i,2)];
Z = [depl0(i,3), deol4(i,3), depl9(i,3)];
line(X,Y,Z,'color',[0 0 0 0.5],'LineWidth',1.5,'LineStyle','--');
end
% Line undepleted (7 instance)
for i = 1:7
X = [undepl0(i,1), undepl4(i,1), undepl9(i,1)];
Y = [undepl0(i,2), undepl4(i,2), undepl9(i,2)];
Z = [undepl0(i,3), undepl4(i,3), undepl9(i,3)];
plot3(X,Y,Z,'color',[0 1/255 127/255 0.5],'LineWidth',1.5,'LineStyle','--');
end
% Grid
for i =1:3
X = [i,i];
Y = [0.1,0.1];
Z = [-0.4,0.4];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Y = [-0.1,-0.1];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Y = [-0.3,-0.3];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Y = [-0.5,-0.5];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Y = [-0.5,0.3];
Z = [0,0];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Z = [0.4,0.4];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Z = [0.2,0.2];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
Z = [-0.2,-0.2];
line(X,Y,Z,'color',[87/255 91/255 69/255]);
end
% Three planes
syms x y z
ezsurf(sym('1'),y,z,[-0.5 0.3 -0.4 0.4]);
ezsurf(sym('2'),y,z,[-0.5 0.3 -0.4 0.4]);
ezsurf(sym('3'),y,z,[-0.5 0.3 -0.4 0.4]);
shading interp
alpha(0.1)
CM=[143/255,151/255,104/255];
CM=repmat(CM,64,1);
colormap(CM);
ytitle = strcat('PC 1 (',num2str(weight(1)),'%)');
ztitle = strcat('PC 2 (',num2str(weight(2)),'%)');
ylabel(ytitle, 'rotation', 42);
zlabel(ztitle);
%title('PCoA of colon samples');
xlabel('Days post DTH arthritis induction');
set(gca,'ZTick',-0.4:0.2:0.4)
set(gca,'ZTickLabel',{'','','','',''})
set(gca,'YTick',-0.5:0.2:0.3)
axis([1 3 -0.5 0.3 -0.4 0.4])
set(gca,'YTickLabel',{'','','','',''})
set(gca,'XTick',1:3)
set(gca,'XTickLabel',{'Day 0','Day 4','Day 9'})
set(gca,'fontsize',12,'fontname','Arial','fontweight', 'bold');
set(l,'fontsize',12,'fontname','Arial')
set(get(gca,'XLabel'),'FontSize',12,'fontname','Arial','fontweight', 'bold');
set(get(gca,'YLabel'),'FontSize',12,'fontname','Arial','fontweight', 'bold');
set(get(gca,'ZLabel'),'FontSize',12,'fontname','Arial','fontweight', 'bold');
h = rotate3d;
set(h,'ActionPostCallback',@align_axislabels);
set(get(gca,'title'),'visible','off');
% 'FontSize',16, 'fontweight', 'bold');
set(gca,'ticklength',[0.0 0.0]);%style 6
set(gca,'tickdir','out');%style 7
grid on
hold off
view([18 30])
% print -r600 % set resolution
% saveas(figure(1),'PCoA1-2.tif') % save image as a .tiff file
以下是数据:
data =
0.1866 0.0749 -0.1734 NaN 0
0.2001 0.0151 -0.0393 NaN 0
0.1057 -0.3854 0.0431 NaN 0
0.2048 0.1505 -0.1489 NaN 0
0.0482 -0.0006 -0.0153 NaN 0
0.1343 0.2477 0.0639 NaN 0
0.1886 -0.0139 0.1079 NaN 0
0.1600 -0.0637 -0.1771 NaN 4.0000
0.1571 -0.0156 -0.0961 NaN 4.0000
0.1465 -0.1112 -0.0855 NaN 4.0000
0.1758 0.0253 -0.1127 NaN 4.0000
0.1655 0.0928 -0.1666 NaN 4.0000
0.1491 0.0166 0.1677 NaN 4.0000
0.1526 0.1451 -0.0703 NaN 4.0000
0.1232 -0.3176 -0.0935 NaN 9.0000
0.1360 0.1054 -0.1026 NaN 9.0000
0.1938 -0.1332 -0.0826 NaN 9.0000
0.2053 -0.1563 0.0799 NaN 9.0000
0.1603 0.1803 -0.1093 NaN 9.0000
0.1371 0.2595 -0.0826 NaN 9.0000
0.1947 -0.1083 -0.0422 NaN 9.0000
0.0839 0.0808 0.1522 NaN 0
0.1757 0.0522 0.1423 NaN 0
-0.3631 0.0319 0.0232 NaN 0
-0.4284 0.0358 -0.0161 NaN 0
0.0265 0.2092 0.2739 NaN 0
-0.3970 -0.0270 -0.0618 NaN 0
-0.3005 -0.1025 -0.0696 NaN 0
0.1598 0.1318 0.0927 NaN 4.0000
0.1753 -0.1845 0.1493 NaN 4.0000
-0.2959 -0.0671 -0.1156 NaN 4.0000
-0.4260 0.1470 -0.0722 NaN 4.0000
-0.0407 -0.0009 0.0680 NaN 4.0000
-0.2739 -0.1550 0.0370 NaN 4.0000
-0.3063 -0.0713 0.0483 NaN 4.0000
0.2129 -0.1394 0.1374 NaN 9.0000
0.1940 -0.0936 0.0295 NaN 9.0000
-0.3589 0.0083 -0.0007 NaN 9.0000
-0.4232 0.0520 0.0296 NaN 9.0000
0.0577 0.1052 0.2468 NaN 9.0000
-0.3794 -0.0535 0.0540 NaN 9.0000
-0.4176 0.0332 -0.0130 NaN 9.0000
weight =
35.2300 11.4800 7.6900
以下是代码生成的图表: http://imgur.com/4lAtNAx
我希望DTR +组的线看起来与DTR组相似。
提前致谢!
答案 0 :(得分:0)
我发现了问题。
显然,出现不同的线条是由特定视角产生的伪影。当我在视图窗口中手动旋转图形时,线条显示为所需的虚线......
对于给您带来的不便表示歉心,感谢您的快速回复...