二维图形绘制 MATLAB基本的二维图形包括线型(Line Plots)、散点型(Scatter Plots)、条形(Bar Plots)、极坐标型(Polar Plots)及矢量图(Vector Fields)。 (MATLAB的书买的太鸡肋了,里面东西都不全,help才是王道) plot指令1.种类 - plot(x,y)
- plot (y)
- plot (z)
- plot (A)
- plot (x,A)
- plot (A,x)
- plot (A,B)
- plot (x,y,str)
- plot (x1,y1,str1,x2,y2,str2,...)
2.栅格 grid on 命令可以在当前图形的单位标记处添加栅格 grid off命令可以取消栅格的显示
3.文字说明 - title('text')
- xlabel('text')
- ylabel('text')
- zlabel('text')
- text(x,y, 'text')
- text(x,y, 'text', 'sc')
4.程序
clc;clear;
normset = 0;
scale = 0.1;
origin = importdata('geo_origin.txt');%读取文件
deformation = importdata('geo_deformed.txt');
eigenVec = importdata('EigenDeformShapes.txt');
x_origin = origin(:,1);%读取第1列
y_origin = origin(:,2);%读取第2列
z_origin = origin(:,3);%读取第3列
%axis([-0.1 2.1 0 0.8 0 1]);
scatter3(x_origin,y_origin,z_origin,60,'blue','*')%绘制三维散点图
%x,y,z三个方向;图标大小;蓝色;图标*
axis equal;
xlabel('x','FontSize',18);%在x轴下的中间位置输入x,字号大小18
ylabel('y','FontSize',18);%在y轴下的中间位置输入x,字号大小18
grid on%画栅格
%figure
%plot3(x_origin,y_origin,z_origin,'b-','MarkerSize',6,'MarkerFaceColor','b')
%axis square equal;
%set(gca,'XTick',[0:0.1:1]);
%set(gca,'YTick',[0:0.2:1]);
%hold on
% for i= 0:1:78
% a = num2str(i)
% ttt = ['initiGeoOne.txt' a '.txt'];
% tt = importdata(ttt);
% x_temp = tt(:,1);
% y_temp = tt(:,2);
% z_temp = tt(:,3);
% %plot3(x_temp,y_temp,z_temp,'r-','MarkerSize',6,'MarkerFaceColor','b')
% hold on
% end
x_deformation = deformation(:,1);
y_deformation = deformation(:,2);
z_deformation = deformation(:,3);
%plot3(x_deformation,y_deformation,z_deformation,'r-','MarkerSize',6,'MarkerFaceColor','r')
%scatter3(x_deformation,y_deformation,z_deformation,36,'red','+')
for i=0:1:19
normset = i;
x_norm = x_origin + eigenVec(:, normset * 3 + 1) * scale;
y_norm = y_origin + eigenVec(:, normset * 3 + 2) * scale;
z_norm = z_origin + eigenVec(:, normset * 3 + 3) * scale;
figure;
scatter3(x_origin,y_origin,z_origin,30,'k','+')
%plot3(x_origin,y_origin,z_origin, 'b.','MarkerSize',4,'MarkerFaceColor','b','LineWidth',0.5)
hold on
scatter3(x_norm, y_norm, z_norm,36,'b','o')
%plot3(x_norm, y_norm, z_norm, 'r-','MarkerSize',6,'MarkerFaceColor','r','LineWidth',1)
axis equal;
xlabel('x','FontSize',18);
ylabel('y','FontSize',18);
zlabel('z','FontSize',18);
%legend('Original',['Mode' num2str(i+1)],'Location','best');
%set (gca,'position',[0.1,0.1,1,1] );
%set(gca,'XTick',[0:0.2:1]);
%set(gca,'YTick',[-0.5:0.2:0.5]);
%set(gca,'ZTick',[-0.5:0.2:0.5]);
%axis square
grid on
end
|