MATLAB Lecture 9 School of Mathematical Sciences Xiamen University tp: /gdjpkc. xmu. edu.cn MATLAB Lecture 9-Graphics-Surface 绘图 Ref: MATLAB-+3-D Visualization- Creating 3-D Graphs Vocabulary: plot绘图 surface曲面 mesh网格 grid格子 llustrate图解 region区域 polygon多边形 ak顶点 记号 helⅸx螺旋 magenta洋红色 cyan青色 gray灰色 aquamarine碧绿色 ● Some functions Plot3 mesh surf meshgrid fill3 fill *axis square *cylinder *sphere * comet ●3- D Graphs ◆ A Typical3- D Graph This table illustrates typical steps involved in producing 3-D scenes containing either data graphs or models of 3-D ep 1. Prepare your data Z= peaks(20) 2. Select window and position plot region figure(1) within windo subplot(2, 1, 2) 3. Call 3-D graphing function h=surf(z) 4. Set colormap and shading algorithm colormap hot shading interp set(h, Edge Color, k) 5. Add lighting. light("Position, [-2, 2, 20D) lighting phong material([04,0.60.5,30]) set(h, Face Color,,[0.7070 BackFaceLighting, Iit' 6. Set viewpoint view([30,25]) set(gca, Camera ViewAngleMode, Manual") 7. Set axis limits and tick marks axis([515515-88]) set(gca, ZTickLabel", Negative Positive 8. Set aspect ratio set(gca, Plot Box AspectRatio, [2.52. ID) 9. Annotate the graph with axis labels, xlabel(XA legend. and text ylabel(Y Axis") zlabel function Value) title(Peaks')MATLAB Lecture 9 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Lec91 MATLAB Lecture 9 –Graphics Surface 绘图 Ref: MATLAB→3D Visualization→Creating 3D Graphs l Vocabulary: plot 绘图 surface 曲面 mesh 网格 grid 格子 illustrate 图解 region 区域 polygon 多边形 peak 顶点 tick 记号 helix 螺旋 magenta 洋红色 cyan 青色 gray 灰色 aquamarine 碧绿色 l Some functions Plot3 mesh surf meshgrid fill3 fill *axis square *cylinder *sphere *comet3 l 3D Graphs ² A Typical 3D Graph This table illustrates typical steps involved in producing 3D scenes containing either data graphs or models of 3D objects. Step Typical Code 1. Prepare your data. Z = peaks(20); 2. Select window and position plot region within window. figure(1) subplot(2,1,2) 3. Call 3D graphing function. h = surf(Z); 4. Set colormap and shading algorithm. colormap hot shading interp set(h,'EdgeColor','k') 5. Add lighting. light('Position',[2,2,20]) lighting phong material([0.4,0.6,0.5,30]) set(h,'FaceColor',[0.7 0.7 0],... 'BackFaceLighting','lit') 6. Set viewpoint. view([30,25]) set(gca,'CameraViewAngleMode','Manual') 7. Set axis limits and tick marks. axis([5 15 5 15 8 8]) set(gca,'ZTickLabel','Negative||Positive') 8. Set aspect ratio. set(gca,'PlotBoxAspectRatio',[2.5 2.5 1]) 9. Annotate the graph with axis labels, legend, and text. xlabel('X Axis') ylabel('Y Axis') zlabel('Function Value') title('Peaks')