10.6: Other Common 2D Plot Types

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.6: Other Common 2D Plot Types

    The plot function is very common, but MATLAB includes many other plotting functions. The best plot depends on what you want to show.

    Plot type

    MATLAB function

    Best used for

    Line plot

    plot

    Continuous trends or relationships between x and y.

    Vertical bar plot

    bar

    Comparing categories or discrete values.

    Horizontal bar plot

    barh

    Comparing categories when labels may be long.

    Area plot

    area

    Showing accumulated values or filled trends.

    Stem plot

    stem

    Discrete data points, especially sequences.

    Histogram

    histogram

    Showing how often values occur in ranges or bins.

    Pie chart

    pie

    Showing parts of a whole.

    Scatter plot

    scatter

    Showing relationships between two variables without connecting points.

    Example \(\PageIndex{1}\)

    Visualize the same data using a simple plot, bar plot, horizontal bar plot, area plot, and stem plot.

    clear; clc; clf;
    
    x = 1:6;
    y = [33 11 5 9 22 30];
    
    
    subplot(2,3,1)
    plot(x, y)
    title('Regular Plot')
    
    
    subplot(2,3,2)
    bar(x, y)
    title('Bar Plot')
    
    
    subplot(2,3,31)
    barh(x, y)
    title('Horizontal Bar Plot')
    
    
    subplot(2,3,4)
    area(x, y)
    title('Area Plot')
    
    
    subplot(2,3,5)
    stem(x, y)
    title('Stem Plot')
    
    Solution

    clipboard_e916246018582b3cd2e2e1ea804115ad5.png


    This page titled 10.6: Other Common 2D Plot Types 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.