
最新四课数据可视化幻灯片.ppt
38页四课数据可视化四课数据可视化实验内容:用图形表示离散函数vn = 0:12;vy=1./abs(n+eps-6);vplot(n,y,’r*’,’MarkerSize’,20);vgrid on线型符号-:-.--含义实线虚线点划线双划线色彩符号bgrcmykw含义蓝绿红青品红黄黑白数据点符号含义符号含义.实心黑点d菱形符diamond+十字符h六角星符hexagram*八线符o空心圆圈^朝上三角符p五角星符pentagram<朝左三角符s方块符square>朝右三角符x叉字符v朝下三角符设置显示值范围、刻度和坐标分格线vmatlab:axis([0,pi,-1,1]);grid on;常用坐标指令(一)坐标轴控制方式、取向和范围指令含义axis auto使用缺省设置axis manual当前坐标轴范围不变axis on使用轴背景axis off取消轴背景axis ij矩阵式坐标axis xy普通直角坐标axis(v)v=[x1,x2,y1,y2]手工设定坐标范围常用坐标指令(二)坐标轴的高宽比指令含义axis equal纵横轴等刻度axis fillmanual下使坐标充满绘图区axis image纵横轴等刻度,坐标框紧贴数据范围axis normal缺省矩形坐标系axis square产生正方形坐标系axis tight把数据范围直接设为数据范围图形注释vmatlab:title(’调制波形’);xlabel(‘t’); ylabel(‘y’);legend(‘sin(t)’,’sin(t)sin(9t)’);text(2,0.5,’y=sin(t)sin(9t)’);图形的精细修饰vmatlab:set(h,'MarkerSize',10);叠绘vt = 2*pi*(0:20)/20;vy = cos(t).*exp(-0.4*t);vstem(t,y,'g');vhold on;vstairs(t,y,'r');vhold off;实验内容:绘制三维图形v三维数据准备:曲线和曲面v选定图形窗及子图位置v设置显示值范围、刻度和坐标分格线v图形注释v着色、明暗、灯光和材质处理v视点、三度(纵横高)比绘制三维曲线vmatlab:t = pi*(0:0.02:2);x = sin(t); y=cos(t); z = cos(2*t);plot3(x,y,z,'b-',x,y,z,'bd');view([-82,58]), box on, legend('链','宝石');绘制三维曲面vmatlab:x = -10:0.1:10;y = -10:0.1:10;[X,Y] = meshgrid(x,y);Z = X.^2+Y.^2;mesh(Z);基本三维绘图指令v曲线:plot3v曲面:meshsurfstem3vn = 0:0.1:12;vy = 1./abs(n+eps-6);vh = plot(n,y,'r*','MarkerSize',20);vgrid onv vtitle('调制波形');vxlabel('t'); ylabel('y');vlegend('sin(t)sin(9t)');vtext(2,0.5,'y=sin(t)sin(9t)');v vset(h,'MarkerSize',10);vt = 2*pi*(0:20)/20;vy = cos(t).*exp(-0.4*t);vstem(t,y,'g');vhold on;vstairs(t,y,'r');vhold off;vt = pi*(0:0.02:2);vx = sin(t); y=cos(t); z = cos(2*t);vplot3(x,y,z,'b-',x,y,z,'bd');vview([-82,58]), box on, legend('链','宝石');vx = -10:0.1:10;vy = -10:0.1:10;v v[X,Y] = meshgrid(x,y);vZ = X.^2+Y.^2;vmesh(Z);三维图形效果v透视v镂空v裁剪透 视v[X0,Y0,Z0] = sphere(30);vmesh(X0,Y0,Z0);vshading interpvhidden offvaxis equal, axis off镂 空vt = linspace(0,2*pi,100); r = 1-exp(-t/2).*cos(4*t);v[x,y,z] = cylinder(r,60);vii = find(x<0&y>0);vz(ii) = NaN;vsurf(x,y,z); colormap(spring); shading interp裁 剪vx = [-8:0.05:8]; y = x; v[X,Y] = meshgrid(x,y); ZZ = X.^2-Y.^2;vii = find(abs(X)>6|abs(Y)>6);vZZ(ii) = zeros(size(ii));vsurf(X,Y,ZZ), shading interp; colormap(copper)特殊图形指令v面域图 areav直方图 bar barh bar3 bar3hv饼图 pie pie3v填色图 fill fill3面域图 areavx = -2:2vy = [3,5,2,4,1;3,4,5,2,1;5,4,3,2,5]vcum_sum = cumsum(y);varea(x',y',0)vlegend('因素A','因素B','因素C'),grid on,colormap(spring)直方图 bar barhvx = -2:2vy = [3,5,2,4,1;3,4,5,2,1;5,4,3,2,5]vsubplot(1,2,1),bar(x',y','stacked')vxlabel('x'), ylabel('\Sigma y'), colormap(cool) vlegend('因素A','因素B','因素C')vsubplot(1,2,2), barh(x',y','grouped')vxlabel('y'), ylabel('x')vlegend('因素A','因素B','因素C')直方图 bar3 bar3hvsubplot(1,2,1), bar3(x',y',1)vxlabel('因素ABC'), ylabel('x'),zlabel('y')vcolormap(summer)vsubplot(1,2,2), bar3h(x',y','grouped')vylabel('y'), zlabel('x')饼图 pie pie3va = [1,1.6,1.2,0.8,2.1];vsubplot(1,2,1), pie(a,[1 0 1 0 0]),vlegend({'1','2','3','4','5'});vsubplot(1,2,2), pie3(a),colormap(cool)填色图 fill vn = 10;vdt = 2*pi/n; t = 0:dt:2*pi;vt = [t,t(1)];vx = sin(t); y = cos(t);vfill(x,y,'c'); axis offvgtext('十边行');填色图 fill3vxc = ones(2,4)/2;vx = [xc;[0 1 1 0]];vy = [xc;[0 0 1 1]];vz = [1 1 1 1;0 0 0 0;0 0 0 0];vc = [1 0 0 1;0 1 0 1;0 0 1 0]; vfill3(x,y,z,c),view([-10,56]),colormap coolvxlabel('x'), ylabel('y'), box on, grid on显示图像vimreadvimshowvdemovmatlab:I = imread(‘image path’);imshow(I);。












