本节先代码,后出图
三维绘图
subplot(1,3,1) ; 同一绘图页面排版-------1行3列第1列
plot3 ----- 曲线
mesh ----- 网线
surf ----- 曲面
%-------------------------本例出图-----figure(1)
x=-2:0.1:2;
y=x;
[x1,y1]=meshgrid(x,y);
% meshgrid(x,y) 以x,y向量为基准,产生在x-y平面的各栅格点坐标值的矩阵
z1=x1.*exp(-(x1.^2+y1.^2));
figure(1)
subplot(1,3,1) % 同一绘图页面排版--1行3列第1列
plot3(x1,y1,z1) % plot3 曲线
subplot(1,3,2) % 同一绘图页面排版--1行3列第2列
mesh(z1) % mesh 网线
subplot(1,3,3) % 同一绘图页面排版--1行3列第13列
surf(x1,y1,z1) % surf 曲面
% 部分镂空
x1(10:20,10:20)=nan;
surf(x1,y1,z1)
% plot3 曲线
% mesh 网线
% surf 曲面
%-------------------------本例出图-----figure(2),figure(3)
x=-5:0.5:5;
y=x;
[x1,y1]=meshgrid(x,y);
% meshgrid(x,y) 以x,y向量为基准,产生在x-y平面的各栅格点坐标值的矩阵
z1=x1.^2+y1.^2;
figure(2)
mesh(x1,y1,z1)
colormap spring
colorbar % 显示颜色标尺
figure(3)
surf(x1,y1,z1)
shading interp
% colormap xx xx:预定义色图的函数表函数,色图
% shading interp 使颜色产生连续变化,细腻着色
% shading flat 小片或整段网线的颜色是同一种颜色
% shading faceted 在flat基础上,在小片交接的边勾画黑色
%-------------------------本例出图-----figure(4)
figure(4)
subplot(1,3,1) % 同一绘图页面排版--1行3列第1列
x1=[60 90 110 120 100 95];
bar(x1)
subplot(1,3,2) % 同一绘图页面排版--1行3列第2列
e=[0 0 0 0 0 1];
pie(x1,e,{'一月份','二月份','三月份','四月份','五月份','六月份'})
x2=[50 80 90 100 100 90];
x=[x1;x2];
subplot(1,3,3) % 同一绘图页面排版--1行3列第3列
bar3(x)