3-D Visualization    

A Typical 3-D Graph

This table illustrates typical steps involved in producing 3-D scenes containing either data graphs or models of 3-D objects. Example applications include pseudocolor surfaces illustrating the values of functions over specific regions and objects drawn with polygons and colored with light sources to produce realism. Usually, you follow either step 4 or step 5.

Step
Typical Code
  1. Prepare your data
Z = peaks(20);
  1. Select window and position plot region within window
figure(1)
subplot(2,1,2)
  1. Call 3-D graphing function
h = surf(Z);
  1. Set colormap and shading algorithm
colormap hot
shading interp
set(h,'EdgeColor','k')
  1. 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')
  1. Set viewpoint
view([30,25])
set(gca,'CameraViewAngleMode','Manual')
  1. Set axis limits and tick marks
axis([5 15 5 15 -8 8])
set(gca,'ZTickLabel','Negative||Positive')
  1. Set aspect ratio
set(gca,'PlotBoxAspectRatio',[2.5 2.5 1])
  1. Annotate the graph with axis labels, legend, and text
xlabel('X Axis')
ylabel('Y Axis')
zlabel('Function Value')
title('Peaks')
  1. Print graph
set(gcf,'PaperPositionMode','auto')
print -dps2


  Creating 3-D Graphs Line Plots of 3-D Data