10.11: Three-Dimensional Plots

Fundamentals of MATLAB Programming · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY-NC-SA, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    10.11: Three-Dimensional Plots

    MATLAB also has plotting functions for three-dimensional data. Many of these functions have names similar to their two-dimensional versions, but with a 3 at the end.

    2D function

    3D function

    Description

    plot

    plot3

    Plots points or lines in 3D.

    bar

    bar3

    Creates a 3D bar plot.

    pie

    pie3

    Creates a 3D pie chart.

    stem

    stem3

    Creates a 3D stem plot.

    Example \(\PageIndex{1}\)

    Creating various three-dimensional plots.

    clear; clc; clf;
    
    % using plot3 function
    x = 1:5;
    y = [0 -2 4 11 3];
    z = 2:2:10;
    subplot(1,3,1)
    plot3(x, y, z, 'k*')
    grid on
    xlabel('x')
    ylabel('y')
    zlabel('z')
    title('3D Point Plot')
    
    % using bar3 function
    x = 1:6; 
    y = [33 11 5 9 22 30]; 
    subplot(1,3,2)
    bar3(x, y);
    grid on
    ylabel('x')
    zlabel('y')
    title('3D bar Plot')
    
    % using pie3 function
    subplot(1,3,3)
    pie3([3 10 5 2])
    title('3D pie chart')
    
    Solution

    clipboard_ee497ffda32c5b86b548c0b2b27cacc4e.png

    A 3D plot uses x, y, and z coordinates. This can be helpful when each data point has three related values.


    This page titled 10.11: Three-Dimensional Plots was last modified on Tue, 30 Jun 2026 02:11:46 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.