3D Plotting in MATLAB: Lines, Surfaces, Meshes, and Scatter Graphs

MATLAB Illustration

MATLAB provides specialized functions for visualizing three-dimensional data including 3D line plots, shaded surface maps, wireframe meshes, and volumetric scatter graphs. These functions help engineers and researchers analyze multi-variable datasets, spatial trajectories, and mathematical surfaces.

1. 3D Line Plots using plot3()

Plot spatial curves and trajectories along three coordinates (X, Y, Z) using the plot3() function:

MATLAB
% 3D Helix Trajectory t = 0:pi/50:10*pi;
st = sin(t);
ct = cos(t);
figure;
plot3(st, ct, t, 'LineWidth', 2, 'Color', 'r');
grid on;
xlabel('X = sin(t)');
ylabel('Y = cos(t)');
zlabel('Z = t (Time / Height)');
title('3D Helix Trajectory Plot');
view(45, 30);
% Set azimuth and elevation

2. 3D Surface Plots (surf) and Meshes (mesh)

Visualize bivariate mathematical functions (Z = f(X,Y)) over a 2D domain grid created with meshgrid():

MATLAB
% Create 2D Grid Coordinates [X, Y] = meshgrid(-2:0.1:2, -2:0.1:2);
Z = X .* exp(-X.^2 - Y.^2);
% 1. Shaded 3D Surface Plot 
figure;
surf(X, Y, Z);
colormap(jet);
colorbar;
shading interp;
% Smooth color transitions 
title('3D Surface Plot using surf()');
xlabel('X-Axis');
ylabel('Y-Axis');
zlabel('Z-Axis');
% 2. 3D Wireframe Mesh Plot 
figure;
mesh(X, Y, Z);
colorbar;
title('3D Wireframe Mesh using mesh()');
xlabel('X-Axis');
ylabel('Y-Axis');
zlabel('Z-Axis');

3. 3D Scatter Plots using scatter3()

Visualize clustered data points in three-dimensional space with color-mapped values and variable marker sizing:

MATLAB
% Generate 3D Gaussian Point Cloud x = randn(200, 1);
y = randn(200, 1);
z = randn(200, 1);
colorValues = sqrt(x.^2 + y.^2 + z.^2);
% Distance from origin  
figure;
scatter3(x, y, z, 50, colorValues, 'filled');
colormap(parula);
colorbar;
grid on;
xlabel('X Coordinate');
ylabel('Y Coordinate');
zlabel('Z Coordinate');
title('3D Volumetric Scatter Plot with Color Mapping');

4. 3D Contour and Isosurface Plots

Project contour lines onto 3D planes to visualize gradient contours alongside surfaces:

MATLAB
% Combined Surface and 3D Contour Plot [X, Y, Z] = peaks(30);
figure;
surfc(X, Y, Z);
% Draws surface with contours beneath colormap(turbo);
colorbar;
title('3D Surface with Projected Contours (surfc)');
xlabel('X');
ylabel('Y');
zlabel('Z');

5. Summary of Common MATLAB 3D Plotting Functions

Function Plot Type Primary Use Case
plot3(x, y, z) 3D Line / Curve UAV trajectories, orbital paths, helical springs, time-series data.
surf(X, Y, Z) Shaded 3D Surface Continuous mathematical functions, terrain elevation, thermal distribution.
mesh(X, Y, Z) 3D Wireframe Grid connectivity, FEM structural deformation, low-overhead 3D inspection.
scatter3(x, y, z) 3D Scatter Points Point cloud datasets, LiDAR sensor scans, multi-feature clustering.
surfc(X, Y, Z) Surface + Contours Optimization landscapes, cost function visualization, saddle points.

Need Expert Guidance with MATLAB or Simulink?

Our 500+ PhD engineers provide verified MATLAB code, custom Simulink models, and 1-on-1 tutoring with Turnitin plagiarism reports.

Verified Feedback

What Engineering Students Say

Real feedback from students across top engineering universities worldwide.

Verified Student

“I got full marks on my MATLAB DSP assignment! The filter design code was completely vectorized, the frequency response plots were exact, and the delivery was 8 hours before my deadline. Highly recommended!”

AS

Aditi Sharma

IIT Bombay • Signal Processing Coursework
Verified Student

“Our Simulink EV powertrain model had severe algebraic loop and solver errors. The MATLABSolutions team fixed the solver configuration in 4 hours and provided an annotated scope diagram. Lifesaver for my final year!”

JM

John M.

Monash University, Australia • Simulink Dynamic Model
Technical Knowledge Base

Latest MATLAB Guides & Tutorials

Explore deep-dive technical articles written by our engineering team to master complex MATLAB & Simulink topics.

MATLAB Guide 5 Min Read

Run Convolutional Neural Networks on ARM Cortex-M with MATLAB

Why Run CNNs on Cortex-M Processors? ARM Cortex-M cores power millions of edge sensors, industrial controllers, and medical wearables. Running 1D or 2D Convolutional N...

MATLAB Guide 5 Min Read

INT8 Deep Learning Quantization in MATLAB for Embedded Systems

The Memory Wall on Edge Microcontrollers Standard neural networks store weights and compute activations using single-precision floating point (32-bit float...